Is There a way so i can execute my db save ongamemodeexit
#1

as title says i want to execute the DB save function ongamemodeexit so if the server is closed no player data loses

i tried this but it does not work

pawn Код:
public OnGameModeExit()
{
    foreach (new i : Player)
    {  
        if(pInfo[i][prSTEP] > 0)
        {
            getPlayerStats(i);
            save_cDATA(i);
        }
    }
    UnINIT_DB();   
    return 1;
}
Reply
#2

any help, i am really stuck with this and need your help ++REP
Reply
#3

make a cmd such as /restart and save stats you want, then set timer for like 2 seconds and after 2 seconds send rcon cmd for restart.
Reply
#4

WHAT ?!
Reply
#5

Any Help ?
Reply
#6

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/restart", cmdtext, true, 8) == 0)
	{
		SetTimer("ServerRestart", 2000, false);
	    foreach (new i : Player)
	    {
	        if(pInfo[i][prSTEP] > 0)
	        {
	            getPlayerStats(i);
	            save_cDATA(i);
	        }
	    }
	    UnINIT_DB();
		return 1;
	}
	return 0;
}

forward ServerRestart();
public ServerRestart()
{
    SendRconCommand("gmx");
    return 1;
}
Reply
#7

what if gamemode crashed ? or an unexpected problem forced it to exit
Reply
#8

Then set a timer for 10 seconds which saves all player data under OnGameModeInit().
Reply
#9

how save data of non existing players !?

OnGameModeInit() there is no players connected and the data already lost cuz the server has exited
Reply
#10

It will just start a timer and save the players which connect to the server only.
Try it out and you'll see.

Код:
public OnGameModeInit()
{
    SetTimer("SavePlayerData", 10000, true);
	return 1;
}

forward SavePlayerData();
public SavePlayerData()
{
	foreach (new i : Player)
	{
		if(pInfo[i][prSTEP] > 0)
 		{
  			getPlayerStats(i);
         	save_cDATA(i);
     	}
	}
	UnINIT_DB();
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)