PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Test"
#define VERSION "0.0"
#define AUTHOR "KORD_12.7"
#define IsValidPev(%0) (pev_valid(%0) == 2)
#define m_rgpPlayerItems_CWeaponBox 34
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "weaponbox", "Weaponbox_Spawn_Post", true);
register_forward(FM_SetModel, "FakeMeta_SetModel", false);
state WeaponBox_Disabled;
}
public Weaponbox_Spawn_Post(const iWeaponBox)
{
if (IsValidPev(iWeaponBox))
{
state (IsValidPev(pev(iWeaponBox, pev_owner))) WeaponBox_Enabled;
}
return HAM_IGNORED;
}
public FakeMeta_SetModel(const iEntity) <WeaponBox_Enabled>
{
state WeaponBox_Disabled;
if (!IsValidPev(iEntity))
{
return FMRES_IGNORED;
}
#define MAX_ITEM_TYPES 6
for (new i, iItem; i < MAX_ITEM_TYPES; i++)
{
iItem = get_pdata_cbase(iEntity, m_rgpPlayerItems_CWeaponBox + i, 4);
if (IsValidPev(iItem) /* && needed weapon check */)
{
//engfunc(EngFunc_SetModel, iEntity, "MY_MODEL.mdl");
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}
public FakeMeta_SetModel(const iEntity) <WeaponBox_Disabled>
{
return FMRES_IGNORED;
}
Code by (thanks to)
KORD_12.7.