15.05.2014, 13:32
pawn Код:
stock SetPlayerRandomPos(playerid, Float:position[][3], size = sizeof(position))
{
new rand = random(size);
SetPlayerPos(playerid, position[rand][0], position[rand][1], position[rand][2]);
return rand;
}
stock SetVehicleRandomPos(vehicleid, Float:position[][3], size = sizeof(position))
{
new rand = random(size);
SetVehiclePos(vehicleid, position[rand][0], position[rand][1], position[rand][2]);
return rand;
}
//Returning the randomized value because it can be used for anything else later.
An example of using it:
pawn Код:
new
Float:RandomPositions[5][3] = { //5 random XYZ positions.
{1614.7770,1162.2877,14.2188},
{2515.5234,-1675.7893,13.8168},
{-1723.2974,-89.6194,3.5547},
{-1980.5894,656.0847,46.5683},
{-1502.7856,824.2550,7.1875}
};
ExampleOnSomething(playerid, vehicleid)
{
SetPlayerRandomPos(playerid, RandomPositions);
SetVehicleRandomPos(vehicleid, RandomPositions);
return 1;
}