SA-MP Forums Archive
Kick already disconnected player - 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: Kick already disconnected player (/showthread.php?tid=610131)



Kick already disconnected player - ScIrUsna - 20.06.2016

Hi,

Can be issue if player out from server onplayerdisconnect callback get called and i at same moment call kick, it's possible that 2 onplayerdisconnect can call?


Re: Kick already disconnected player - Matz - 20.06.2016

I've seen 2 admins banned one person but the thing you mentioned is unlikely to be happen


Re: Kick already disconnected player - XVlaDX - 20.06.2016

Quote:
Originally Posted by Matz
View Post
I've seen 2 admins banned one person but the thing you mentioned is unlikely to be happen
That's primarily because of the delay between the ban and kick functions. A lot of servers delay the kick process by around a second or two to enable for a ban message to be sent to the player being banned. What I assume happened in your case is that two admins banned an individual in the same instant or in the aforementioned time frame.

As for the question, OnPlayerDisconnect is called once, when the player actually disconnects.


Re: Kick already disconnected player - ScIrUsna - 20.06.2016

Another question is this callback OnPlayerDisconnect always call when player disconnect can by times that it's not by called lagg or smth? because if i'am saving player stats it's get bad if one time it's not save.


Re: Kick already disconnected player - XVlaDX - 20.06.2016

It's always called when the player disconnects unless your server crashes.
What I would suggest is creating a timer that regularly saves your players accounts, this will reduce the likeliness of a significant rollback should a Player disconnect and not have their stats save.


Re: Kick already disconnected player - [KHK]Khalid - 20.06.2016

Quote:
Originally Posted by XVlaDX
View Post
That's primarily because of the delay between the ban and kick functions. A lot of servers delay the kick process by around a second or two to enable for a ban message to be sent to the player being banned. What I assume happened in your case is that two admins banned an individual in the same instant or in the aforementioned time frame.
You can fix that by assigning a variable (say BeingKicked[playerid] = true) to whoever you set that delayed timer to, and on /ban or /kick commands you just do a check to make sure that BeingKicked variable is set to false before executing anything.


Re: Kick already disconnected player - NaS - 20.06.2016

OnPlayerDisconnect will never call twice, no matter what you do.
The only thing that might make it not call is accessing invalid array slots (or similar "bugs"), which can lead to weird and unpredicted behaviour, but that would be your fault/a script-related bug.