Random
From SA-MP Wiki
(Difference between revisions)
Revision as of 13:38, 29 January 2014 Smithy (Talk | contribs) ← Previous diff |
Revision as of 14:58, 2 February 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 35: | Line 35: | ||
[[Category:Scripting Functions]] | [[Category:Scripting Functions]] | ||
+ | |||
[[de:random]] | [[de:random]] | ||
+ | [[fr:Random]] |
Revision as of 14:58, 2 February 2014
Description:
Get a pseudo-random number.
(max)
max | The range of values (from 0 to this value minus one) that can be returned. |
Return Values:
A random number ranging from 0 to max-1.
new Float:RandomSpawn[][4] = { // Positions, (X, Y, Z and Facing Angle) {-2796.9854, 1224.8180, 20.5429, 192.0335}, {-2454.2170, 503.8759, 30.0790, 267.2932}, {-2669.7322, -6.0874, 6.1328, 89.8853} };
public OnPlayerSpawn(playerid) { new rand = random(sizeof(RandomSpawn)); // SetPlayerPos to the random spawn data SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]); // SetPlayerFacingAngle to the random facing angle data SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]); return 1; }