Y_INI - Save on change
#6

Quote:
Originally Posted by ShadowMortar
Посмотреть сообщение
Try with this:

Код:
new AccTimer; // Defines the timer

forward SaveAccounts();
public SaveAccounts()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
	    new INI:File = INI_Open(UserPath(i));
	    INI_SetTag(File,"data");

	    INI_WriteInt(File,"Admin Level", PlayerInfo[i][pAdmin]);
	    INI_WriteInt(File,"Faction Director", PlayerInfo[i][pFacDirector]);
	    INI_WriteInt(File,"Faction", PlayerInfo[i][pFaction]);
	    INI_WriteInt(File,"Faction Rank", PlayerInfo[i][pFacRanks]);

	    INI_Close(File);
	}
    return 1;
}
Put under OnGameModeInit:
AccTimer = SetTimer("SaveAccounts", 60000 *5, true); // Saves all accounts every 5 minutes

Put under OnGameModeExit:
KillTimer(AccTimer);

Under OnPlayerDisconnect:
SaveAccounts();

For safe /gmx command:
new RestartTime = 10;
CMD:gmx(playerid)
{
    if(PlayerInfo[playerid][pAdmin] < 3)
	{
		SendClientMessage(playerid, -1, "You are not authorized to use that command!");
	}
	else if(PlayerInfo[playerid][pAdmin] >= 3)
	{
	    SaveAccounts();
		SetTimer("ServerRestartTime",10000 ,false);
	}
	return 1;
}

forward ServerRestartTime(playerid);
public ServerRestartTime(playerid)
{
	RestartTime--;
	if(RestartTime == 0)
	{
	    RestartTime = 10;
	    SendRconCommand("gmx");
	    return 1;
	}
	return 1;
}
Instead of saving it every 5 minutes, how can I make it so it'll update on change? Like, I'd like it so if I'm in faction X, and I change it to faction y the server will save the player data.

Edit: I already made a gmx with a timer.
Reply


Messages In This Thread
Y_INI - Save on change - by Mo123 - 02.12.2018, 17:23
Re: Y_INI - Save on change - by oMa37 - 02.12.2018, 18:47
Re: Y_INI - Save on change - by Mo123 - 02.12.2018, 18:50
Re: Y_INI - Save on change - by oMa37 - 02.12.2018, 18:53
Re: Y_INI - Save on change - by ShadowMortar - 02.12.2018, 19:45
Re: Y_INI - Save on change - by Mo123 - 02.12.2018, 20:31

Forum Jump:


Users browsing this thread: 1 Guest(s)