Raised This Month: $ Target: $400
 0% 

Fatal Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 15:26   Fatal Error
Reply With Quote #1

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"); }
The Specialist is offline
Send a message via AIM to The Specialist
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 12-08-2006 , 15:36   Re: Fatal Error
Reply With Quote #2

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")
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd

Last edited by Orangutanz; 12-08-2006 at 15:40.
Orangutanz is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 15:47   Re: Fatal Error
Reply With Quote #3

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 ? 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)

Last edited by The Specialist; 12-08-2006 at 16:15.
The Specialist is offline
Send a message via AIM to The Specialist
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 12-08-2006 , 17:35   Re: Fatal Error
Reply With Quote #4

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

Wich line is 117 then?
[ --<-@ ] Black Rose is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 17:38   Re: Fatal Error
Reply With Quote #5

117 is where it says , Ahealth = pev(AttackerID,pev_health)
son of a bitch now i have to rename my sma
The Specialist is offline
Send a message via AIM to The Specialist
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 12-08-2006 , 17:48   Re: Fatal Error
Reply With Quote #6

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);
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 17:50   Re: Fatal Error
Reply With Quote #7

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?
The Specialist is offline
Send a message via AIM to The Specialist
stupok
Veteran Member
Join Date: Feb 2006
Old 12-08-2006 , 17:57   Re: Fatal Error
Reply With Quote #8

How about...

is_user_connected()

is_user_alive()



Last edited by stupok; 12-08-2006 at 18:00.
stupok is offline
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 12-08-2006 , 17:58   Re: Fatal Error
Reply With Quote #9

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
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-08-2006 , 18:32   Re: Fatal Error
Reply With Quote #10

Ok i did some testing on that function you did (thank you )
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

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

Last edited by The Specialist; 12-08-2006 at 18:36.
The Specialist is offline
Send a message via AIM to The Specialist
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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