Save all account in /gmx? - 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: Save all account in /gmx? (
/showthread.php?tid=530669)
Save all account in /gmx? -
alanhutch - 08.08.2014
Hi all..
I wanted to know how to save all .ini files of player accounts without needing the player connected.
How can I do that?..
Thanks
Re: Save all account in /gmx? -
alanhutch - 08.08.2014
HELP
Re: Save all account in /gmx? -
2KY - 08.08.2014
There's no reason to save files of players that aren't even connected and playing. Simply use a loop, open their file, save their variables, close it, and THEN restart the server. I use a 2 second timer after I save their files to actually send the rcon command to restart.
pawn Код:
CMD:gmx(playerid, params[])
{
new
plStr[64],
plName[MAX_PLAYER_NAME];
for(new i; i < MAX_PLAYERS; i ++)
{
if(pl_Logged[playerid] != 1) // change this to your logged in variable
return 0;
GetPlayerName(i, plName, MAX_PLAYER_NAME);
format(plStr, sizeof(plStr), "Accounts/%s.ini", plName);
new
INI: File = INI_Open(plStr);
INI_SetTag(File, "..."); // set file tag
INI_WriteInt(File, "....", ..); // set their variables
INI_Close(File); // close their file
}
SetTimer("RestartServ", 2000, false);
}
forward RestartServ();
public RestartServ()
{
SendRconCommand("gmx");
return 1;
}
This example is using YINI & YCMD.
Re: Save all account in /gmx? -
alanhutch - 08.08.2014
That's working, but one variable always restarts when I restart/start the server...
It's the name of a caracther in a characters system...
pawn Код:
//When it saves
strcpy(PlayerInfo[playerid][pNomePersonaggio1], inputtext, 64);
OnPlayerSave(playerid);
//OnPlayerConnect
PlayerInfo[playerid][pNomePersonaggio1] = PlayerInfo[playerid][pNomePersonaggio1];
PlayerInfo[playerid][pNomePersonaggio2] = PlayerInfo[playerid][pNomePersonaggio2];
PlayerInfo[playerid][pNomePersonaggio3] = PlayerInfo[playerid][pNomePersonaggio3];
//OnPlayerRegister
format(var, 32, "NomePersonaggio1=%s\n",PlayerInfo[playerid][pNomePersonaggio1]);fwrite(hFile, var);
//OnPlayerSave
format(var, 32, "NomePersonaggio1=%s\n",PlayerInfo[playerid][pNomePersonaggio1]);fwrite(hFile, var);
Why this variable restart everytime I restart the GM?
Thanks