public OnGameModeExit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SalvarPlayer(i);
}
}
DOF2_Exit();
return 1;
}
stock SalvarPlayer(playerid)
{
if(IsPlayerConnected(playerid))
{
new Float:x,Float:y,Float:z, Float:hp;
GetPlayerName(playerid,Nick,24);
format(pArquivo,39,"Contas\\%s.ini",Nick);
DOF2_SetInt(pArquivo,"Nivel",GetPlayerScore(playerid));
DOF2_SetInt(pArquivo,"Dinheiro_Mao",GetPlayerMoney(playerid));
DOF2_SetInt(pArquivo,"Skin",GetPlayerSkin(playerid));
DOF2_SetInt(pArquivo,"Admin_Level",playerinfo[playerid][pAdmin]);
GetPlayerPos(playerid,x,y,z);
DOF2_SetFloat(pArquivo,"posX",x);
DOF2_SetFloat(pArquivo,"posY",y);
DOF2_SetFloat(pArquivo,"posZ",z);
DOF2_SetFloat(pArquivo,"Vida",GetPlayerHealth(playerid,hp));
DOF2_SetInt(pArquivo,"PlayerInterior",GetPlayerInterior(playerid));
DOF2_SaveFile();
return 1;
}
return 1;
}
Chame a callback de salvamento em OnPlayerDisconnect.
E quando executar o GMX, faзa um timer de atй no mбximo 5 segundos para realizar os salvamentos com seguranзa. Se, por ventura, o console fechar inesperadamente/crashar, a callback OnGameModeExit nгo й chamada. Por isso, eu nгo aconselho a usar aн, pois nгo irб ser salvo o arquivo. O mais indicado й quando o jogador sair do servidor. |
Sim, isso consigo fazer. A preocupaзгo й com crashs. Esse loop na prбtica acabou nгo funcionando, ou estou enganado?
*OBS: quanto ao gmx, jб estou fazendo isso que vocк disse... me parece o mais prudente. |
Й como eu te falei, se o console for fechado, nгo irб funcionar.
Se vocк colocar em OnPlayerDisconnect, nгo hб com o que se preocupar! |
Agora entendi melhor.
Significa que entгo no OnGameModeExit, aquela loop й inъtil?! |