hi,
im lost with code can a person explain to me how to put knife model with this code (i wan a v_knife.mdl and p_knife.mdl)
#include <amxmodx>
#include <engine>
#include <fakemeta>
new VIEW_MODEL[] = "models/v_<model name>.mdl"
new PLAYER_MODEL[] = "models/p_<model name>.mdl"
new WORLD_MODEL[] = "models/w_<model name>.mdl"
new OLDWORLD_MODEL[] = "models/w_<model name>.mdl" // the world model you want replaced
new PLUGIN_NAME[] = "Custom Weapon 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)
{
// might not work for other mods
new weaponID = read_data(2)
// eg, if weapon is not ak then continue
if(weaponID != CSW_AK47)
return PLUGIN_CONTINUE
// this set's the view model (what you see when holding the gun)
entity_set_string(id, EV_SZ_viewmodel, VIEW_MODEL)
// this set's the player model (what you see when people holding the gun)
entity_set_string(id, EV_SZ_weaponmodel, PLAYER_MODEL)
return PLUGIN_CONTINUE
}
public fw_SetModel(entity, model[])
{
// check if its a valid entity or else we'll get errors
if(!is_valid_ent(entity))
return FMRES_IGNORED
// checks if it's the model we want to change
if(!equali(model, OLDWORLD_MODEL))
return FMRES_IGNORED
new className[33]
entity_get_string(entity, EV_SZ_classname, className, 32)
// dropped weapons map weapons c4 + grenades
if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
{
// set's the world model (what you see on the ground)
entity_set_model(entity, WORLD_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}