SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/06/2016, 08:10 AM   #1
ScIrUsna
Huge Clucker
 
Join Date: Mar 2016
Posts: 285
Reputation: 3
Default Kick already disconnected player

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?
__________________
zombie server 185.34.52.221:7777
ScIrUsna is offline   Reply With Quote
Old 20/06/2016, 12:03 PM   #2
Matz
Huge Clucker
 
Matz's Avatar
 
Join Date: Apr 2011
Location: Istanbul
Posts: 249
Reputation: 142
Default Re: Kick already disconnected player

I've seen 2 admins banned one person but the thing you mentioned is unlikely to be happen
Matz is offline   Reply With Quote
Old 20/06/2016, 01:45 PM   #3
XVlaDX
Little Clucker
 
Join Date: Apr 2012
Location: Jupiter
Posts: 48
Reputation: 3
Default Re: Kick already disconnected player

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.
XVlaDX is offline   Reply With Quote
Old 20/06/2016, 01:47 PM   #4
ScIrUsna
Huge Clucker
 
Join Date: Mar 2016
Posts: 285
Reputation: 3
Default Re: Kick already disconnected player

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.
__________________
zombie server 185.34.52.221:7777
ScIrUsna is offline   Reply With Quote
Old 20/06/2016, 01:50 PM   #5
XVlaDX
Little Clucker
 
Join Date: Apr 2012
Location: Jupiter
Posts: 48
Reputation: 3
Default Re: Kick already disconnected player

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.
XVlaDX is offline   Reply With Quote
Old 20/06/2016, 04:17 PM   #6
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 854
Reputation: 136
Default Re: Kick already disconnected player

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.
[KHK]Khalid is offline   Reply With Quote
Old 20/06/2016, 05:05 PM   #7
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,783
Reputation: 619
Default Re: Kick already disconnected player

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.
NaS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Made /kick Command to Kick Player from Virtual World... MAFIAWARS Scripting Help 11 28/09/2013 03:39 PM
If the player disconnected. dorperez Scripting Help 6 22/04/2013 06:32 PM
Player Weapon Bug after event / Disconnected PRoleplay Scripting Help 1 22/11/2012 03:49 AM
[Question] Variable of disconnected/Connected player. DanTzi Scripting Help 5 25/09/2011 04:23 PM
Save weapons if a player disconnected Battlaman Help Archive 2 03/09/2009 06:33 AM


All times are GMT. The time now is 08:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.