AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fatal Error (https://forums.alliedmods.net/showthread.php?t=48246)

The Specialist 12-08-2006 15:26

Fatal Error
 
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 :cry: 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"); }

Orangutanz 12-08-2006 15:36

Re: Fatal Error
 
The reason your getting an error is that the proper implementation of pev_viewmodel requires ALLOC_STRING since it uses an integer believe it or not :)

set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, "models/v_samari.mdl"))

or you can do:
set_pev(id, pev_viewmodel2, "models/v_samari.mdl")

The Specialist 12-08-2006 15:47

Re: Fatal Error
 
:up: OMG it worked perfectly. I tried eveyrthing . My only problem now is reseting the samari every round . thanks ++karma

EDIT : any idea why i get these run time errors now ?:cry: Also i dont see any lightning . The +damage works though and so does the smoke and model .

Code:


L 12/08/2006 - 15:00:48: Info (map "de_dust_cz") (logfile "error_120806.log")
L 12/08/2006 - 15:00:48: [FAKEMETA] Invalid entity
L 12/08/2006 - 15:00:49: [AMXX] Displaying debug trace (plugin "samari.amxx")
L 12/08/2006 - 15:00:49: [AMXX] Run time error 10: native error (native "pev")
L 12/08/2006 - 15:00:49: [AMXX]    [0] samari.sma::SamariDamage (line 117)


[ --<-@ ] Black Rose 12-08-2006 17:35

Re: Fatal Error
 
It's victim, not victom.
By "samari" do you mean "samurai"?

Wich line is 117 then?

The Specialist 12-08-2006 17:38

Re: Fatal Error
 
117 is where it says , Ahealth = pev(AttackerID,pev_health)
son of a bitch now i have to rename my sma :cry:

P34nut 12-08-2006 17:48

Re: Fatal Error
 
make sure that the attacker is connected

and btw
change:
Code:
fm_fakedamage(id,"weapon_knife",float(Samari_Damage),DMG_SLASH && DMG_BLAST); // TO fm_fakedamage(id,"weapon_knife",float(Samari_Damage),DMG_SLASH | DMG_BLAST);

The Specialist 12-08-2006 17:50

Re: Fatal Error
 
thanks Peanut :) But as far as making sure the user is connected, the user was me in my test server . so i know i was conencted. any ideas?

stupok 12-08-2006 17:57

Re: Fatal Error
 
How about...

is_user_connected()

is_user_alive()


:shock:

P34nut 12-08-2006 17:58

Re: Fatal Error
 
Code:
public SamariDamage(id) {     new Damage = read_data( 2 );     new AttackerID = get_user_attacker( id, Weapon );     new Samari_Damage = Damage + 55 ;     if (is_user_connected(AttackerID))     {         // Health is a float...         new Float:fAHealth         pev(AttackerID,pev_health, fAHealth);         new Float:fVHealth         pev(id,pev_health, fVHealth);                 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, fAHealth + fVHealth );             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();           }     } }

Test this plz

The Specialist 12-08-2006 18:32

Re: Fatal Error
 
Ok i did some testing on that function you did (thank you :wink: )
and it works to some degree.

1. You got the users health to early , before the extra damage was done , so there was to much health being givin out . and for some reason it wasnt doign the +55 damage.
2. no run time errors
3. no lightning :cry:

Stupko @ like i said that doesnt matter im in my test server alone with a bot testing it . Im alive and im connected .


All times are GMT -4. The time now is 06:56.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.