Нашел тут на dev-cs по созданию кастомных пушек:
подскажет кто-нибудь может как сделать выдачу не по флагу а по стим айди например или по нику+пасс на крайняк
заранее спасибо
Код:
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
#define WEAPON_CMD "give_m4a1" // Êîìàíäà ïî êîòîðîé áóäåò âûäàíî îðóæèå
#define WEAPON_ID WEAPON_M4A1 // ID îðóæèÿ
#define WEAPON_NAME "weapon_m4a1" // Íàçâàíèå îðóæèÿ
#define ACCESS_FLAG ADMIN_LEVEL_H // Ôëàã êîòîðîìó äîñòóïíî îðóæèå. Çàêîìåíòèðîâàòü ÷òîáû áûëî äîñòóïíî âñåì
#define WEAPON_DAMAGE 2.0 // Ìíîæèòåëü óðîíà. Çàêîìåíòèðîâàòü åñëè íå íóæíî
#define WEAPON_CLIP 35 // Êîëè÷åñòâî ïàòðîíîâ â îáîéìå. Çàêîìåíòèðîâàòü åñëè êîëè÷åñòâî ïî óìîë÷àíèþ
#define WEAPON_AMMO 120 // Êîëè÷åñòâî ïàòðîíîâ â çàïàñå
#define WEAPON_SPEED 300.0 // Ñêîðîñòü áåãà. Çàêîìåíòèðîâàòü åñëè êîëè÷åñòâî ïî óìîë÷àíèþ
#define WEAPON_GRAVITY 0.8 // Ãðàâèòàöèÿ (1.0 == sv_gravity). Çàêîìåíòèðîâàòü åñëè êîëè÷åñòâî ïî óìîë÷àíèþ.
#define MODEL_V "models/gold/v_m4a1.mdl" // Ìîäåëü îðóæèÿ. Çàêîìåíòèðîâàòü åñëè íå íóæíî
#define MODEL_P "models/gold/p_m4a1.mdl" // Ìîäåëü îðóæèÿ. Çàêîìåíòèðîâàòü åñëè íå íóæíî
#define MODEL_W "models/gold/w_m4a1.mdl" // Ìîäåëü îðóæèÿ. Çàêîìåíòèðîâàòü åñëè íå íóæíî
#define WEAPON_CAN_TOUCH_ONLY_OWNER // Ïîäíÿòü ñìîæåò òîëüêî âëàäåëåö. Çàêîìåíòèðîâàòü åñëè íå íóæíî
#define WEAPON_UID 1
#define IsCustomWeapon(%1) bool:(get_entvar(%1, var_impulse) == WEAPON_UID)
#if defined WEAPON_DAMAGE
new Float:g_PlayerDamage[MAX_PLAYERS + 1];
#endif
#if defined MODEL_V || defined MODEL_P || defined MODEL_W
public plugin_precache() {
#if defined MODEL_V
precache_model(MODEL_V);
#endif
#if defined MODEL_P
precache_model(MODEL_P);
#endif
#if defined MODEL_W
precache_model(MODEL_W);
#endif
}
#endif
public plugin_init() {
register_clcmd(WEAPON_CMD, "CmdGive");
#if defined MODEL_V || defined MODEL_P || defined WEAPON_DAMAGE || defined WEAPON_GRAVITY
RegisterHam(Ham_Item_Deploy, WEAPON_NAME, "HookItemDeploy", 1);
#endif
#if defined WEAPON_DAMAGE || defined WEAPON_GRAVITY
RegisterHam(Ham_Item_Holster, WEAPON_NAME, "HookHolster", 1);
#endif
#if defined MODEL_W
RegisterHookChain(RG_CWeaponBox_SetModel, "HookSetModel", 0);
#endif
#if defined WEAPON_DAMAGE
RegisterHookChain(RG_CBasePlayer_TakeDamage, "HookTakeDamage", 0);
#endif
#if defined WEAPON_CLIP
RegisterHam(Ham_Weapon_Reload, WEAPON_NAME, "HookReloaded", 0);
#endif
#if defined WEAPON_SPEED
RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "HookResetMaxSpeed", 1);
#endif
#if defined WEAPON_CAN_TOUCH_ONLY_OWNER
RegisterHam(Ham_Touch, "weaponbox", "HookWeaponBoxTouch", 0);
#endif
}
public CmdGive(id) {
#if defined ACCESS_FLAG
if (~get_user_flags(id) & ACCESS_FLAG) {
return PLUGIN_HANDLED;
}
#endif
new weapon = rg_give_custom_item(id, WEAPON_NAME, GT_REPLACE, WEAPON_UID);
if (is_nullent(weapon)) {
return PLUGIN_HANDLED;
}
#if defined WEAPON_CLIP
rg_set_iteminfo(weapon, ItemInfo_iMaxClip, WEAPON_CLIP);
rg_set_user_ammo(id, WEAPON_ID, WEAPON_CLIP);
#endif
#if defined WEAPON_AMMO
rg_set_user_bpammo(id, WEAPON_ID, WEAPON_AMMO);
#endif
return PLUGIN_HANDLED;
}
#if defined MODEL_V || defined MODEL_P || defined WEAPON_DAMAGE || defined WEAPON_GRAVITY
public HookItemDeploy(weapon) {
new id = get_member(weapon, m_pPlayer);
if (!is_user_connected(id) || !IsCustomWeapon(weapon)) {
return HAM_IGNORED;
}
#if defined MODEL_V
set_entvar(id, var_viewmodel, MODEL_V);
#endif
#if defined MODEL_V
set_entvar(id, var_weaponmodel, MODEL_P);
#endif
#if defined WEAPON_DAMAGE
g_PlayerDamage[id] = WEAPON_DAMAGE;
#endif
#if defined WEAPON_GRAVITY
set_entvar(id, var_gravity, WEAPON_GRAVITY);
#endif
return HAM_IGNORED;
}
#endif
#if defined WEAPON_DAMAGE || defined WEAPON_GRAVITY
public HookHolster(weapon) {
new id = get_member(weapon, m_pPlayer);
if (!is_user_connected(id)) {
return HAM_IGNORED;
}
#if defined WEAPON_DAMAGE
g_PlayerDamage[id] = 0.0;
#endif
#if defined WEAPON_GRAVITY
set_entvar(id, var_gravity, 1.0);
#endif
return HAM_IGNORED;
}
#endif
#if defined MODEL_W
public HookSetModel(const weaponbox, const model[]) {
new weapon = getWeaponBoxWeapon(weaponbox);
if (weaponbox != NULLENT && IsCustomWeapon(weapon)) {
SetHookChainArg(2, ATYPE_STRING, MODEL_W);
}
return HC_CONTINUE;
}
#endif
#if defined WEAPON_DAMAGE
public HookTakeDamage(const id, inflictor, attacker, Float:damage, type) {
if (
!is_user_connected(id) ||
id == attacker ||
attacker != inflictor ||
(type & (DMG_BULLET | DMG_NEVERGIB)) == 0
) {
return HC_CONTINUE;
}
if (g_PlayerDamage[attacker] > 0.0) {
SetHookChainArg(4, ATYPE_FLOAT, damage * g_PlayerDamage[attacker]);
}
return HC_CONTINUE;
}
#endif
#if defined WEAPON_CLIP
public HookReloaded(weapon) {
new id = get_member(weapon, m_pPlayer);
if (!is_user_connected(id) || !IsCustomWeapon(weapon)) {
return HAM_IGNORED;
}
if (get_member(weapon, m_Weapon_iClip) < WEAPON_CLIP) {
return HAM_IGNORED;
}
#if WEAPON_ID == WEAPON_M4A1
new animation = get_member(weapon, m_Weapon_iWeaponState) & WPNSTATE_M4A1_SILENCED ? 0 : 7;
#elseif WEAPON_ID == WEAPON_USP
new animation = get_member(weapon, m_Weapon_iWeaponState) & WPNSTATE_USP_SILENCED ? 0 : 8;
#else
new animation = 0
#endif
set_entvar(id, var_weaponanim, animation);
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id);
write_byte(animation);
write_byte(get_entvar(id, var_body));
message_end();
return HAM_SUPERCEDE;
}
#endif
#if defined WEAPON_SPEED
public HookResetMaxSpeed(const id)
{
new speed = floatround(Float:get_entvar(id, var_maxspeed));
if (speed == 900 || speed == 1) { // Observer mode or Freeze period
return HC_CONTINUE;
}
new weapon = get_member(id, m_pActiveItem);
if(
weapon == NULLENT ||
WeaponIdType:get_member(weapon, m_iId ) != WEAPON_ID ||
!IsCustomWeapon(weapon)
) {
return HC_CONTINUE;
}
set_entvar(id, var_maxspeed, WEAPON_SPEED);
return HC_CONTINUE;
}
#endif
#if defined WEAPON_CAN_TOUCH_ONLY_OWNER
public HookWeaponBoxTouch(const weaponbox, const id) {
new weapon = getWeaponBoxWeapon(weaponbox);
if(
weapon == NULLENT ||
WeaponIdType:get_member(weapon, m_iId ) != WEAPON_ID ||
!IsCustomWeapon(weapon)
) {
return HAM_IGNORED;
}
return get_entvar(weaponbox, var_owner) == id ? HAM_IGNORED : HAM_SUPERCEDE;
}
#endif
stock getWeaponBoxWeapon(const weaponbox) {
for (new i = 0, weapon; i < MAX_ITEM_TYPES; i++) {
weapon = get_member(weaponbox, m_WeaponBox_rgpPlayerItems, i);
if (!is_nullent(weapon)) {
return weapon;
}
}
return NULLENT;
}
подскажет кто-нибудь может как сделать выдачу не по флагу а по стим айди например или по нику+пасс на крайняк
заранее спасибо