Actually, I just tested it again and I think the problem is from fakemeta, not hamsandwich. Here's the code that won't work:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#if !defined m_pPlayer
#define m_pPlayer 41
#endif
#define V_MODEL "models/iplaydr/v_knife20.mdl"
#define P_MODEL "models/iplaydr/p_knife20.mdl"
public plugin_init()
{
register_plugin("PluginName", "1.0", "OciXCrom")
RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
RegisterHam(Ham_Item_Deploy, "weapon_knife", "OnKnifeDeploy", 1)
//register_event("CurWeapon", "OnKnifeDeploy", "be", "1=1", "2=29")
}
public plugin_precache()
{
precache_model(V_MODEL)
precache_model(P_MODEL)
}
public OnPlayerSpawn(id)
{
if(is_user_alive(id))
{
strip_user_weapons(id)
give_item(id, "weapon_knife")
}
}
public OnKnifeDeploy(iEnt)
{
new id = pev(iEnt, pev_owner)
//new id = get_pdata_cbase(iEnt, 41, 5)
client_print(0, print_chat, "id is %i", id)
set_pev(id, pev_viewmodel2, V_MODEL)
set_pev(id, pev_weaponmodel2, P_MODEL)
}
This happens only if the weapons are removed on spawn.
The same code will work without problems if we use the CurWeapon event instead.
With the testing I just did, I found that using
pev(iEnt, pev_owner) to get the player's id returns 0 which is why the models isn't set. It returns the correct id however if the weapons aren't removed on spawn.
Getting the id with
get_pdata_cbase(iEnt, 41, 5) returns the correct value and the model is set.
__________________