Random FR
From SA-MP Wiki
(Difference between revisions)
Revision as of 04:02, 18 December 2013 Connor Mead (Talk | contribs) ← Previous diff |
Revision as of 04:06, 18 December 2013 Connor Mead (Talk | contribs) Next diff → |
||
Line 13: | Line 13: | ||
new Float:RandomSpawn[][4] = | new Float:RandomSpawn[][4] = | ||
{ | { | ||
- | // Positions, (X, Y, Z and Facing Angle) | + | //Position X , Y , Z , Facing Angle |
{-2796.9854, 1224.8180, 20.5429, 192.0335}, | {-2796.9854, 1224.8180, 20.5429, 192.0335}, | ||
{-2454.2170, 503.8759, 30.0790, 267.2932}, | {-2454.2170, 503.8759, 30.0790, 267.2932}, | ||
Line 25: | Line 25: | ||
new rand = random(sizeof(RandomSpawn)); | new rand = random(sizeof(RandomSpawn)); | ||
- | // SetPlayerPos to the random spawn data | ||
SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]); | SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]); | ||
+ | //Si rand est égal à 0, alors ça reviendra à écrire: | ||
+ | //SetPlayerPos(playerid, -2796.9854, 1224.8180, 20.5429); | ||
- | // SetPlayerFacingAngle to the random facing angle data | ||
SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]); | SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]); | ||
return 1; | return 1; |
Revision as of 04:06, 18 December 2013
Page d'Accueil | Les Fonctions | Les Callbacks | Les bases du Scripting | Plugins de Serveur | Tutoriaux
Ne prenez pas en compte les FR dans les noms
Description:
Récupère un nombre au hasard via un Générateur de nombres pseudo-aléatoires
(max)
max | Le chiffre maximum possible (part de 0). Peut être retourné. |
Retourne:
Un chiffre aléatoire entre 0 et (max-1). (Si max vaut 2, alors le chiffre sera 0 ou 1)
new Float:RandomSpawn[][4] = { //Position X , Y , Z , 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(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]); //Si rand est égal à 0, alors ça reviendra à écrire: //SetPlayerPos(playerid, -2796.9854, 1224.8180, 20.5429); SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]); return 1; }