Raised This Month: $ Target: $400
 0% 

Check if a player is within two positions?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jarrrk
New Member
Join Date: Aug 2014
Old 08-02-2014 , 13:15   Check if a player is within two positions?
Reply With Quote #1

Hi,

I want to respawn players in the same location if they're in a specified location.

Basically, how can I check if a player is within a two co-ordinates from getPos?

Cheers
Jarrrk is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-02-2014 , 13:18   Re: Check if a player is within two positions?
Reply With Quote #2

Get user's origin and check if it is in the parameters between the center and the radius of the sphere (I guess it is sphere?).
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Jarrrk
New Member
Join Date: Aug 2014
Old 08-02-2014 , 13:27   Re: Check if a player is within two positions?
Reply With Quote #3

The area would need to be a cube, have you got any code samples I could take a look at?

Cheers
Jarrrk is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 08-03-2014 , 19:59   Re: Check if a player is within two positions?
Reply With Quote #4

Better if you try to explain drawing it.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 08-03-2014 , 20:11   Re: Check if a player is within two positions?
Reply With Quote #5

Here's simple stock for it
PHP Code:
stock is_origin_in_cubeFloat:origin[3], Float:cubeorigin[3], Float:mins[3], Float:maxs[s] )
{
    static 
ac
    
for( 03a++ )
    {
        if( 
origin[a] > cubeorigin[a] + maxs[a] ) return 0
        
if( origin[cubeorigin[a] + mins[a] ) return 0
    
}
    return 
1

using:
PHP Code:
static Float:o[3// player origin
pevidpev_origin)
static 
Float:o2[3// cube origin ( I wont be setting cube origin so it will be in the middle )
static mins[3], maxs[3]
mins[0] = -10.0 // box x min side
mins[1] = -10.0 // box y min side
mins[2] = 0.0 // box z min side
maxs[0] = 10.0 // box x max side
maxs[1] = 10.0 // box y max side
maxs[2] = 20.0 // box z max side
// box size will be 20.0

if( is_origin_in_cubeoo2minsmaxs) ) // is inside the cube 
.Dare Devil. 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 22:27.


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