Raised This Month: $ Target: $400
 0% 

Finding certain entity in sphere


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SkazzY
AlliedModders Donor
Join Date: Nov 2014
Location: Forbidden Forest
Old 05-07-2016 , 19:26   Finding certain entity in sphere
Reply With Quote #1

First of all code :
PHP Code:
public DetonateLasermine(id)
{
    new 
EntityName[32];
    new 
Float:origin[3]
    
pev(id,pev_origin,origin);
    new 
ent = -1
    ColorChat
(idRED"^4[SkazzY LaserMine] ^1Plugin is ^3WORKING")
    while((
ent find_ent_in_sphere(id,origin,512.0)) != 0) {
        
pev(entpev_classnameEntityName31)
        if(
equali(EntityNameENT_CLASS_NAME))
        {
            if(
pev(entLASERMINE_OWNER) != id)
            {
                
ColorChat(idRED"^4[SkazzY LaserMine] ^1You don't have any lasermines in ^3RADIUS ^1of ^3512 ^1units")
                return 
PLUGIN_HANDLED
            
}
            else
            {
                
PlaySound(entSTOP_SOUND)
                
CreateExplosion(ent)
                
CreateDamage(entget_pcvar_float(g_LRDMG), get_pcvar_float(g_LRADIUS))
                
RemoveEntity(ent)
                
ColorChat(idRED"^4[SkazzY LaserMine] ^1You have succesfully ^3DETONATED ^1your lasermine")
                return 
PLUGIN_HANDLED
            
}
        }
        
ColorChat(idRED"^4[SkazzY LaserMine] ^1There are no lasermines in ^3RADIUS ^1of ^3512 ^1units")
        return 
PLUGIN_HANDLED
    
}  
    return 
PLUGIN_HANDLED

Explain :
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 WORKING
[SkazzY LaserMine] There are no lasermines in RADIUS of 512 units
Which means plugin did find entity but that entity isn't lasermine.
Same message appears if i go out of the map where there are no entities.

Last edited by SkazzY; 05-07-2016 at 19:59. Reason: Updated code
SkazzY 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