SA-MP Forums Random spawn coords in a gangzone
 New Account Members List Search Today's Posts Mark Forums Read

 22/09/2018, 07:27 PM #1 v1k1nG Huge Clucker     Join Date: Feb 2018 Posts: 435 Reputation: 31 Random spawn coords in a gangzone How would you spawn players in a random point, within a zone borders? I am trying to figure it out.. I am using this function to get if player is in zone: PHP Code: ``` bool: IsPlayerInZone(playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)  { GetPlayerPos(playerid, P[playerid][px], P[playerid][py], P[playerid][pz]); if (P[playerid][px] > minx && P[playerid][px] < maxx && P[playerid][py] > miny && P[playerid][py] < maxy) return true; return false; }  ``` __________________
 22/09/2018, 11:26 PM #2 DarkBr Huge Clucker   Join Date: Feb 2017 Location: ∫ f(x) dx Posts: 367 Reputation: 11 Re: Random spawn coords in a gangzone Maybe if you try to use the random () function with the minimum and maximum end of the X and Y positions
23/09/2018, 11:13 AM   #3
v1k1nG
Huge Clucker

Join Date: Feb 2018
Posts: 435
Reputation: 31
Re: Random spawn coords in a gangzone

Quote:
 Originally Posted by ****** From YSI: Code: ```new Float:x = FloatRandom(minx, maxx); new Float:y = FloatRandom(miny, maxy);```
Which file to include in the gamemode exactly? I have all of them already
Is it something like this?

PHP Code:
``` frandom(Float:max, Float:min = 0.0, dp = 4) {     new         // Get the multiplication for storing fractional parts.         Float:mul = floatpower(10.0, dp),         // Get the max and min as integers, with extra dp.         imin = floatround(min * mul),         imax = floatround(max * mul);     // Get a random int between two bounds and convert it to a float.     return float(random(imax - imin) + imin) / mul; }  ```
This was an old post of yours
__________________

 24/09/2018, 11:59 PM #4 v1k1nG Huge Clucker     Join Date: Feb 2018 Posts: 435 Reputation: 31 Re: Random spawn coords in a gangzone Bump __________________
 26/09/2018, 11:58 AM #5 v1k1nG Huge Clucker     Join Date: Feb 2018 Posts: 435 Reputation: 31 Re: Random spawn coords in a gangzone Nothing, I am getting tag mismatch warning at PHP Code: ``` return float(random(imax - imin) + imin) / mul;  ``` Also I was looking for the FloatRandom function in YSI files, but I didn't manage to find the file to include yet. EDIT It compiles, but does not seem to work though PHP Code: ``` Float:frandom(Float:max, Float:min = 0.0, dp = 4) {     new         // Get the multiplication for storing fractional parts.         Float:mul = floatpower(10.0, dp),         // Get the max and min as integers, with extra dp.         imin = floatround(min * mul),         imax = floatround(max * mul);     new Float: x = float(random(imax - imin) + imin) / mul;     // Get a random int between two bounds and convert it to a float.     return x; }  ``` __________________ Last edited by v1k1nG; 26/09/2018 at 01:10 PM.

 Thread Tools Display Modes Hybrid Mode

 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 Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Scropion Scripting Help 6 21/08/2015 10:00 PM fuckingcruse Scripting Help 1 12/03/2015 06:11 PM bajskorv123 Help Archive 2 26/12/2009 09:17 PM XtremeChio Help Archive 2 01/09/2009 01:57 PM _Vortex Help Archive 5 25/08/2009 04:27 PM

All times are GMT. The time now is 08:12 PM.

 -- (EN) English -- (RU) Русски Contact Us - SA-MP - Archive - Top