AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check if player is in radius of entity? (https://forums.alliedmods.net/showthread.php?t=49101)

hlstriker 12-27-2006 23:44

Check if player is in radius of entity?
 
How can I check to see if any player is in the radius of any info_* entities?

The Specialist 12-27-2006 23:51

Re: Check if player is in radius of entity?
 
find_ent_in_sphere()

hlstriker 05-31-2007 15:29

Re: Check if player is in radius of entity?
 
I'm a bit confused on how to use find_ent_in_sphere(). I really don't even know how to set the function up to work.

I just need to find if any info_* entities are in the radius of a players id. If there are any info items then it can say... "Found info entity".

Code:
new ent; ent = -1 while((ent = find_ent_in_sphere(ent, ?,?))) {     // Now what? }

regalis 05-31-2007 15:39

Re: Check if player is in radius of entity?
 
Fakemeta !?
Code:

#include <fakemeta>

new Float:radius = 300.0;
new ent = -1;

    while((ent = engfunc(EngFunc_FindEntityInSphere, ent, PlayerOrigin, radius)) != 0)
    {
        pev(ent, pev_classname, entclass, 32)
        if(contain(entclass, "info_") != 0)
        {
            // found entity ;)
        }
    }


Rolnaaba 05-31-2007 15:41

Re: Check if player is in radius of entity?
 
[EDIT] nvm regalis beat me :/

regalis 05-31-2007 15:44

Re: Check if player is in radius of entity?
 
Quote:

Originally Posted by Rolnaaba (Post 484192)
[EDIT] nvm regalis beat me :/

Post it engine way ;)
I don't know engine realy good.. :P

hlstriker 05-31-2007 15:57

Re: Check if player is in radius of entity?
 
This should be the engine I'm assuming...

Code:
#include <engine> new Float:radius = 300.0; new ent = -1; new entClass[32]; while((ent = find_ent_in_sphere(ent, forigin, radius)) != 0) {     entity_get_string(ent, EV_SZ_classname, entClass, 31);     if(contain(entClass, "info_") != 0)     {         // found entity ;)     } }

hlstriker 05-31-2007 16:33

Re: Check if player is in radius of entity?
 
When trying to compile I get a tag mismatch on this line...
entity_get_string(ent, EV_SZ_classname, entClass, 31);

Also, should this line be a 0 or -1 at the end...?
while((ent = find_ent_in_sphere(ent, forigin, radius)) != 0)

regalis 05-31-2007 18:00

Re: Check if player is in radius of entity?
 
Why not using fakemeta?
pev(ent, pev_classname, entClass, 31) works fine ;)
But the engine way you posted looks correct too..0o

It should be 0 ;)

greetz regalis

hlstriker 05-31-2007 18:03

Re: Check if player is in radius of entity?
 
Hmm, I'm not sure why I get the tag mismatch then.

I'm trying to use engine too because the rest of my code is in engine.


All times are GMT -4. The time now is 22:24.

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