Finding certain entity in sphere
First of all code :
PHP Code:
So first of all, this is just a part of modified LaserMine plugin (lasermine_023) which i didn't make, most of things are changed but nothing that is important in this exact function. For those who don't know this plugin, it sets a entity lasermine box that emits "light" and deals damage. What i am trying to do is detonate entity in radius of 512 units with conditions of its classname being "lasermine" == ENT_CLASS_NAME (ENT_CLASS_NAME is defined at the top of the code and that classname is set while creating lasermine), and it needs to be yours (LASERMINE_OWNER is defined and set same as ENT_CLASS_NAME). Problem : No matter where i go, how many lasers/entities surround it pops this message : Code:
[SkazzY LaserMine] Plugin is WORKINGSame message appears if i go out of the map where there are no entities. |
Re: Finding certain entity in sphere
LASERMINE_OWNER should probably be set to pev_iuser1 or something similar, depending on what the plugin uses to define the owner of it.
|
Re: Finding certain entity in sphere
Yes, it is define as pev_iuser2
PHP Code:
|
Re: Finding certain entity in sphere
Code:
You probably want to remove the "return" inside the if/else statement. Make a counter to see if you got any matches, display messages after the loop is complete, not during. You have got to let the loop finish completely. otherwise it will turn into a lottery. |
Re: Finding certain entity in sphere
Code:
public DetonateLasermine(id) |
Re: Finding certain entity in sphere
I totally forgot i need to loop all entities, so dumb. As you said it will turn into lottery.
@Black Rose Appreciate explaining @XaluX Appreciate the code EDIT : XaluX your code crashes my server after entering loop (It displays message that plugin is running, i made it with log_amx because that is instant without delay). |
Re: Finding certain entity in sphere
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:
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. |
Re: Finding certain entity in sphere
Server that i am making this for allows only 1 lasermine/player so that is not big of a problem. All of those messages were just for testing purposes, so I don't need to check logs, i just look at the chat and see what comes up, i'll just make 1 message "You detonated your lasermine" and "You don't have lasermine in radius of 512 units". First one is when the entity is found and when it gets destroyed before the break, and second one is when loop ends i'll just check if ent == -99 or not. In theory that should work. For log_amx I'll add that and i'll edit this post later today with results (Double posts are not allowed, correct me if i am wrong).
Edited Code:
L 05/10/2016 - 21:58:31: [lasermine_test.amxx] Looping entity 40 |
Re: Finding certain entity in sphere
With the same entity? (40)
What version of Engine are you using. Write "meta list" in your console to find out. Try using the fakemeta alternative just to see if you get a different result. engfunc(EngFunc_FindEntityInSphere, index, Float:origin[3], Float:radius) I can't see a reason within your code that will cause this error. For all I know, this is how that function is supposed to be used. |
Re: Finding certain entity in sphere
PHP Code:
I changed from : PHP Code:
PHP Code:
|
| All times are GMT -4. The time now is 18:37. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.