Raised This Month: $51 Target: $400
 12% 

Random position in the range of player as the center


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tjdgns9246
Member
Join Date: Dec 2009
Old 07-29-2011 , 06:09   Random position in the range of player as the center
Reply With Quote #1

title is all.

how can i random position ? like this

----------------------|
|    .        |
|            |
|     O      |
|            |
|            |
|            |
|---------------------|


that dot is the random position and O is the player

how can i get random position like that ?

Last edited by tjdgns9246; 01-25-2012 at 10:07.
tjdgns9246 is offline
Pawn 3-pg
Senior Member
Join Date: Jul 2009
Old 07-29-2011 , 08:39   Re: Random position in the range of player as the center
Reply With Quote #2

This will find a random position within a 128 unit square around the client (64 units on each side from the player).
PHP Code:
new Float:x
new Float:y
new Float:pos[3]
GetClientAbsOrigin(clientpos)
GetRandomFloat(-64.064.0)
GetRandomFloat(-64.064.0)
pos[0] = pos[0] + x
pos
[1] = pos[1] + 

Last edited by Pawn 3-pg; 07-29-2011 at 10:44.
Pawn 3-pg is offline
tjdgns9246
Member
Join Date: Dec 2009
Old 07-29-2011 , 08:59   Re: Random position in the range of player as the center
Reply With Quote #3

Quote:
Originally Posted by Pawn 3-pg View Post
This will find a random position within a 128 unit square around the client (64 units on each side from the player).
PHP Code:
new Float:x
new Float:z
new Float:pos[3]
GetClientAbsOrigin(clientpos)
GetRandomFloat(-64.064.0)
GetRandomFloat(-64.064.0)
pos[0] = pos[0] + x
pos
[2] = pos[2] + 
um..... sorry for poor information

that picture is topview.

so if i want to get x & y position, should i replace z with y and pos[2] to pos[0] ?
tjdgns9246 is offline
Pawn 3-pg
Senior Member
Join Date: Jul 2009
Old 07-29-2011 , 10:45   Re: Random position in the range of player as the center
Reply With Quote #4

I edited my previous post. It should be pos[1] for the y position.
Pawn 3-pg is offline
tjdgns9246
Member
Join Date: Dec 2009
Old 07-29-2011 , 18:40   Re: Random position in the range of player as the center
Reply With Quote #5

Quote:
Originally Posted by Pawn 3-pg View Post
I edited my previous post. It should be pos[1] for the y position.
thanks a lot. it should be helpful for me ! XD
tjdgns9246 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 00:44.


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