SA-MP Forums Archive
OnPlayerDisconnect - 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: OnPlayerDisconnect (/showthread.php?tid=521691)



OnPlayerDisconnect - Mauricee - 24.06.2014

Код:
public OnPlayerDisconnect(playerid,reason)
{
	new string[128];
	numplayers--;
	mysql_format(SQL, string,128,"UPDATE `users` SET `online`='0' WHERE `ID`='%d' LIMIT 1",PlayerData[playerid][online],PlayerData[playerid][ID]);
	mysql_tquery(SQL, string, "", "");
	if(PlayerData[playerid][SpectateP] != -1)
	{
		new id = PlayerData[playerid][SpectateP];
		PlayerData[id][WatchingTV] = 0;//
		PlayerData[id][Spectate] = -2;
		GameTextForPlayer(id, "~w~                Target~n~~r~                Left", 5000, 6);
		PlayerPlaySound(id, 1145, 0.0, 0.0, 0.0);
		PlayerData[playerid][SpectateP] = -1;
	}
	
	switch(reason)
    {
        case 0: format(string,sizeof string,"%s exited the game. (crash)", PlayerData[playerid][Name]);
        case 1: format(string,sizeof string,"%s exited the game. (quit)", PlayerData[playerid][Name]);
        case 2: format(string,sizeof string,"%s exited the game. (kicked/banned)", PlayerData[playerid][Name]);
    }
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    
	TextDrawDestroy(TextDrawSpec[playerid][1]);
	TextDrawDestroy(TextDrawSpec[playerid][2]);
	TextDrawDestroy(TextDrawSpec[playerid][3]);
	TextDrawDestroy(TextDrawSpec[playerid][4]);
    MysqlRaceCheck[playerid]++;
	
	return 1;
}
Why that query isn't executed sometimes?


Re: OnPlayerDisconnect - Faisal_khan - 24.06.2014

Show the MySQL log.


Re: OnPlayerDisconnect - Mauricee - 24.06.2014

Already checked that, MySQL log doesn't show any errors


Re: OnPlayerDisconnect - RajatPawar - 24.06.2014

pawn Код:
"UPDATE `users` SET `online`='0' WHERE `ID`='%d' LIMIT 1",PlayerData[playerid][online],PlayerData[playerid][ID]
You have only one specifier, while two values to fill it up. The correct query would be -

pawn Код:
"UPDATE `users` SET `online`= 0 WHERE `ID`= %d LIMIT 1", PlayerData[playerid][ID]



Re: OnPlayerDisconnect - Ciandlah - 24.06.2014

Well if its not showing an error in the Mysql Log then nothing is wrong - If anything is wrong within Mysql Saving / Loading it will say in the Mysql log


Also Use This
Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
pawn Код:
"UPDATE `users` SET `online`='0' WHERE `ID`='%d' LIMIT 1",PlayerData[playerid][online],PlayerData[playerid][ID]
You have only one specifier, while two values to fill it up. The correct query would be -

pawn Код:
"UPDATE `users` SET `online`= 0 WHERE `ID`= %d LIMIT 1", PlayerData[playerid][ID]



Re: OnPlayerDisconnect - Mauricee - 24.06.2014

Now, I use that, but nothing change..


Re: OnPlayerDisconnect - Ciandlah - 24.06.2014

Show us your Mysql Log then