Raised This Month: $32 Target: $400
 8% 

[STOCK] isEntityInsideFakeZone


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-19-2018 , 05:26   [STOCK] isEntityInsideFakeZone
Reply With Quote #1

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.

Last edited by eyal282; 01-19-2018 at 05:27.
eyal282 is offline
 


Thread Tools
Display Modes

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 16:03.


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