Raised This Month: $ Target: $400
 0% 

Point inclusion, Zone points generation, and Zone drawing


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
blaacky
Senior Member
Join Date: Oct 2012
Old 08-06-2013 , 22:47   Point inclusion, Zone points generation, and Zone drawing
Reply With Quote #1

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. It would be neat in the future to have this work so it checks if any single part of a character is within a zone and not just the center of their feet.
PHP Code:
/*
* returns true if a player is inside the given zone
* returns false if they aren't in it
*/
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 2 opposite corners. This is so the zone can be drawn
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];
        }
    }

__________________

Last edited by blaacky; 06-14-2017 at 18:53.
blaacky is offline
 



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 18:27.


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