How to make spawn colors FR
From SA-MP Wiki
(Difference between revisions)
Revision as of 20:38, 5 January 2013 Connor Mead (Talk | contribs) (a) ← Previous diff |
Revision as of 20:40, 5 January 2013 Connor Mead (Talk | contribs) Next diff → |
||
Line 45: | Line 45: | ||
return 1; | return 1; | ||
}</pawn> | }</pawn> | ||
- | <h3>2èmee Méthode</h3> | + | <h3>2ème Méthode</h3> |
<pawn> | <pawn> | ||
public OnPlayerSpawn(playerid) | public OnPlayerSpawn(playerid) |
Revision as of 20:40, 5 January 2013
Contents |
Saving which class the player selects
To set the color to a certain one (e.g. a team-color), we need to save which class has been selected by the player. We can achieve this by a new global variable, which is just for the purpose of saving the class that is selected on the spawn-selection-screen.
new pClass[MAX_PLAYERS]; // Stores the player's class
Ajout de deux classes
Pour ajouter une couleur particulière pour une certaine classe
public OnGameModeInit() { AddPlayerClass(106,2512.8611,-1673.2799,13.5104,87.7485,0,0,0,0,0,0); // Classe 0 AddPlayerClass(107,2508.1372,-1656.6781,13.5938,129.4222,0,0,0,0,0,0); // Classe 1 return 1; }
Detection de la class choisie
When we want to set the color upon the color later, we need to find out what class has been selected.
public OnPlayerRequestClass(playerid, classid) { pClass[playerid] = classid; return 1; }
Changement de la couleur du joueur a l'apparition
Il y à deux méthodes différentes pour verifier si pClass est égal à 0 où 1.
1ère Méthode
public OnPlayerSpawn(playerid) { switch(pClass[playerid]) { case 0: { SetPlayerColor(playerid, 0xFF6600AA); // Orange } case 1: { SetPlayerColor(playerid, 0xFF0000AA); // Rouge } } return 1; }
2ème Méthode
public OnPlayerSpawn(playerid) { if(pClass[playerid]==0) { SetPlayerColor(playerid, 0xFF6600AA); //Orange } if(pClass[playerid]==1) { SetPlayerColor(playerid, 0xFF0000AA); //Orange } return 1; }
Voilà, maintenant quand le joueur apparaîtra, il sera orange si il a choisi la classe 0, et rouge si il a choisi la classe 1.