Raised This Month: $ Target: $400
 0% 

Check if player is in radius of entity?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-27-2006 , 23:44   Check if player is in radius of entity?
Reply With Quote #1

How can I check to see if any player is in the radius of any info_* entities?
hlstriker is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-27-2006 , 23:51   Re: Check if player is in radius of entity?
Reply With Quote #2

find_ent_in_sphere()
The Specialist is offline
Send a message via AIM to The Specialist
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 05-31-2007 , 15:29   Re: Check if player is in radius of entity?
Reply With Quote #3

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? }
hlstriker is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-31-2007 , 15:39   Re: Check if player is in radius of entity?
Reply With Quote #4

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 ;)
        }
    }
__________________
regalis is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 05-31-2007 , 15:41   Re: Check if player is in radius of entity?
Reply With Quote #5

[EDIT] nvm regalis beat me :/
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 05-31-2007 at 15:43.
Rolnaaba is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-31-2007 , 15:44   Re: Check if player is in radius of entity?
Reply With Quote #6

Quote:
Originally Posted by Rolnaaba View Post
[EDIT] nvm regalis beat me :/
Post it engine way ;)
I don't know engine realy good..
__________________
regalis is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 05-31-2007 , 15:57   Re: Check if player is in radius of entity?
Reply With Quote #7

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 ;)     } }

Last edited by hlstriker; 05-31-2007 at 16:07.
hlstriker is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 05-31-2007 , 16:33   Re: Check if player is in radius of entity?
Reply With Quote #8

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)
hlstriker is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-31-2007 , 18:00   Re: Check if player is in radius of entity?
Reply With Quote #9

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
__________________
regalis is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 05-31-2007 , 18:03   Re: Check if player is in radius of entity?
Reply With Quote #10

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.
hlstriker is offline
Reply



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 21:34.


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