Raised This Month: $ Target: $400
 0% 

Finding certain entity in sphere


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-10-2016 , 11:15   Re: Finding certain entity in sphere
Reply With Quote #7

I don't see an obvious reason for the crash. Xalus code will still only find one lasermine and destroy it.
If you want to edit it to find more you need to remove "ent = -99;" and "break". But you also have to find another condition to display the message. I strongly suggest a counter. And if counter is not equal to 0, display the message.
To find what part of the code crashes the server, add log_amx between each line to see exactly where it stops. Like this for example:
Code:
    log_amx("Starting the loop");     while((ent = find_ent_in_sphere(id,origin,512.0)) != 0)     {         log_amx("Looping entity %d", ent);         pev(ent, pev_classname, EntityName, 31)         if(equali(EntityName, ENT_CLASS_NAME))         {             log_amx("Classname match on entity %d", ent);             if(pev(ent, LASERMINE_OWNER) == id)             {                 log_amx("Owner match on entity %d: %d", ent, id);                 PlaySound(ent, STOP_SOUND)                 log_amx("PlaySound completed");                 CreateExplosion(ent)                 log_amx("CreateExplosion completed");                 CreateDamage(ent, get_pcvar_float(g_LRDMG), get_pcvar_float(g_LRADIUS))                 log_amx("CreateDamage completed");                 RemoveEntity(ent)                 log_amx("RemoveEntity completed");                 ColorChat(id, RED, "^4[SkazzY LaserMine] ^1You have succesfully ^3DETONATED ^1your lasermine")                 log_amx("ColorChat completed");                                 ent = -99;                 break             }         }     }     log_amx("Loop completed");
And as a side note, almost all code is instant. There is only one thread in AMXX and HLDS for that matter. Otherwise you would not be able to manipulate hooks and stop them if necessary.
As far as plugin coding goes, as long as you're inside a function in your code, nothing else will run until that function is finished.
The exception is if a module creates another thread. But this can only be done with certain things, like sockets or heavy calculations that does not require any input to finish.
__________________

Last edited by Black Rose; 05-10-2016 at 11:19.
Black Rose is offline
 



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 18:37.


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