Por que a textdraw ta sendo criada na callback do OnPlayerConnect? cada vez que o jogador conectava no servidor setava um timer em todo mundo e criava a textdraw pra todo mundo ? seria melhor assim(AO MEU VER)
PHP код:
#define Conta "Contas/%s.ini"
new MinutosP[MAX_PLAYERS],
SegundosP[MAX_PLAYERS],
PlayerText:Textdraw0[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
new file[40], NomePl[MAX_PLAYER_NAME];
GetPlayerName(playerid, NomePl, sizeof NomePl);
format(file, sizeof file, Conta, NomePl);
if(DOF2_FileExists(file))
{
MinutosP[playerid] = DOF2_GetInt(file, "Minutos");
SegundosP[playerid] = DOF2_GetInt(file, "Segundos");
}
Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 499.000000, 123.000000, "");
PlayerTextDrawBackgroundColor(playerid, Textdraw0[playerid], 255);
PlayerTextDrawFont(playerid, Textdraw0[playerid], 1);
PlayerTextDrawLetterSize(playerid, Textdraw0[playerid], 0.450000, 0.899999);
PlayerTextDrawColor(playerid, Textdraw0[playerid], -16776961);
PlayerTextDrawSetOutline(playerid, Textdraw0[playerid], 0);
PlayerTextDrawSetProportional(playerid, Textdraw0[playerid], 0);
PlayerTextDrawSetShadow(playerid, Textdraw0[playerid], 1);
PlayerTextDrawSetSelectable(playerid, Textdraw0[playerid], 0);
return 1;
}
/*
* @OBS - Vocк precisa adicionar o codigo abaixo na funзгo onde o player faz o login
*/
forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
PlayerTextDrawShow(playerid, textdraw0[playerid]);
}
public OnPlayerDisconnect(playerid, reason)
{
new file[40], NomePl[MAX_PLAYER_NAME];
GetPlayerName(playerid, NomePl, sizeof NomePl);
format(file, sizeof file, Conta, NomePl);
if(DOF2_FileExists(file))
{
DOF2_SetInt(Conta, "Minutos", MinutosP[playerid]);
DOF2_SetInt(Conta, "Segundos", SegundosP[playerid]);
}
return 1;
}
public OnGameModeInit()
{
SetTimer("RelogioUP", 1000, true);
}
forward RelogioUP();
public RelogioUP()
{
foreach(new playerid: Player)
{
if(MinutosP[playerid] <= 0 && SegundosP[playerid] <= 0)
{
MinutosP[playerid] = 60;
SegundosP[playerid] = 0;
Payday(playerid); // << Taca o Payday
}
else
{
if(SegundosP[playerid] <= 0)
{
MinutosP[playerid]--;
SegundosP[playerid] = 60;
}
else
SegundosP[playerid]--;
}
new text[30];
format(text, sizeof text, "Payday:~w~%02d:%02d", MinutosP[playerid], SegundosP[playerid]);
PlayerTextDrawSetString(playerid, textdraw0[playerid], text);
//Se colocar pra aparecer a textdraw aqui vai aparecer na tela de login tambйm, mas se quiser:
PlayerTextDrawShow(playerid, textdraw0[playerid]);
}
return true;
}