UPRelogio[playerid] = SetTimerEx("RelogioUP", 1000,true,"i",playerid);
PlayerStatus[playerid][20] = CreatePlayerTextDraw(playerid, 598.600097, 302.655731, "");
PlayerTextDrawLetterSize(playerid, PlayerStatus[playerid][20], 0.331000, 1.130000);
PlayerTextDrawAlignment(playerid, PlayerStatus[playerid][20], 2);
PlayerTextDrawColor(playerid, PlayerStatus[playerid][20], -1);
PlayerTextDrawSetShadow(playerid, PlayerStatus[playerid][20], 0);
PlayerTextDrawSetOutline(playerid, PlayerStatus[playerid][20], -1);
PlayerTextDrawBackgroundColor(playerid, PlayerStatus[playerid][20], 255);
PlayerTextDrawFont(playerid, PlayerStatus[playerid][20], 3);
PlayerTextDrawSetProportional(playerid, PlayerStatus[playerid][20], 1);
PlayerTextDrawSetShadow(playerid, PlayerStatus[playerid][20], 0);
forward UpGeral();
public UpGeral()
{
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i))
{
//
}
}
SetTimer("UpGeral", 1000, false);
}
public OnPlayerConnect(playerid)
{
// Coloque esse cуdigo na callback onde autentica a senha do usuбrio, para exibir o 'Relуgio UP' quando inserir a senha.
UPRelogio[playerid] = SetTimerEx("RelogioUP", 1000,true,"i",playerid);
PlayerStatus[playerid][20] = CreatePlayerTextDraw(playerid, 598.600097, 302.655731, "");
PlayerTextDrawLetterSize(playerid, PlayerStatus[playerid][20], 0.331000, 1.130000);
PlayerTextDrawAlignment(playerid, PlayerStatus[playerid][20], 2);
PlayerTextDrawColor(playerid, PlayerStatus[playerid][20], -1);
PlayerTextDrawSetShadow(playerid, PlayerStatus[playerid][20], 0);
PlayerTextDrawSetOutline(playerid, PlayerStatus[playerid][20], -1);
PlayerTextDrawBackgroundColor(playerid, PlayerStatus[playerid][20], 255);
PlayerTextDrawFont(playerid, PlayerStatus[playerid][20], 3);
PlayerTextDrawSetProportional(playerid, PlayerStatus[playerid][20], 1);
PlayerTextDrawSetShadow(playerid, PlayerStatus[playerid][20], 0);
return 1;
}
public OnPlayerDisconnect(playerid)
{
KillTimer(UPRelogio[playerid]);
return 1;
}
Recomendo utilizar Timer Global para todos os players nesse caso.
Crie um timer com repetiзгo (false) e coloque o mesmo timer dentro do timer. Assim й mais otimizado Exemplo: PHP Code:
|
PHP Code:
|
Cara, vocк tem que iniciar o temporizador quando o player logar no servidor e interromper o temporizador quando o usuбrio desconectar. Desta forma estб correta. Se estiver dando lag, й outra cousa que estб interferindo nesse sistema; Vai de vocк analisar sistema por sistema identificar a falha ...
|
Se eu usar um time para todos, quando eu bloquear o time de um nгo bloquearia de todos tbm ?
Jб coloquei isso, mas nгo adianta. |
public OnGameModeInit()
{
SetTimer("UpGeral", 1000, false);
return 1;
}
forward UpGeral();
public UpGeral()
{
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][SegundoUP] > 0 && PlayerInfo[i][Preso] == 0)
{
pInfo[i][SegundoUP] --;
}
if(PlayerInfo[i][SegundoUP] == 0 && PlayerInfo[i][MinutosUP] >= 1 && PlayerInfo[i][Preso] == 0)
{
pInfo[i][SegundoUP] = 59;
pInfo[i][MinutosUP] --;
}
if(PlayerInfo[i][MinutosUP] == 0 && PlayerInfo[i][SegundosUP] == 0)
{
pInfo[i][SegundoUP] = 59;
pInfo[i][MinutosUP] = 9;
UPLevel(i);
//Upou
}
}
}
SetTimer("UpGeral", 1000, false);
}
forward RelogioUP(playerid);
public RelogioUP(playerid)
{
if(pSegUP[playerid] == 0 && pMinUP[playerid] == 0)
{
if(PlayerInfo[playerid][Logado] == true)
{
if(PlayerInfo[playerid][Afk] == false)
{
//dini_IntSet(file, "Tempo", dini_Int(file, "Tempo")+1);
if(PlayerInfo[playerid][Exp] == 5)
{
MessageFormat(playerid, 0x75EA00AA, "| UP | Vocк ganhou +1 de Experiкncia ( %d/5 )", PlayerInfo[playerid][Exp]);
PlayerInfo[playerid][Exp]=0;
PlayerInfo[playerid][Level]++;
MessageFormat(playerid, 0x75EA00AA, "| UP | Vocк juntou 5 de Experiкncia e ganhou +1 level ( %d ) ",PlayerInfo[playerid][Level]);
PlayerPlaySound(playerid, 1057, 0, 0, 0);
} else {
PlayerInfo[playerid][Exp]++;
PlayerPlaySound(playerid, 1057, 0, 0, 0);
GameTextForPlayer(playerid, "~w~UP!", 3000, 6);
MessageFormat(playerid, 0x75EA00AA, "| UP | Vocк ganhou +1 de Experiкncia ( %d/5 )", PlayerInfo[playerid][Exp]);
//dini_IntSet(file, "Tempo",0);
}
}
}
}
if(pSegUP[playerid] == -1)
{
if(pMinUP[playerid] == 0)
pMinUP[playerid]=10;
pSegUP[playerid]=59;
pMinUP[playerid]--;
}
format(String, sizeof(String), "~w~+~b~UP: ~w~%02d:%02d", pMinUP[playerid],pSegUP[playerid]);
PlayerTextDrawSetString(playerid, PlayerStatus[playerid][20], String);
pSegUP[playerid]--;
return 1;
}
Mano, tu tem que fazer o q o cara ali falou, salvar o tempo quando o cara deslogar e quando ele logar pegar essa info e mostrar pra ele. Simples, nгo tem mistйrio
|
mysql_format(IDConexao, Query, sizeof(Query), "SELECT * FROM Contas WHERE Nome='%s'", pPlayerInfo[playerid][pNome]);
mysql_tquery(IDConexao, Query, "LoadAccounts", "i", pPlayerInfo[playerid][pNome]);
LoadAccounts(playerid);
mysql_format(IDConexao, Query, sizeof(Query), "SELECT * FROM Contas WHERE Nome='%s'", pPlayerInfo[playerid][pNome]);
mysql_tquery(IDConexao, Query, "LoadAccounts", "i", playerid);