[Include] DelayKickBan - With additional checks over send/receive of player data
#1

DelayKickBan
With additional checks over send/receive of player data
(Previously known as : KickBanFix)
Since 0.3x release, functions - Kick, Ban or BanEx functions are called quickly when processed. So any functions which would get or set player's data will fail as it would lose the connection. There had been some fix for this by delaying the Kick/Ban function and I've also been using it before. But then I realized that it's not completely efficient because in case if a player is spamming and an auto-kick is kept, the server would still receive data until the player's connection is actually lost. This is a bad practice and would create a mess if the scripter hasn't denied the data of the player after kick/ban is processed.

Example : Anti-spam on chat -

You've created an anti-spam on your server which would check if the player is chat spamming. Usually, it used to kick player with a message if spamming. But if the spam is too fast and if you're delaying the kick, even after the spam counts the server will receive some more player spam messages.
Код:
fall3n : spam test
fall3n : spam test
fall3n : spam test
(Example anti-spam kicking fall3n for spamming)
fall3n : spam test
fall3n : spam test
fall3n : spam test
fall3n : spam test

** fall3n has left the server (Kicked/Banned)
This include ensures that most of the player's update won't be synced to the server, including chat, commands, dialog responses, vehicle updates and death information. This include is compatible with both 0.3x version and 0.3z version.

Also, this include allows you to replace the default Kick, Ban and BanEx functions to be working as delayed functions. So that you don't have to use "DelayKick" to delay, "Kick" would automatically delay. The same goes for "Ban", and "BanEx". To use this, define HOOK_DEFAULT_KICKBAN before including this script.




How would the anti-spam look if using DelayKickBan include:
Код:
fall3n : spam test
fall3n : spam test
fall3n : spam test
(Example anti-spam kicking fall3n for spamming)

** fall3n has left the server (Kicked/Banned)
The include will automatically deny the text message of player. Not only chat text, it also ensures if commands, dialog response, bullet data, damage, vehicle updates and death information are ignored when the player is processed for kick/ban.

Natives

pawn Код:
#if defined HOOK_DEFAULT_KICKBAN
//It will then get the default natives to work accordingly
native Kick(playerid, delay_ms=150);
native Ban(playerid, delay_ms=150);
native BanEx(playerid, const reason[], delay_ms=150);

//"delay_ms" is an optional parameter, which means even if you use Kick(playerid); there's no problem, it will kick the player after 150ms.
//If you're using Kick(playerid, 1000); It would kick player only after 1000 ms (1 second).
//The same applies for Ban and BanEx.

#else
//If not defined the HOOK_DEFAULT_KICKBAN
native DelayKick(playerid, delay_ms=150);
native DelayBan(playerid, delay_ms=150);
native DelayBanEx(playerid, const reason[], delay_ms=150);

#endif

native IsKickBanProcessed(playerid); //Returns : 1 if kick/ban is processed on player, 0 if not.

//This native can be used to ignore anything on your script for the player in case if it's called.
Documentation

https://sampforum.blast.hk/showthread.php?tid=540505

This is a simple include, yes but the documentation contains some various methods in determining the delay_ms to be used and also to block callbacks to prevent them from executing player functions when kick/ban is processed.

Changelog

v1.1-3
• Fixed : Unable to use commands while this include is in use issue.
v1.1-2
• Fixed : An issue caused on timer calls.
Download

If there's any issue, please let me know about that.

https://github.com/falle3n/DelayKickBan/releases
Latest release : https://github.com/falle3n/DelayKick...ses/tag/v1.1-3
Reply
#2

Where's the reason param in BanEx?
EDIT: I wrote this before checking the include (I just saw the natives you posted here)
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Where's the reason param in BanEx?
EDIT: I wrote this before checking the include (I just saw the natives you posted here)
Thanks for noting that out. I forgot to add the "reason" parameter on the native list. Fixed now.
Reply
#4

Nice, I'm using this now.
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
You should really use a different name for the functions, like "DelayKick" or something, since this is not a true fix. The functions work exactly as designed, what you want is different behaviour, and so a different function. That's the reason fixes.inc doesn't do Kick/Ban - they aren't broken.
Thanks for that note, I did have a feeling if I should have hooked the default functions or not but since the majority of coders are using normal Kick/Ban/BanEx functions, I thought to hook them. I've done a small update to the include changing the function names to "DelayKick", "DelayBan" and "DelayBanEx". In case if anyone wants the include to work like how it used to work, you can use the previous version or define "HOOK_DEFAULT_KICKBAN" before including.

Also, I would be happy if you could rename my topic to "DelayKickBan".

OT:

Include has been updated and following are the changes :

- Renamed : The include functions to "DelayKick", "DelayBan" and "DelayBanEx".
- Added : A method to use "Kick", "Ban" and "BanEx" functions like the delayed functions. To use this, define HOOK_DEFAULT_KICKBAN before including this script.
- Renamed : The include's name to "DelayKickBan"

Downloads can be found at the main post. There's both "DelayKickBan.inc" and "KickBanFix.inc", choose them according to your usage.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Sorry, I should have said in my last post that I do like the way you have done this, hooking callbacks to prevent their use while still having people connected for a short while.
I did notice many servers having this issue which made me block the callbacks for users who are processed for delayed kicks or bans. Thanks!
Reply
#7

Nice one. + REP
Reply
#8

The concept used here looks good but you could actually block every player callbacks and not let it to get called over scripts while player is being processed under kick/ban if this is included. So that every player callbacks would be prevented from calling on script which uses this include while kick/ban is being processed for the player.(if this one's included first).
Reply
#9

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
The concept used here looks good but you could actually block every player callbacks and not let it to get called over scripts while player is being processed under kick/ban if this is included. So that every player callbacks would be prevented from calling on script which uses this include while kick/ban is being processed for the player.(if this one's included first).
Thank you for your suggestion. I too agree that it's better to block every player callbacks if kick / ban is being processed. Writing them all would take a few time and I'm quite a lazy person. I'd try doing that all when I'm free. I've for seen it earlier and that's why I included a function IsKickBanProcessed.

There was a bug found on this include and it has been fixed, those who have downloaded earlier are requested to download the latest version. It's recommended because false calls over SetTimer might cause crash.

https://github.com/falle3n/DelayKick...ses/tag/v1.1-2
Reply
#10

Nice include, it does an KickCrash too (for quit players game)? +REP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)