Raised This Month: $ Target: $400
 0% 

Server crashing code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 12-16-2006 , 11:56   Server crashing code
Reply With Quote #1

The following Code is meant to give information
about Players and monsters you are looking at.
Actually it crashes the server if you look at an entity.
I probably am using the engfunc completely wrong.
Help please!
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define VERSION "1.0" new const ally_thingie[2][8]= {     "Enemy",     "Friend" } public plugin_init() {     register_plugin("SC Player Info",VERSION,"Silencer")     set_task(0.3,"SCPI_Overwrite",0,"",0,"b") } public SCPI_RemoveMsg(x) {     set_hudmessage(0,0,0,0.1,0.62,0,0.0,0.1,0.0,0.0,1)     show_hudmessage(x,"a") } public SCPI_Overwrite() {     new iPlayers[32],iNum     get_players(iPlayers,iNum,"ach")     new x,target,body,name[32],hp_str[16],ap_str[16],classname[64],displayname[32],is_ally_str[8],hp,ap,is_ally     for(new i=0;i<iNum;i++)     {         x=iPlayers[i]         get_user_aiming(x,target,body,9999)         if(target>0)         {             if(target<33)             {                 engfunc(EngFunc_InfoKeyValue,target,"health",hp_str,15)                 engfunc(EngFunc_InfoKeyValue,target,"battery",ap_str,15)                 hp=str_to_num(hp_str)                 ap=str_to_num(ap_str)                 get_user_name(target,name,31)                 set_hudmessage(10,220,30,0.1,0.62,0,0.0,255.0,0.01,0.0,1)                 show_hudmessage(x,"Player: %s^nHP|AP: %i|%i",name,hp,ap)             }             else             {                 pev(target,pev_classname,classname,63)                 if(containi(classname,"monster_")>-1)                 {                     engfunc(EngFunc_InfoKeyValue,target,"is_player_ally",is_ally_str,7)                     engfunc(EngFunc_InfoKeyValue,target,"health",hp_str,15)                     engfunc(EngFunc_InfoKeyValue,target,"displayname",displayname,31)                     hp=str_to_num(hp_str)                     is_ally=str_to_num(is_ally_str)                     if(equali(classname,"monster_scientist")||equali(classname,"monster_barney"))                     {                         switch(is_ally)                         {                             case 1:                             {                                 is_ally=0                             }                             case 0:                             {                                 is_ally=1                             }                         }                     }                     switch(is_ally)                     {                         case 1:                         {                             set_hudmessage(5,175,235,0.1,0.62,0,0.0,255.0,0.01,0.0,1)                         }                         case 0:                         {                             set_hudmessage(240,115,5,0.1,0.62,0,0.0,255.0,0.01,0.0,1)                         }                     }                     show_hudmessage(x,"%s: %s^nHP: %i",ally_thingie[is_ally],displayname,hp)                 }                 else                 {                     SCPI_RemoveMsg(x)                 }             }         }         else         {             SCPI_RemoveMsg(x)         }     } }
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 12-16-2006 at 17:32.
Silencer123 is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-16-2006 , 14:08   Re: Server crashing code
Reply With Quote #2

Well, the first thing you should do before asking for help is debugging, comment out all eng_func thingies.
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-16-2006 , 14:46   Re: Server crashing code
Reply With Quote #3

InfoKeyValue doesn't work to retrieve a value. It only takes two arguments, and you're giving it much more. This is why it is crashing.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 12-16-2006 , 15:23   Re: Server crashing code
Reply With Quote #4

Well, what should I use then??

BTW I increased the distance in get_user_aiming and added '>-1' to the containi condition.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-16-2006 , 17:17   Re: Server crashing code
Reply With Quote #5

also, don't create things in the for loop, create them outside it.
Ex.
Code:
for(new i;i<5;i++){
   new blahblah = i
}
->
Code:
new blahblah
for(new i;i<5;i++){
   blahblah = i
}
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Silencer123
Veteran Member
Join Date: Jul 2006
Old 12-16-2006 , 17:33   Re: Server crashing code
Reply With Quote #6

True. Changed that. However, I still need something
in fakemeta to read a specific keys value from an entity
and put it into a string.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
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:53.


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