AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Check if player is entering a area/zone (https://forums.alliedmods.net/showthread.php?t=222695)

NRG21 08-05-2013 12:54

Check if player is entering a area/zone
 
Hi,

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

Thanks

TnTSCS 08-05-2013 12:57

Re: Check if player is entering a area/zone
 
There are some props you can check on a client to see if they're in a zone...

NRG21 08-05-2013 13:00

Re: Check if player is entering a area/zone
 
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.

TnTSCS 08-05-2013 13:08

Re: Check if player is entering a area/zone
 
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...

NRG21 08-05-2013 13:14

Re: Check if player is entering a area/zone
 
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.

TnTSCS 08-05-2013 13:35

Re: Check if player is entering a area/zone
 
Check out how this plugin is coded: http://forums.alliedmods.net/showthread.php?t=152898

NRG21 08-05-2013 14:02

Re: Check if player is entering a area/zone
 
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?

blaacky 08-05-2013 20:59

Re: Check if player is entering a area/zone
 
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

TheGodKing 08-06-2013 05:04

Re: Check if player is entering a area/zone
 
1 Attachment(s)
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

NRG21 08-06-2013 09:28

Re: Check if player is entering a area/zone
 
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?


All times are GMT -4. The time now is 10:40.

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