Sometimes ( at least in my codes ) I needed to know if an entity is inside a fake zone within a specific function, instead of hooking the moment of entering. So here you go:
Code:
stock bool:isEntityInsideFakeZone(entity, Float:xOriginWall, Float:xOriginParallelWall, Float:yOriginWall2, Float:yOriginParallelWall2, Float:zOriginCeiling, Float:zOriginFloor)
{
if(!IsValidEntity(entity))
ThrowError("Entity %i is not valid!", entity);
new Float:Origin[3];
GetEntPropVector(entity, Prop_Data, "m_vecOrigin", Origin);
if( ( Origin[0] >= xOriginWall && Origin[0] <= xOriginParalelWall ) || ( Origin[0] <= xOriginWall && Origin[0] >= xOriginParalelWall ) )
{
if( ( Origin[1] >= yOriginWall2 && Origin[1] <= yOriginParalelWall2 ) || ( Origin[1] <= yOriginWall2 && Origin[1] >= yOriginParalelWall2 ) )
{
if( ( Origin[2] >= zOriginFloor && Origin[2] <= zOriginCeiling ) || ( Origin[2] <= zOriginFloor && Origin[2] >= zOriginCeiling ) )
{
return true;
}
}
}
return false;
}
@entity = The entity whose origin you wish to compare to the zone.
@Float:xOriginWall = The x origin of a wall.
@Float:xOriginParallelWall = The x origin of a wall parallel to the first wall.
@Float:yOriginWall2 = The y origin of the other wall.
@Float:yOriginParallelWall = The y origin of the wall paralel to the other wall.
@Float:zOriginCeiling = The z origin of the ceiling.
@Float:zOriginFloor = The z origin of the floor.
@Note: All four walls and two ceilings should create a cube that is the zone.
@Note: When using the origins of the first and parallel to first wall, ensure that their Y origin is almost equal or you'll make the cube really problematic.