AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detecting entity inside a zone (https://forums.alliedmods.net/showthread.php?t=298961)

Creater RJ 06-27-2017 22:20

Detecting entity inside a zone
 
Is it possible to detect a non - player entity inside a zone ? buyzone, escapezone, etc

Craxor 06-28-2017 09:57

Re: Detecting entity inside a zone
 
Yes.

I'l show a method when i will have free time, until then i will post just the function i use:

Code:
bool:isPlayer(i) {     new classname[8];     pev( i, pev_classname, classname, charsmax(classname) );     return  classname[0] == 'p'         && classname[1] == 'l'         && classname[2] == 'a'         && classname[3] == 'y'          && classname[4] == 'e'         && classname[5] == 'r'         && classname[6] == EOS; }

PRoSToTeM@ 06-28-2017 10:13

Re: Detecting entity inside a zone
 
Quote:

Originally Posted by Craxor (Post 2532222)
Code:
return bool:(classname[0]=='p'&&classname[1]=='l'&&classname[3]=='y'&&classname[5]=='r');

It is already bool and you should check all 7 cells.
Code:
return classname[0] == 'p' && classname[1] == 'l' && classname[2] == 'a' && classname[3] == 'y' && classname[4] == 'e' && classname[5] == 'r' && classname[6] == EOS;
But easier and better just check for is_user_connected or is_user_alive or 1 <= player <= MaxPlayers (get_maxplayers()).

Creater RJ 06-28-2017 10:58

Re: Detecting entity inside a zone
 
Quote:

Originally Posted by Craxor (Post 2532222)
Yes.

I'l show a method when i will have free time, until then i will post just the function i use:

PHP Code:

bool:isPlayer(i)
{
    new 
classname[8];
    
pevipev_classnameclassnamecharsmax(classname) );

    return 
bool:(classname[0]=='p'&&classname[1]=='l'&&classname[3]=='y'&&classname[5]=='r');



Sorry i didnt get you, i want to detect a non-player entity inside a zone , something like cs_get_user_mapzones(player) which will work only for players , i want for non-player entity

Craxor 06-28-2017 15:18

Re: Detecting entity inside a zone
 
Yes, you can use my function to check if is a non player by doing:

Code:
if( !isPlayer(ent) ) { }

Also i've editet the func with prostemato suggestions, check again the code.

HamletEagle 06-28-2017 16:16

Re: Detecting entity inside a zone
 
Quote:

Originally Posted by Craxor (Post 2532301)
Yes, you can use my function to check if is a non player by doing:

Code:
if( !isPlayer(ent) ) { }

Also i've editet the func with prostemato suggestions, check again the code.

That's not what he is asking....
He's asking how to check if an entity is inside a zone. I think I posted some snippet for that 2/3 times some years ago, you may try to search...

baneado 06-28-2017 17:19

Re: Detecting entity inside a zone
 
Depending what zone you want to check...

Creater RJ 06-28-2017 18:55

Re: Detecting entity inside a zone
 
Quote:

Originally Posted by HamletEagle (Post 2532312)
That's not what he is asking....
He's asking how to check if an entity is inside a zone. I think I posted some snippet for that 2/3 times some years ago, you may try to search...

I tried searching your posts and didnt get any related title for this it will be great if you can do the favour, thanks in advance :)

Creater RJ 06-28-2017 18:57

Re: Detecting entity inside a zone
 
Quote:

Originally Posted by baneado (Post 2532329)
Depending what zone you want to check...

It may be any zone, escape zone, buyzone or bombsite zone as i am going to create it myself using valve hammer, I just want to detect if that entity is inside that zone/area :)

Craxor 06-28-2017 23:26

Re: Detecting entity inside a zone
 
Check 'zone info' by alka.


All times are GMT -4. The time now is 23:08.

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