Random spawn coords in a gangzone
#1

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 код:
boolIsPlayerInZone(playeridFloat:minxFloat:minyFloat:maxxFloat:maxy)  {
GetPlayerPos(playeridP[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;

Reply
#2

Maybe if you try to use the random () function with the minimum and maximum end of the X and Y positions
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
From YSI:

Код:
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 код:
frandom(Float:maxFloat:min 0.0dp 4)
{
    new
        
// Get the multiplication for storing fractional parts.
        
Float:mul floatpower(10.0dp),
        
// 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
Reply
#4

Bump
Reply
#5

Nothing, I am getting tag mismatch warning at
PHP код:
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 код:
Float:frandom(Float:maxFloat:min 0.0dp 4)
{
    new
        
// Get the multiplication for storing fractional parts.
        
Float:mul floatpower(10.0dp),
        
// Get the max and min as integers, with extra dp.
        
imin floatround(min mul),
        
imax floatround(max mul);
    new 
Floatfloat(random(imax imin) + imin) / mul;
    
// Get a random int between two bounds and convert it to a float.
    
return x;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)