How to make only logged player saving stats.. :) -
TiXz0r - 09.12.2014
i have stock
Код:
SavePlayer(playerid)
and
Код:
stock IsPlayerLoggedIn(playerid) {
if(IsPlayerConnected(playerid))
{
if(IsLogged[playerid] != false)
{
return 1;
} else return 0;
} else return 0;
}
cant this two work on onplayerdisconnect like:
Код:
if(IsLogged[playerid] == true) {
SavePlayer(playerid)
}
i want make system for only logged players,server saving stats. im make one script,but not working.. :/
Re: How to make only logged player saving stats.. :) -
BlackWolf120 - 09.12.2014
-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.
Re: How to make only logged player saving stats.. :) -
TiXz0r - 09.12.2014
Quote:
Originally Posted by BlackWolf120
-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.
|
like this?
Код:
if(IsLogged[playerid] == true) {
SavePlayer(playerid);
SaveRegisterPlayer(playerid);
}
oh god, i have timer ongamemodeint:
SetTimer("SavePlayer",900000,1);, can move to when player login?
Re: How to make only logged player saving stats.. :) -
BlackWolf120 - 09.12.2014
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.
Re: How to make only logged player saving stats.. :) -
Abagail - 09.12.2014
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;
}
}
Re: How to make only logged player saving stats.. :) -
TiXz0r - 09.12.2014
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;
}
Re: How to make only logged player saving stats.. :) -
Beckett - 09.12.2014
It's not really a big deal mate.
If the player is logged in. (true/1)
Then execute your saving code.
--
Quote:
Originally Posted by Abagail
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;
}
}
|
pawn Код:
foreach(new i : Player)
{
if(IsLoggedIn(i))
{
SavePlayer(i);
continue;
}
}
Re: How to make only logged player saving stats.. :) -
Abagail - 09.12.2014
Quote:
Originally Posted by DaniceMcHarley
It's not really a big deal mate.
If the player is logged in. (true/1)
Then execute your saving code.
--
pawn Код:
foreach(new i : Player) { if(IsLoggedIn(i)) { SavePlayer(i); continue; } }
|
As far as I know they work interchangably. I use it with the iterator first, it's always worked for me like that anyways.
Re: How to make only logged player saving stats.. :) -
Beckett - 09.12.2014
Quote:
Originally Posted by Abagail
As far as I know they work interchangably. I use it with the iterator first, it's always worked for me like that anyways.
|
Yes, right. But that wasn't my point you had this in a loop which is in invalid parameter.
Supposed to be 'i'.
Re: How to make only logged player saving stats.. :) -
Abagail - 09.12.2014
Quote:
Originally Posted by DaniceMcHarley
Yes, right. But that wasn't my point you had this in a loop which is in invalid parameter.
|
Oh well... I tried, lol. I really need to start paying more attention to these things.