Posts: 761
Threads: 124
Joined: Nov 2010
Reputation:
0
-Set IsLogged[playerid] to false under OnPlayerConnect
-Set IsLogged[playerid] to true if the player has passed the login phase successfully.
else set it to false.
-Under OnPlayerDisconnect or whenever SavePlayer(playerid) shall be used, check if IsLogged[playerid] is set to true before executing this function on that specific player.
regards, wolf.
Posts: 761
Threads: 124
Joined: Nov 2010
Reputation:
0
basically yes, but as i dont know what the 2 functions are supposed to do for sure i cant tell you, its up to you...
Also, try to avoid timers for "huge" processes like player savings.
I assume that you loop through all connected players once every 15 minutes to save their data AT THE SAME time.
I would suggest to use gettime(); (returns the current timestamp) e.g. under OnPlayerSpawn and check there if 15 minutes have already passed since the last saving.
In that manner you would avoid a timer and also what is more important avoiding the circumstance that the data of all players is saved at the "exact" same moment.
Posts: 3,133
Threads: 71
Joined: Dec 2013
Reputation:
0
You can use this in your save function.
if(IsPlayerLoggedIn(playerid))
{
SavePlayer(playerid);
}
or in a loop for example using foreach and a IsPlayerLoggedIn function:
foreach(Player, i)
{
if(IsLoggedIn(i))
{
SavePlayer(playerid);
continue;
}
}
Posts: 178
Threads: 62
Joined: Nov 2013
Reputation:
0
Maybe this better?
stock SavePlayer(playerid)
{
if(IsLogged[playerid] == true){
{
new Float:health, Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
//
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
INI_WriteInt(File,"Level",GetPlayerScore(playerid) );
//im delete other becouse is to long..
INI_Close(File);
}
}
return 1;
}