Is this the right way of precaching more then 1 model? and is there an easier way cause this way doesn't work and only works for 1 model
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
new const VIEW_MODEL[] =
{
"models/cod4/v_aug.mdl",
"models/cod4/v_scout.mdl"
}
new const PLAYER_MODEL[] =
{
"models/cod4/p_aug.mdl",
"models/cod4/p_scout.mdl"
}
new const WORLD_MODEL[] =
{
"models/cod4/w_aug.mdl",
"models/cod4/w_scout.mdl"
}
new const OLDWORLD_MODEL[] =
{
"w_aug.mdl",
"w_scout.mdl"
}
new PLUGIN_NAME[] = "Custom Knife Model"
new PLUGIN_AUTHOR[] = "Cheap_Suit"
new PLUGIN_VERSION[] = "1.0"
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_event("CurWeapon", "Event_CurWeapon", "be","1=1")
register_forward(FM_SetModel, "fw_SetModel")
}
public plugin_precache()
{
precache_model(VIEW_MODEL)
precache_model(PLAYER_MODEL)
precache_model(WORLD_MODEL)
}
public Event_CurWeapon(id)
{
new weaponID = read_data(2)
if(weaponID != CSW_AUG)
return PLUGIN_CONTINUE
if(weaponID != CSW_SCOUT)
return PLUGIN_CONTINUE
set_pev(id, pev_viewmodel2, VIEW_MODEL)
set_pev(id, pev_weaponmodel2, PLAYER_MODEL)
return PLUGIN_CONTINUE
}
public fw_SetModel(entity, model[])
{
if(!is_valid_ent(entity))
return FMRES_IGNORED
if(!equali(model, OLDWORLD_MODEL))
return FMRES_IGNORED
new className[33]
entity_get_string(entity, EV_SZ_classname, className, 32)
if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
{
engfunc(EngFunc_SetModel, entity, WORLD_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}