SA-MP Forums Archive
irccmd:restart saving player stats Y_INI - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: irccmd:restart saving player stats Y_INI (/showthread.php?tid=389479)



irccmd:restart saving player stats Y_INI - _Khaled_ - 02.11.2012

OnPlayerDisconnect, it saves score, wantedlevel everything
PHP код:
//Public OnPlayerDisconnect.
public OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"Player's Data");
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    
INI_WriteInt(File,"WantedLevel",GetPlayerWantedLevel(playerid));
    
INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    
INI_WriteInt(File,"Army",PlayerInfo[playerid][pArmy]);
    
INI_WriteInt(File,"BankAccount",PlayerInfo[playerid][pBankAccount]);
    
INI_WriteInt(File,"Datasaved",PlayerInfo[playerid][pAccountdata]);
    
INI_WriteInt(File,"Arrests",PlayerInfo[playerid][pArrests]);
    
INI_WriteInt(File,"Robberies",PlayerInfo[playerid][pRobberies]);
    
INI_WriteInt(File,"Hits",PlayerInfo[playerid][pHits]);
    
INI_WriteInt(File,"Tazers",PlayerInfo[playerid][pTazers]);
    
INI_WriteInt(File,"Heals",PlayerInfo[playerid][pHeals]);
    
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_WriteInt(File,"AntiBanned",PlayerInfo[playerid][pABanned]);
    
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    
INI_WriteInt(File,"Jail",PlayerInfo[playerid][pJail]);
    
INI_Close(File);
    
//Other stuff

but !restart
PHP код:

//Command RESTART.
IRCCMD:restart(botidchannel[], user[], host[], params[])
{
    new 
string[256];
    new 
msg[128];
    new 
playerid;
    
format(stringsizeof(string), "***[SERVER RESTART] Server restarting, all players data have been saved."user);
    
SendClientMessageToAll(0x0000FFFFstring);
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"Player's Data");
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    
INI_WriteInt(File,"WantedLevel",GetPlayerWantedLevel(playerid));
    
INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    
INI_WriteInt(File,"Army",PlayerInfo[playerid][pArmy]);
    
INI_WriteInt(File,"BankAccount",PlayerInfo[playerid][pBankAccount]);
    
INI_WriteInt(File,"Datasaved",PlayerInfo[playerid][pAccountdata]);
    
INI_WriteInt(File,"Arrests",PlayerInfo[playerid][pArrests]);
    
INI_WriteInt(File,"Robberies",PlayerInfo[playerid][pRobberies]);
    
INI_WriteInt(File,"Hits",PlayerInfo[playerid][pHits]);
    
INI_WriteInt(File,"Tazers",PlayerInfo[playerid][pTazers]);
    
INI_WriteInt(File,"Heals",PlayerInfo[playerid][pHeals]);
    
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_WriteInt(File,"AntiBanned",PlayerInfo[playerid][pABanned]);
    
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    
INI_WriteInt(File,"Jail",PlayerInfo[playerid][pJail]);
    
INI_Close(File);
    
    
format(msgsizeof(msg), "02[SERVER RESTART] Server restarting, all players data have been saved.");
    
IRC_GroupSay(groupIDIRC_CHANNELmsg);
    
IRC_GroupSay(groupIDADMIN_CHANNELmsg);
    if(!
IRC_IsAdmin(botidchanneluser)) return 0;
    
SendRconCommand("gmx");
    return 
1;

and when I remove new playerid; errors

someone?


Re: irccmd:restart saving player stats Y_INI - Glint - 02.11.2012

There are no "playerid" parameters in IRC commands.


Re: irccmd:restart saving player stats Y_INI - ricardo178 - 02.11.2012

Also if you send the GMX before saving, it wont save the player file.


Re: irccmd:restart saving player stats Y_INI - gtakillerIV - 02.11.2012

I don't know much about IRC but you can use a loop to loop through all of the players then save their stats.


Re: irccmd:restart saving player stats Y_INI - _Khaled_ - 03.11.2012

So, any idea how to save the stats..
and ALSO, it resets the player wantedlevel to 0
and score to 0