09.01.2017, 17:20
Hello!
I have a Save Player function in my gamemode but sometimes I have to restart the server. If there are players online playing at the time im restarting the server, they are saved in coord 0,0,0. I suppose that the OnPlayerDisconnect is not called when this happens or something (because I have the function in OnPlayerDisconnect) or the function calls after the player disconnect because it sets the coords X,Y,Z to 0.
What should I do, a timer for save the players coords every x seconds or there is any way to solve this? Here are the code:
I have a Save Player function in my gamemode but sometimes I have to restart the server. If there are players online playing at the time im restarting the server, they are saved in coord 0,0,0. I suppose that the OnPlayerDisconnect is not called when this happens or something (because I have the function in OnPlayerDisconnect) or the function calls after the player disconnect because it sets the coords X,Y,Z to 0.
What should I do, a timer for save the players coords every x seconds or there is any way to solve this? Here are the code:
Код:
public OnPlayerDisconnect(playerid, reason)
{
if (gLogged[playerid] == 1)
{
if (PlayerInfo[playerid][pPrision] <= 0)
{
SavePlayer(playerid);
ResetPlayerVarsGM(playerid);
}
}
return 1;
}
public SavePlayer(playerid)
{
new Float:jX, Float:jY, Float:jZ, Float:hp, Float:armour, dmoney, playerskin;
GetPlayerPos(playerid, jX, jY, jZ);
GetPlayerHealth(playerid, hp);
GetPlayerArmour(playerid, armour);
dmoney= GetPlayerCash(playerid);
playerskin = GetPlayerSkin(playerid);
PlayerInfo[playerid][pSkin] = playerskin;
Update(playerid, PlayerInfo[playerid][pSkin]);
PlayerInfo[playerid][pCash] = dmoney;
Update(playerid, pCashu);
PlayerInfo[playerid][pX] = jX;
Update(playerid, pXu);
PlayerInfo[playerid][pY] = jY;
Update(playerid, pYu);
PlayerInfo[playerid][pZ] = jZ;
Update(playerid, pZu);
PlayerInfo[playerid][pVida] = hp;
Update(playerid, pVidau);
PlayerInfo[playerid][pArmadura] = armour;
Update(playerid, pArmadurau);
PlayerInfo[playerid][pInterior] = GetPlayerInterior(playerid);
Update(playerid, pInterioru);
PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
Update(playerid, pVWu);
AccountInfo[playerid][aOnline] = 0;
UpdatePlayerAccount(playerid, aOnlineu, AccountInfo[playerid][aName]);
return 0;
}


