AlliedModders Donor
Join Date: Aug 2019
Location: Romania
|
01-03-2022
, 16:19
Advanced slot reservation
|
#1
|
Advanced slot reservation
Informations
Description This script can detect if the player's Name, Password or IP Address is reserved and it automatically kicks a random player ( in accordance with settings, player can be non-admin / admin and bot or hltv proxy ) from server, only if the server is full. In order to do that, sv_visiblemaxplayers has to be more than maxplayers.
It is compatible with dynamic admins storage, such as users.ini, amxbans, etc ).
Requirements - AmxModX 1.8.2+
- HLDS ( Build: 8684+ ) or ReHLDS ( Version: 3.11.0.767+ )
- For ReHLDS: ReAPI Module ( Version: 5.21.0.248+ )
- For HLDS: Orpheu Module
Installation- Download the archive from down below.
- Compile advanced_slot_reservation.sma using a local compiler or a web compiler.
- Put advanced_slot_reservation.amxx in amxmodx/plugins folder
- Go to amxmodx/configs/plugins.ini, open the file and write on the last line advanced_slot_reservation.amxx.
- Step ONLY for HLDS:
- Add SV_ConnectClient signature file to configs/orpheu/functions
- Restart your server or change the map and you're ready to go.
API
PHP Code:
/* Sublime AMXX Editor v4.2 */
#if defined _adv_slot_reservation_included
#endinput
#endif
#define _adv_slot_reservation_included
#if !defined MAX_NAME_LENGTH
#define MAX_NAME_LENGTH 32
#endif
#if !defined MAX_IP_LENGTH
#define MAX_IP_LENGTH 16
#endif
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
/* Engine const https://github.com/dreamstalker/rehlds/blob/master/rehlds/engine/info.h#L37 */
#define MAX_INFO_STRING 256
#define MAX_STRING 256
#define MAX_USER_INFO_PASSWORD 34
/* Custom return values */
enum (+=250)
{
SLOT_KICK_NO = 0,
SLOT_KICK_YES
};
enum _:PlayerData
{
#if defined USE_REAPI
szIP[MAX_IP_LENGTH],
#endif
szName[MAX_NAME_LENGTH],
szPassword[MAX_USER_INFO_PASSWORD]
};
/**
* @description Multiforward called before a player will be kicked to free a player slot.
*
* @param id Choosen player to be kicked index.
* @param szPlayerData Array which contains data of the reserved client.
*
* @return Return SLOT_KICK_YES if you want to not let the plugin kick the player or SLOT_KICK_NO to continue executing.
*/
forward player_kick_pre(id, szPlayerData[PlayerData]);
/**
* @description Multiforward called right before a player will be kicked to free a player slot.
*
* @param id Choosen player to be kicked index.
* @param szPlayerData Array which contains data of the reserved client.
*
* @return Forward ignores return values.
*/
forward player_kick_post(id, szPlayerData[PlayerData]);
/**
* @description Multiforward called after the player array was sorted.
*
* @param szPlayers Array which contains player's indexes.
* @param iTotalPlayers Total of players included in the sorting algorithm.
*
* @note Array will be passed in kicking function with the changes made inside this forward.
*
* @return Forward ignores return values.
*/
forward player_check_playtime(szPlayers[MAX_PLAYERS], iTotalPlayers);
/* Support for AmxModX versions lower that 1.8.3 */
#if AMXX_VERSION_NUM < 183
enum GetPlayersFlags (<<= 1)
{
GetPlayers_None = 0, // No filter (Default)
GetPlayers_ExcludeDead = 1, // Do not include dead clients
GetPlayers_ExcludeAlive, // Do not include alive clients
GetPlayers_ExcludeBots, // Do not include bots
GetPlayers_ExcludeHuman, // Do not include human clients
GetPlayers_MatchTeam, // Match with team
GetPlayers_MatchNameSubstring, // Match with part of name
GetPlayers_CaseInsensitive, // Match case insensitive
GetPlayers_ExcludeHLTV, // Do not include HLTV proxies
GetPlayers_IncludeConnecting // Include connecting clients
};
stock get_players_ex(players[MAX_PLAYERS] = {}, &num, GetPlayersFlags:flags = GetPlayers_None, const team[] = "")
{
new strFlags[10];
get_flags(_:flags, strFlags, charsmax(strFlags));
get_players(players, num, strFlags, team);
}
stock get_playersnum_ex(GetPlayersFlags:flags = GetPlayers_None, const team[] = "")
{
new PlayersNum;
get_players_ex(_, PlayersNum, flags, team);
return PlayersNum;
}
#endif
To Do-
If all slots are used, ability to search a player to kick based on certain criteria (spectator, defined afk time, etc) - Idea took from "New features in plugins" from GitHub. Done!
-
Improve detection. Done!
ChangeLog
FULL Changelog can be found HERE- Version 1.0:
- Version 1.1:
-- Added reservation type either by IP address or name.
- Added some settings for connected players checking.
- Added parsing player's name in SV_ConnectClient hook ( Thanks HamletEagle for showing me this way https://forums.alliedmods.net/showpo...9&postcount=13 ).
- Improved connected players checking code.
- Version 1.2:
- Implemented a new reservation method:
- Implemented more methods for the kicking player algorithm:
- Kick only from spectators. If there is no spectator, then go to the next search method.
- Kick player by played time ( the oldest player on the server or the newest player on the server ).
- Added admin immunity flag in configuration file ( which flag should be skipped from algorithm ).
- Added kick message field in configuration file.
- Version 1.3:
- Added support for VGUI connect ( like before but customizable, read description in config file ).
- Removed SV_ConnectClient execute parameter (id) because it isn't passed from hook and renamed function name.
- Version 1.4:
- Added support for dynamiclly stored admins ( such as users.ini, SQL Admins, AmxBans too ) ( except those which have SteamID as auth data because player's steamID can't be retrieved in SV_ConnectClient hook ).
- Thanks to PomanoB & droper for the idea.
- Improved a little set_visible_players() function.
- Version 1.5:
- Added API to plugin:
- Added player_kick_pre() forward which is called before a player will be kicked.
- Added player_kick_post() forward which is called right before a player is kicked.
- Added player_check_playtime() forward which is called after player's indexes array was sorted.
- Added an API test plugin.
- Added a new ADMIN_SUPPORT value ( updated in documentation from the config file ).
- Version 1.6:
- Added compatibility support for AmxModX 1.8.2.
- Version 1.7:
- Fixed SQL dynamic admins support
- Version 1.8:
- Added password hashing support
- Fixed a bug when admins were the spectators, and INCLUDE_ADMINS was 0, it won't kick any player from server, preventing the reserved player to connect. ( Thanks AntiLamer.(https://forums.alliedmods.net/member.php?u=57625) for tests )
- Improved pieces of code
- Version 1.9:
- Fixed password and name support.
- Fixed VGUI Support if there are less than maxplayers.
- Version 2.0:
- Fixed an issue when there is no player selected
- Version 2.1:
- Fixed IP and Password reservation types.
- Version 2.2:
- Added HLDS Support
- IP reservation can't be achieved on HLDS ( or at least I couldn't find any method ).
Orpheu Signature for SV_ConnectClient ( Only for HLDS )
Code:
{
"name" : "SV_ConnectClient",
"library" : "engine",
"identifiers" :
[
{
"os" : "windows",
"value" : [0x55,0x8B,0xEC,0x81,"*","*","*","*","*",0x53,0x56,0x57,0xB9,0x05,0x00,0x00,0x00,0xBE,"*","*","*","*",0x8D,"*","*",0x33,0xDB,0x68,"*","*","*","*"]
},
{
"os" : "linux",
"value" : "SV_ConnectClient"
}
]
}
GitHub Project
DOWNLOAD SOURCE CODE
DOWNLOAD COMPILED PLUGIN
__________________
Last edited by Shadows Adi; 02-15-2022 at 09:56.
Reason: Update version 2.2
|
|