Raised This Month: $32 Target: $400
 8% 

Check if player is entering a area/zone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NRG21
Member
Join Date: Mar 2013
Old 08-05-2013 , 12:54   Check if player is entering a area/zone
Reply With Quote #1

Hi,

how can i check, if a player is entering a specific area/zone on the map?

Thanks
NRG21 is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 08-05-2013 , 12:57   Re: Check if player is entering a area/zone
Reply With Quote #2

There are some props you can check on a client to see if they're in a zone...
__________________
View my Plugins | Donate
TnTSCS is offline
NRG21
Member
Join Date: Mar 2013
Old 08-05-2013 , 13:00   Re: Check if player is entering a area/zone
Reply With Quote #3

Can you give me an example? If I have the x, y and z-coordinates i want to check if a players has entered this zone.
NRG21 is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 08-05-2013 , 13:08   Re: Check if player is entering a area/zone
Reply With Quote #4

Are they zones in a map (like buy zones or bomb planting zones)? What game is this for?

Example: With CS:S (and possibly others) you can check the bool of m_bInBuyZone the player has... other games might have other similar netprops dealing with zones. There's also m_b_InBombZone, and m_bInHostageRescueZone...
__________________
View my Plugins | Donate

Last edited by TnTSCS; 08-05-2013 at 13:09.
TnTSCS is offline
NRG21
Member
Join Date: Mar 2013
Old 08-05-2013 , 13:14   Re: Check if player is entering a area/zone
Reply With Quote #5

The game is CS:S, but i want to check my own zone that i want to specify in the plugin, not the CSS-standard-zones like the buyzone, rescue-zone.
NRG21 is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 08-05-2013 , 13:35   Re: Check if player is entering a area/zone
Reply With Quote #6

Check out how this plugin is coded: http://forums.alliedmods.net/showthread.php?t=152898
__________________
View my Plugins | Donate
TnTSCS is offline
NRG21
Member
Join Date: Mar 2013
Old 08-05-2013 , 14:02   Re: Check if player is entering a area/zone
Reply With Quote #7

I've already checked this plugin and also the Death Zone-Plugin, but i can't get it. :/ Isn't there any tutorial for this?
NRG21 is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 08-05-2013 , 20:59   Re: Check if player is entering a area/zone
Reply With Quote #8

This is a function I use for a plugin I made. The logic is in there and the code is pretty short. It just checks if a player is between two opposite corners of a zone in all 3 axes
PHP Code:
bool:IsInsideZone(clientFloat:point[8][3])
{
    new 
Float:playerPos[3];
    
    
GetEntPropVector(clientProp_Send"m_vecOrigin"playerPos);
    
playerPos[2] += 5.0;
    
    for(new 
i=0i<3i++)
    {
        if(
point[0][i]>=playerPos[i] == point[7][i]>=playerPos[i])
        {
            return 
false;
        }
    }

    return 
true;

Here is a function I use to draw a zone
PHP Code:
/*
* Graphically draws a zone
*    if client == 0, it draws it for all players in the game
*   if client index is between 0 and MaxClients+1, it draws for the specified client
*/
DrawZone(clientFloat:array[8][3], beamspritehalospritecolor[4], Float:life)
{
    for(new 
i=0i2=3i2>=0i+=i2--)
    {
        for(new 
j=1j<=7j+=(j/2)+1)
        {
            if(
!= 7-i)
            {
                
TE_SetupBeamPoints(array[i], array[j], beamspritehalosprite00life5.05.000.0color0);
                if(
client <= MaxClients)
                    
TE_SendToClient(client0.0);
                else
                    
TE_SendToAll(0.0);
            }
        }
    }

And here is one I use to generate all 8 zone points from just 2
PHP Code:
/*
* Generates all 8 points of a zone given just 2 of its points
*/
CreateZonePoints(Float:point[8][3])
{
    for(new 
i=1i<7i++)
    {
        for(new 
j=0j<3j++)
        {
            
point[i][j] = point[((>> (2-j)) & 1) * 7][j];
        }
    }

They are all pretty complicated and took a lot of effort to figure out and are a lot faster and shorter in code then pretty much every other public one that you will find

Last edited by blaacky; 08-06-2013 at 05:45.
blaacky is offline
TheGodKing
BANNED
Join Date: Dec 2012
Location: PrintToChatAll("Aus
Old 08-06-2013 , 05:04   Re: Check if player is entering a area/zone
Reply With Quote #9

I ripped this method from cpmod, it is not my code.

This code uses a menu to setup coordinates for a zone and creates a sprite to outline the zone.
In the example code the zone will increment any clients hp who stands within it.

PS. I didn't proof read anything and this may contain code that isn't being used due to it being ripped to the point where my compiler was happy with it =p
Attached Files
File Type: sp Get Plugin or Get Source (zones.sp - 231 views - 8.2 KB)

Last edited by TheGodKing; 08-06-2013 at 05:07.
TheGodKing is offline
NRG21
Member
Join Date: Mar 2013
Old 08-06-2013 , 09:28   Re: Check if player is entering a area/zone
Reply With Quote #10

Thanks blaacky! I don't understand the CreateZonePoints-function (generate 8 zone points from just 2), can you give me an example how to use this with only 2 zone points?
NRG21 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 22:20.


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