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(client, Float:point[8][3])
{
new Float:playerPos[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", playerPos);
playerPos[2] += 5.0;
for(new i=0; i<3; i++)
{
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(client, Float:array[8][3], beamsprite, halosprite, color[4], Float:life)
{
for(new i=0, i2=3; i2>=0; i+=i2--)
{
for(new j=1; j<=7; j+=(j/2)+1)
{
if(j != 7-i)
{
TE_SetupBeamPoints(array[i], array[j], beamsprite, halosprite, 0, 0, life, 5.0, 5.0, 0, 0.0, color, 0);
if(0 < client <= MaxClients)
TE_SendToClient(client, 0.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=1; i<7; i++)
{
for(new j=0; j<3; j++)
{
point[i][j] = point[((i >> (2-j)) & 1) * 7][j];
}
}
}
__________________