Участник
Пользователь
- Сообщения
- 166
- Реакции
- 34
- Помог
- 3 раз(а)
Хотелось добавлять к оружию в первом слоте дополнительное оружие, но только одно, не более.
Я поступил очень не гуманно, подумав, что все получиться и убрал оружие которое как мне казалось не должно будет добавляться. Но по факту не получилось, направьте на путь истинные в чем ошибка? Где то надо еще что то подправить как я понимаю?
Код:
// Copyright © 2016/2017 Vaqtincha
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
// #define CS_GO_FEATURE
#define PL_VERSION "0.0.1b"
#define ArmouryWeaponID(%1) g_iWeaponId[%1] // m_iItem to m_iId
const PRIMARY_ARMOURY_BS = ((1 << any:ARMOURY_MP5NAVY)|(1 << any:ARMOURY_TMP)|(1 << any:ARMOURY_P90)|(1 << any:ARMOURY_MAC10)
|(1 << any:ARMOURY_AK47)|(1 << any:ARMOURY_SG552)|(1 << any:ARMOURY_M4A1)|(1 << any:ARMOURY_AUG)|(1 << any:ARMOURY_SCOUT)
|(1 << any:ARMOURY_G3SG1)|(1 << any:ARMOURY_AWP)|(1 << any:ARMOURY_M3)|(1 << any:ARMOURY_XM1014)|(1 << any:ARMOURY_M249)
|(1 << any:ARMOURY_FAMAS)|(1 << any:ARMOURY_SG550)|(1 << any:ARMOURY_GALIL)|(1 << any:ARMOURY_UMP45)
)
new any:g_iWeaponId[any:ARMOURY_DEAGLE + 1] =
{
WEAPON_MP5N, WEAPON_TMP, WEAPON_P90, WEAPON_MAC10, WEAPON_AK47, WEAPON_SG552, WEAPON_M4A1, WEAPON_AUG,
WEAPON_SCOUT, WEAPON_G3SG1, WEAPON_AWP, WEAPON_M3, WEAPON_XM1014, WEAPON_M249, WEAPON_FLASHBANG, WEAPON_HEGRENADE,
WEAPON_NONE, WEAPON_NONE, WEAPON_SMOKEGRENADE, WEAPON_SHIELDGUN, WEAPON_FAMAS, WEAPON_SG550, WEAPON_GALIL,
WEAPON_UMP45, WEAPON_GLOCK18, WEAPON_USP, WEAPON_ELITE, WEAPON_FIVESEVEN, WEAPON_P228, WEAPON_DEAGLE
}
public plugin_init()
{
register_plugin("Primary Weapons Collector", PL_VERSION, "Vaqtincha")
RegisterHam(Ham_ObjectCaps, "armoury_entity", "CArmoury_ObjectCaps", .Post = false)
RegisterHam(Ham_ObjectCaps, "weaponbox", "CWeaponbox_ObjectCaps", .Post = false)
RegisterHam(Ham_Use, "weaponbox", "CWeaponbox_Use", .Post = true)
RegisterHam(Ham_Use, "armoury_entity", "CArmoury_Use", .Post = true)
}
public CArmoury_ObjectCaps(const pArmoury)
{
SetHamReturnInteger(FCAP_ONOFF_USE)
return HAM_SUPERCEDE
}
public CWeaponbox_ObjectCaps(const pWeaponBox)
{
SetHamReturnInteger(FCAP_ONOFF_USE)
return HAM_SUPERCEDE
}
public CArmoury_Use(const pArmoury, const pPlayer, const pCaller, const use_type, const Float:value)
{
if(value == 0.0 || is_nullent(pArmoury) || get_entvar(pArmoury, var_solid) != SOLID_TRIGGER || !is_user_alive(pPlayer))
return
new iItemID = get_member(pArmoury, m_Armoury_iItem)
if((PRIMARY_ARMOURY_BS & (1 << iItemID) && !user_has_weapon(pPlayer, ArmouryWeaponID(iItemID))))
{
#if defined CS_GO_FEATURE
rg_drop_items_by_slot(pPlayer, PRIMARY_WEAPON_SLOT)
#endif
set_member(pPlayer, m_bHasPrimary, false) // HACK
ExecuteHam(Ham_Touch, pArmoury, pPlayer)
}
}
public CWeaponbox_Use(const pWeaponBox, const pPlayer, const pCaller, const use_type, const Float:value)
{
if(value == 0.0 || is_nullent(pWeaponBox) || !(get_entvar(pWeaponBox, var_flags) & FL_ONGROUND) || !is_user_alive(pPlayer))
return
new pNextItem, pWeapon
if((pWeapon = get_member(pWeaponBox, m_WeaponBox_rgpPlayerItems, PRIMARY_WEAPON_SLOT)) <= 0)
return
if(user_has_weapon(pPlayer, get_member(pWeapon, m_iId))) // var_weapons
return
while(pWeapon > 0)
{
pNextItem = get_member(pWeapon, m_pNext)
set_member(pWeaponBox, m_WeaponBox_rgpPlayerItems, pNextItem, PRIMARY_WEAPON_SLOT)
#if defined CS_GO_FEATURE
rg_drop_items_by_slot(pPlayer, PRIMARY_WEAPON_SLOT)
#endif
if(ExecuteHam(Ham_AddPlayerItem, pPlayer, pWeapon))
{
ExecuteHam(Ham_Item_AttachToPlayer, pWeapon, pPlayer)
emit_sound(pPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
pWeapon = pNextItem
}
// set_entvar(pWeaponBox, var_flags, get_entvar(pWeaponBox, var_flags) | FL_KILLME)
set_entvar(pWeaponBox, var_nextthink, get_gametime() + 0.1)
}
Код:
#define ArmouryWeaponID(%1) g_iWeaponId[%1] // m_iItem to m_iId
const PRIMARY_ARMOURY_BS = ((1 << any:ARMOURY_MP5NAVY)|(1 << any:ARMOURY_TMP)|(1 << any:ARMOURY_P90)|(1 << any:ARMOURY_MAC10)
|(1 << any:ARMOURY_AK47)|(1 << any:ARMOURY_SG552)|(1 << any:ARMOURY_M4A1)|(1 << any:ARMOURY_AUG)|(1 << any:ARMOURY_SCOUT)
|(1 << any:ARMOURY_G3SG1)|(1 << any:ARMOURY_AWP)|(1 << any:ARMOURY_M3)|(1 << any:ARMOURY_XM1014)|(1 << any:ARMOURY_M249)
|(1 << any:ARMOURY_FAMAS)|(1 << any:ARMOURY_SG550)|(1 << any:ARMOURY_GALIL)|(1 << any:ARMOURY_UMP45)
)
new any:g_iWeaponId[any:ARMOURY_DEAGLE + 1] =
{
WEAPON_AK47, WEAPON_SG552, WEAPON_M4A1, WEAPON_AUG, WEAPON_AWP, WEAPON_GALIL
}