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

[STOCK] isEntityInsideFakeZone


Post New Thread Reply   
 
Thread Tools Display Modes
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
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 01-19-2018 , 05:51   Re: [STOCK] isEntityInsideFakeZone
Reply With Quote #2

This might also be helpful if anyone needs it: https://forums.alliedmods.net/showthread.php?p=2030793
hmmmmm is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-19-2018 , 08:21   Re: [STOCK] isEntityInsideFakeZone
Reply With Quote #3

Quote:
Originally Posted by hmmmmm View Post
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.
eyal282 is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 01-19-2018 , 10:46   Re: [STOCK] isEntityInsideFakeZone
Reply With Quote #4

The stock I linked checks all axes
hmmmmm is offline
Reply



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:13.


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