Raised This Month: $12 Target: $400
 3% 

[Solved] Detecting plugin created entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-09-2011 , 12:41   [Solved] Detecting plugin created entities
Reply With Quote #1

I'm trying to detect an entity that I've created with my plugin when I'm aiming at it, but it won't detect. I can detect any other entity in the map, just not the one that I've created.

Here's how I'm doing it:

PHP Code:
new gMdlPlant[] = "models/uplant1.mdl";

public 
plugin_precache()
{
    
precache_modelgMdlPlant );
}

public 
plugin_init()
{
    
register_forwardFM_TraceLine"fwTraceLine" );

    
register_clcmd"say /plant""cmdPlant");
}

public 
fwTraceLineFloat:start], Float:end], noMonstersidtrace )
{
    new 
ent get_tr2traceTR_pHit )
   
    if ( !
is_user_aliveid ) ) 
    return 
PLUGIN_HANDLED;
   
    if( 
is_valid_entent ) )
    {   
        new 
ent,body
        get_user_aiming
identbody )
   
        new 
owner peventpev_owner );
   
        static 
name32 ];
        
get_user_nameownernamecharsmaxname ) );

        
set_hudmessage02550, -1.00.3510.20.20.00.0);
        
show_hudmessageid"Entity owned by %s"name );
    }
    else
    {
        
set_hudmessage000, -1.00.000.00.00.00.0);
        
show_hudmessageid"" );
    }
   
    return 
FMRES_HANDLED;
}

public 
cmdPlantid )
{
    new 
Float:Origin];
    
entity_get_vectoridEV_VEC_originOrigin );
   
    new 
ent create_entity"info_target" );
    
entity_set_edictentEV_ENT_ownerid );
    
entity_set_originentOrigin );
    
entity_set_modelentgMdlPlant );
   
    
set_renderingentkRenderFxNone000kRenderNormal);
    
drop_to_floorent );
   
    return 
PLUGIN_CONTINUE;

Please help me out here

Last edited by hornet; 04-12-2011 at 23:20.
hornet is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-09-2011 , 12:53   Re: Detecting plugin created entities
Reply With Quote #2

Make your entity solid.
__________________
Arkshine is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-09-2011 , 13:18   Re: Detecting plugin created entities
Reply With Quote #3

Wouldn't that be achieved by doing:
PHP Code:
entity_set_intentEV_INT_solid
...because I added that into my entity creating function and it didn't work.
I made its solid type 4 because that's what every other detected entity's solid type is.
Is that correct?

EDIT: Ok thanks, I found a helpful thread here:

https://forums.alliedmods.net/archiv...p/t-79108.html

Now I just need to figure out how create this solid entity without getting my player stuck on it...

EDIT 2: Done.

Last edited by hornet; 04-09-2011 at 14:12.
hornet is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-11-2011 , 23:44   Re: Detecting plugin created entities
Reply With Quote #4

Now I'm need to set the owner of the entity, so I do:

PHP Code:
set_peventpev_ownerid ); 
But after reading the link I posted above, Exolent says that there's a certain order for the settings of an entity, and that if you don't do that order correctly, then the entity's solid key will fail. I've tried adding my line to set the owner, and that's exactly what happens, the solid key fails.
Can anyone help me?
hornet is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-12-2011 , 00:04   Re: Detecting plugin created entities
Reply With Quote #5

Entities act like they are not solid for the owner.
That is probably what is causing your problem.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-12-2011 , 23:20   Re: Detecting plugin created entities
Reply With Quote #6

Wow. That's exactly what the problem is. Thanks alot!

Solved.
hornet is offline
Reply


Thread Tools
Display Modes

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 15:28.


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