Je viens de faire un test sur mon script à tout faire.
Je créer 3 TextDraws à chaque fois qu'un joueur se connecte et je commence à les afficher au moment où il spawn.
Tout marche très bien pour moi avec 2 joueurs (je n'ai que 2 machines, je n'ai pas pu tester avec plus).
En "haut" du script :
new Text:Text1Seconde[MAX_PLAYERS];
new Text:Text2Seconde[MAX_PLAYERS];
new Text:Text3Seconde[MAX_PLAYERS];
new Compteur[MAX_PLAYERS] = -1;
forward UpdateTextDraws ();
public UpdateTextDraws ()
{
new string[61];
/* Boucle sur les joueurs */
for (new i=0 ; i<MAX_PLAYERS ; i++)
{
/* Si le joueur est connecté et que son compteur est lancé */
if (IsPlayerConnected (i) && Compteur[i] != -1)
{
/* Incrémentation du compteur pour le joueur */
Compteur[i]++;
/* Fabrication de la chaine */
for (new j=0 ; j<Compteur[i] ; j++)
{
string[j]='-';
}
string[Compteur[i]]=0;
/* Mise à jour des TextDraws */
TextDrawSetString (Text1Seconde[i], string);
if (Compteur[i]%2 == 0)
{
TextDrawSetString (Text2Seconde[i], string);
}
if (Compteur[i]%3 == 0)
{
TextDrawSetString (Text3Seconde[i], string);
}
if (Compteur[i] == 60)
{
Compteur[i] = 0;
}
}
}
}
Dans OnGameModeInit :
SetTimer ("UpdateTextDraws", 1000, true);
Dans OnPlayerConnect :
Text1Seconde[playerid] = TextDrawCreate (320.00, 370.00, " ");
TextDrawFont (Text1Seconde[playerid], 3);
TextDrawSetProportional (Text1Seconde[playerid], 2);
TextDrawAlignment (Text1Seconde[playerid], 2);
TextDrawSetOutline (Text1Seconde[playerid], 1);
TextDrawSetShadow (Text1Seconde[playerid], 0);
TextDrawColor (Text1Seconde[playerid], 0x00AA00FF);
TextDrawBackgroundColor (Text1Seconde[playerid], 0x005500FF);
TextDrawHideForPlayer (playerid, Text1Seconde[playerid]);
Text2Seconde[playerid] = TextDrawCreate (320.00, 380.00, " ");
TextDrawFont (Text2Seconde[playerid], 3);
TextDrawSetProportional (Text2Seconde[playerid], 2);
TextDrawAlignment (Text2Seconde[playerid], 2);
TextDrawSetOutline (Text2Seconde[playerid], 1);
TextDrawSetShadow (Text2Seconde[playerid], 0);
TextDrawColor (Text2Seconde[playerid], 0x00AA00FF);
TextDrawBackgroundColor (Text2Seconde[playerid], 0x005500FF);
TextDrawHideForPlayer (playerid, Text2Seconde[playerid]);
Text3Seconde[playerid] = TextDrawCreate (320.00, 390.00, " ");
TextDrawFont (Text3Seconde[playerid], 3);
TextDrawSetProportional (Text3Seconde[playerid], 2);
TextDrawAlignment (Text3Seconde[playerid], 2);
TextDrawSetOutline (Text3Seconde[playerid], 1);
TextDrawSetShadow (Text3Seconde[playerid], 0);
TextDrawColor (Text3Seconde[playerid], 0x00AA00FF);
TextDrawBackgroundColor (Text3Seconde[playerid], 0x005500FF);
TextDrawHideForPlayer (playerid, Text3Seconde[playerid]);
Dans OnPlayerSpawn :
/* On demarre l'affichage des TextDraws */
Compteur[playerid]=0;
TextDrawShowForPlayer (playerid, Text1Seconde[playerid]);
TextDrawShowForPlayer (playerid, Text2Seconde[playerid]);
TextDrawShowForPlayer (playerid, Text3Seconde[playerid]);
Dans OnPlayerDisconnect :
/* Destructions des TextDraws */
Compteur[playerid] = -1;
TextDrawDestroy (Text1Seconde[playerid]);
TextDrawDestroy (Text2Seconde[playerid]);
TextDrawDestroy (Text3Seconde[playerid]);
++
Syg