AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [STOCK] isEntityInsideFakeZone (https://forums.alliedmods.net/showthread.php?t=304555)

eyal282 01-19-2018 05:26

[STOCK] isEntityInsideFakeZone
 
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.

hmmmmm 01-19-2018 05:51

Re: [STOCK] isEntityInsideFakeZone
 
This might also be helpful if anyone needs it: https://forums.alliedmods.net/showthread.php?p=2030793

eyal282 01-19-2018 08:21

Re: [STOCK] isEntityInsideFakeZone
 
Quote:

Originally Posted by hmmmmm (Post 2572846)
This might also be helpful if anyone needs it: https://forums.alliedmods.net/showthread.php?p=2030793

In your stock you must ensure that the first origin is above / below the second, mine double checks everything so no mistakes are done.

hmmmmm 01-19-2018 10:46

Re: [STOCK] isEntityInsideFakeZone
 
The stock I linked checks all axes


All times are GMT -4. The time now is 19:32.

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