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

Entity mins and maxs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 01-23-2012 , 04:23   Entity mins and maxs
Reply With Quote #1

Could anybody help me? How to find entity's mins and maxs as you can do it with player by using GetClientMins() or GetClientMaxs()?
Yeah=} is offline
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 01-23-2012 , 04:42   Re: Entity mins and maxs
Reply With Quote #2

New question.

I want to check if player is in a sphere that located in an origin of an entity with a radius that equals a length of a vector of maxs of the entity. I've used this code but it works from time to time :\

PS. Can anybody tell me how works TraceHull? I was thinking that it checks if player is in a sphere.

PSPS. Maybe anybody know how to check if a player is in a sphere which is located in the random target on a map?


Code:
public bool:OnStartTouch( entity, collisiongroup, contentsmask, bool:originalResult )
{
	if( contentsmask & MASK_PLAYERSOLID )
	{
		new Float:fMins[3], Float:fMaxs[3];
		GetEntPropVector( entity, Prop_Send, "m_vecMins", fMins );
		GetEntPropVector( entity, Prop_Send, "m_vecMaxs", fMaxs );
		
		new Float:fPos[3], Float:fNewPos[3];
		GetEntPropVector( entity, Prop_Send, "m_vecOrigin", fPos );
		
		ScaleVector( fMins, 3.5 );
		ScaleVector( fMaxs, 3.5 );
		
		fNewPos[0] = fPos[0] + fMaxs[0] + 1.0;
		fNewPos[1] = fPos[1] + fMaxs[1] + 1.0;
		fNewPos[2] = fPos[2] + fMaxs[2] + 1.0;
		
		TR_TraceHull( fPos, fNewPos, fMins, fMaxs, MASK_PLAYERSOLID );
		
		if( TR_DidHit( ) )
		{
			new ent = TR_GetEntityIndex( );
			
			if( 1 <= ent <= MaxClients )
			{
				PrintToChatAll( "%d killed!", ent );
				ForcePlayerSuicide( ent );
			}
		}
	}
}

Last edited by Yeah=}; 01-23-2012 at 06:02.
Yeah=} is offline
-Absolute-
Member
Join Date: Mar 2010
Old 01-23-2012 , 16:32   Re: Entity mins and maxs
Reply With Quote #3

Checking if a Player is in a certain sphere (distance) of a point, you just have to calculate the distance, which is done by the Formula:
sqrt(x²+y²+z²) [where sqrt means square root]
If you now want to check if the player is in that specific distance you just compare the value you are outputted to the radius of your sphere, if its smaller than the radius, the player is in the sphere.

PS: you can omit the sqrt, but then use the ² of the radius
-Absolute- is offline
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 01-24-2012 , 05:58   Re: Entity mins and maxs
Reply With Quote #4

Quote:
Originally Posted by -Absolute- View Post
Checking if a Player is in a certain sphere (distance) of a point, you just have to calculate the distance, which is done by the Formula:
sqrt(x²+y²+z²) [where sqrt means square root]
If you now want to check if the player is in that specific distance you just compare the value you are outputted to the radius of your sphere, if its smaller than the radius, the player is in the sphere.

PS: you can omit the sqrt, but then use the ² of the radius
Thanks, I will try it.
Yeah=} 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 12:36.


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