Im getting a fatal error and my server crashes saying "sv_ model not precached" . It only happens as soon as i switch to my knife . Heres my code , i cant find the problem , it still crashes
i think it has to do with the way i set the model , but i dnt know why.
Code:
#include <amxmodx>
#include <fakemeta_util>
#define TE_SMOKE 5
#define TE_LIGHTNING 7
new g_Switch;
new g_TSamari;
new g_CTSamari;
new sprite;
new origin[3];
new Lightning;
new VictomOrigin[3];
new AttackerOrigin[3];
new Weapon;
public plugin_init()
{
register_plugin("The Samari","0.1","The Specialist");
g_Switch = register_cvar("smr_switch","1");
register_event("HLTV", "RoundStart", "a", "1=0", "2=0");
register_event("CurWeapon","SamariModel","be","1=1");
register_forward(FM_PlayerPreThink,"MakeSamariSmoke");
register_event("Damage" , "SamariDamage" , "b");
}
// round start random players
public RoundStart(id)
{
g_CTSamari = 0;
g_TSamari = 0;
if(get_pcvar_num(g_Switch))
{
new Terrorist[32],T_num;
get_players(Terrorist,T_num,"ace","TERRORIST");
g_TSamari = Terrorist[random_num(0,T_num-1)]
new CTs[32],CT_num;
get_players(CTs,CT_num,"ace","CT");
g_CTSamari = CTs[random_num(0,CT_num-1)];
}
return;
}
// make the samari smoke
public MakeSamariSmoke(id)
{
if((g_CTSamari == id || g_TSamari == id) && ( pev(id,pev_button) & IN_USE ))
{
pev(id,pev_origin,origin);
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
write_byte(TE_SMOKE);
engfunc(EngFunc_WriteCoord,origin[0]);
engfunc(EngFunc_WriteCoord,origin[1]);
engfunc(EngFunc_WriteCoord,origin[2]);
write_short(sprite);
write_byte(255);
write_byte(0);
message_end();
}
}
// give the samari a model
public SamariModel(id)
{
new Weapon = read_data(2)
if((g_CTSamari || g_TSamari ) && ( Weapon == CSW_KNIFE))
{
set_pev( id, pev_viewmodel,"models/v_samari.mdl");
}
return;
}
// damage by the samarai sword
public SamariDamage(id)
{
new Damage = read_data( 2 );
new AttackerID = get_user_attacker( id, Weapon );
new Samari_Damage = Damage + 55 ;
new AHealth = pev(AttackerID,pev_health);
new VHealth = pev(id,pev_health);
if((Weapon == CSW_KNIFE) && (AttackerID == g_CTSamari || AttackerID == g_TSamari ))
{
fm_fakedamage(id,"weapon_knife",float(Samari_Damage),DMG_SLASH && DMG_BLAST);
set_pev(id,pev_health,AHealth + VHealth );
pev(id,pev_origin,VictomOrigin);
pev(AttackerID,pev_origin,AttackerOrigin);
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
write_byte(TE_LIGHTNING);
engfunc(EngFunc_WriteCoord,VictomOrigin[0]);
engfunc(EngFunc_WriteCoord,VictomOrigin[1]);
engfunc(EngFunc_WriteCoord,VictomOrigin[2]);
engfunc(EngFunc_WriteCoord,AttackerOrigin[0]) ;
engfunc(EngFunc_WriteCoord,AttackerOrigin[1]);
engfunc(EngFunc_WriteCoord,AttackerOrigin[2]);
write_byte(50);
write_byte(10);
write_byte(10);
write_short(Lightning);
message_end();
}
}
// precache file needed
public plugin_precache()
{
Lightning = precache_model("sprites/laserbeam.spr");
sprite = precache_model("sprites/steam1.spr");
precache_model("models/v_samari.mdl");
}