[Ajuda] Sistema de Salvamento
#1

Meu Sistema de Salvamento Tem Hora Que Salva e Tem Hora Que Nao Salvar Vou Postar Ele Correto Aki !
PHP код:
//----------[TOP DA GM]--------//
enum Info
{
    
Matou,
    
Morreu,
    
Score,
};
new 
pInfo[MAX_PLAYERS][Info];
//----------[OnGameModeInit]--------//
    
SetTimer("info", 1000, 1);
//----------[OnPlayerConnect]-----//
AS TEXT '-' 
//----------[OnPlayerDeath]--------//
    
pInfo[killerid][Matou]++;
    
pInfo[playerid][Morreu]++;
//--------[FINAL DA GM PARA MOSTRAR]-------//
forward info(playerid);
public 
info(playerid)
{
    new 
STR[128], str2[128], str3[128], str4[128], str5[128];
    
format(STR, sizeof(STR), "~b~Matou:~w~ %d", pInfo[playerid][Matou]);
    
PlayerTextDrawSetString(playerid, INFO[2][playerid], STR);
    
format(str3, sizeof(str3), "~b~Morreu:~w~ %d", pInfo[playerid][Morreu]);
    
PlayerTextDrawSetString(playerid, INFO[3][playerid], str3);
    
format(str2, sizeof(str2), "~b~Score:~w~ %d",GetPlayerScore(playerid));
    
PlayerTextDrawSetString(playerid, INFO[5][playerid], str2);
    
format(str4, sizeof(str4), "~b~Nick:~w~ %s",PlayerName(playerid));
    
PlayerTextDrawSetString(playerid, INFO[6][playerid], str4);
    
format(str5, sizeof(str5), "Seje Bem Vindo Ao Servidor ~b~%s ~w~Para Algumas Informaзoes Use /regras & /comandos",PlayerName(playerid));
    
PlayerTextDrawSetString(playerid, Tela_LoginNome[playerid], str5);
    return 
1;
}
//-----------------[Salvando & Carregando]--------------------//
stock SalvarPlayer(playerid)
{
    
GetPlayerName(playerid, Nome, sizeof(Nome));
    
format(String, sizeof(String), CONTAS, Nome);
    
DOF2::SetInt(String,"Dinheiro", GetPlayerMoney(playerid));
    
Skin[playerid] = GetPlayerSkin(playerid);
    
DOF2::SetInt(String,"Skin", Skin[playerid]);
    
DOF2::SetInt(String,"Logou", Logou[playerid]);
    
DOF2_SetInt(String, "Morreu", pInfo[playerid][Morreu]);
    
DOF2_SetInt(String, "Matou", pInfo[playerid][Matou]);
    
DOF2_SetInt(String,"Score", GetPlayerScore(playerid));
    
getdate(Ano[playerid], Mes[playerid], Dia[playerid]);
    
gettime(Hora[playerid], Minuto[playerid]);
    
DOF2::SetInt(String, "Minuto",  Minuto[playerid]);
    
DOF2::SetInt(String, "Hora", Hora[playerid]);
    
DOF2::SetInt(String, "Dia", Dia[playerid]);
    
DOF2::SetInt(String, "Mкs", Mes[playerid]);
    
DOF2::SetInt(String, "Ano", Ano[playerid]);
    
DOF2::SaveFile();
    
Desaparece(playerid);
    
SetupPlayerForClassSelection(playerid);
    return 
true;
}
stock CarregarPlayer(playerid)
{
    
GetPlayerName(playerid, Nome, sizeof(Nome));
    
format(String, sizeof(String), CONTAS, Nome);
    
GivePlayerMoney(playerid, DOF2::GetInt(String,"Dinheiro"));
    
Skin[playerid] = DOF2::GetInt(String, "Skin");
    
SetPlayerSkin(playerid, Skin[playerid]);
    
SetPlayerScore(playerid, DOF2_GetInt(String,"Score"));
    
pInfo[playerid][Matou] = DOF2_GetInt(String, "Matou");
    
pInfo[playerid][Morreu] = DOF2_GetInt(String, "Morreu");
    
Logou[playerid] = DOF2::GetInt(String, "Logou");
    
Minuto[playerid] = DOF2::GetInt(String, "Minuto");
    
Hora[playerid] = DOF2::GetInt(String, "Hora");
    
Dia[playerid] = DOF2::GetInt(String, "Dia");
    
Mes[playerid] = DOF2::GetInt(String, "Mкs");
    
Ano[playerid] = DOF2::GetInt(String, "Ano");
    
DOF2::SaveFile();
    
Desaparece(playerid);
    
SetupPlayerForClassSelection(playerid);
    return 
true;
} 
Reply
#2

Antigamente quando eu usava DOF2 , se eu fecha-se o samp-server.exe , as vezes bugava e limpava as contas , tente fazer uma funзгo pra salvar todos que estгo online na hora que fechar o gamemode , ou adiciona um comando pra isso , e executa antes de fechar o samp-server ou dar stop no painel de controle do seu servidor...
Reply
#3

Faзa isso..

PHP код:
public OnGameModeExit()
{
    for(new 
i = 0; i < MAX_PLAYERS; i++) SalvarPlayer(i);
    
DOF2_Exit();
    return 
1;
} 
Reply
#4

Vlw Jimmy , Boa Ideia dark +REP para os 2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)