SA-MP Forums Archive
Is There a way so i can execute my db save ongamemodeexit - 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: Is There a way so i can execute my db save ongamemodeexit (/showthread.php?tid=370387)



Is There a way so i can execute my db save ongamemodeexit - Healian - 19.08.2012

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;
}



Re: Is There a way so i can execute my db save ongamemodeexit - Healian - 19.08.2012

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


Re: Is There a way so i can execute my db save ongamemodeexit - ikey07 - 19.08.2012

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.


Re: Is There a way so i can execute my db save ongamemodeexit - Healian - 19.08.2012

WHAT ?!


Re: Is There a way so i can execute my db save ongamemodeexit - Healian - 19.08.2012

Any Help ?


Re: Is There a way so i can execute my db save ongamemodeexit - Shetch - 19.08.2012

Код:
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;
}



Re: Is There a way so i can execute my db save ongamemodeexit - Healian - 20.08.2012

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


Re: Is There a way so i can execute my db save ongamemodeexit - Shetch - 20.08.2012

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


Re: Is There a way so i can execute my db save ongamemodeexit - Healian - 20.08.2012

how save data of non existing players !?

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


Re: Is There a way so i can execute my db save ongamemodeexit - Shetch - 20.08.2012

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;
}