AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server crashing code (https://forums.alliedmods.net/showthread.php?t=48616)

Silencer123 12-16-2006 11:56

Server crashing code
 
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)         }     } }

dutchmeat 12-16-2006 14:08

Re: Server crashing code
 
Well, the first thing you should do before asking for help is debugging, comment out all eng_func thingies.

XxAvalanchexX 12-16-2006 14:46

Re: Server crashing code
 
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.

Silencer123 12-16-2006 15:23

Re: Server crashing code
 
Well, what should I use then??

BTW I increased the distance in get_user_aiming and added '>-1' to the containi condition.

Emp` 12-16-2006 17:17

Re: Server crashing code
 
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
}


Silencer123 12-16-2006 17:33

Re: Server crashing code
 
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.


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

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