mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Improve ban commands
The ban commands have the 'sv_' prefix removed. CBaseEntity::InputKill expects 'kickid' to be present, it uses this to kick the player once the entity has been destroyed. Not doing so could lead into a crash or other undesired behavior.
This commit is contained in:
parent
d43ab4a850
commit
b13cc071a9
r5dev
@ -109,17 +109,59 @@ void ToggleBrowser_f(const CCommand& args)
|
||||
/*
|
||||
=====================
|
||||
Host_Kick_f
|
||||
|
||||
helper function for
|
||||
bansystem
|
||||
=====================
|
||||
*/
|
||||
void Host_Kick_f(const CCommand& args)
|
||||
void _Author_Client_f(const CCommand& args, EKickType type)
|
||||
{
|
||||
if (args.ArgC() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_pBanSystem->KickPlayerByName(args.Arg(1),
|
||||
args.ArgC() > 2 ? args.Arg(2) : nullptr);
|
||||
const char* szReason = args.ArgC() > 2 ? args.Arg(2) : nullptr;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case KICK_NAME:
|
||||
{
|
||||
g_pBanSystem->KickPlayerByName(args.Arg(1), szReason);
|
||||
break;
|
||||
}
|
||||
case KICK_ID:
|
||||
{
|
||||
g_pBanSystem->KickPlayerById(args.Arg(1), szReason);
|
||||
break;
|
||||
}
|
||||
case BAN_NAME:
|
||||
{
|
||||
g_pBanSystem->BanPlayerByName(args.Arg(1), szReason);
|
||||
break;
|
||||
}
|
||||
case BAN_ID:
|
||||
{
|
||||
g_pBanSystem->BanPlayerById(args.Arg(1), szReason);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Code bug.
|
||||
Assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
Host_Kick_f
|
||||
=====================
|
||||
*/
|
||||
void Host_Kick_f(const CCommand& args)
|
||||
{
|
||||
_Author_Client_f(args, EKickType::KICK_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -129,13 +171,7 @@ Host_KickID_f
|
||||
*/
|
||||
void Host_KickID_f(const CCommand& args)
|
||||
{
|
||||
if (args.ArgC() < 2) // Do we at least have 2 arguments?
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_pBanSystem->KickPlayerById(args.Arg(1),
|
||||
args.ArgC() > 2 ? args.Arg(2) : nullptr);
|
||||
_Author_Client_f(args, EKickType::KICK_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -145,13 +181,7 @@ Host_Ban_f
|
||||
*/
|
||||
void Host_Ban_f(const CCommand& args)
|
||||
{
|
||||
if (args.ArgC() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_pBanSystem->BanPlayerByName(args.Arg(1),
|
||||
args.ArgC() > 2 ? args.Arg(2) : nullptr);
|
||||
_Author_Client_f(args, EKickType::BAN_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -161,11 +191,7 @@ Host_BanID_f
|
||||
*/
|
||||
void Host_BanID_f(const CCommand& args)
|
||||
{
|
||||
if (args.ArgC() < 2)
|
||||
return;
|
||||
|
||||
g_pBanSystem->BanPlayerById(args.Arg(1),
|
||||
args.ArgC() > 2 ? args.Arg(2) : nullptr);
|
||||
_Author_Client_f(args, EKickType::BAN_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -606,11 +606,11 @@ void ConCommand_StaticInit(void)
|
||||
// SERVER DLL |
|
||||
#ifndef CLIENT_DLL
|
||||
ConCommand::StaticCreate("script", "Run input code as SERVER script on the VM.", nullptr, FCVAR_GAMEDLL | FCVAR_CHEAT, SQVM_ServerScript_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_kick", "Kick a client from the server by user name.", "sv_kick \"<userId>\"", FCVAR_RELEASE, Host_Kick_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_kickid", "Kick a client from the server by handle, nucleus id or ip address.", "sv_kickid \"<handle>\"/\"<nucleusId>/<ipAddress>\"", FCVAR_RELEASE, Host_KickID_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_ban", "Bans a client from the server by user name.", "sv_ban <userId>", FCVAR_RELEASE, Host_Ban_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_banid", "Bans a client from the server by handle, nucleus id or ip address.", "sv_banid \"<handle>\"/\"<nucleusId>/<ipAddress>\"", FCVAR_RELEASE, Host_BanID_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_unban", "Unbans a client from the server by nucleus id or ip address.", "sv_unban \"<nucleusId>\"/\"<ipAddress>\"", FCVAR_RELEASE, Host_Unban_f, nullptr);
|
||||
ConCommand::StaticCreate("kick", "Kick a client from the server by user name.", "kick \"<userId>\"", FCVAR_RELEASE, Host_Kick_f, nullptr);
|
||||
ConCommand::StaticCreate("kickid", "Kick a client from the server by handle, nucleus id or ip address.", "kickid \"<handle>\"/\"<nucleusId>/<ipAddress>\"", FCVAR_RELEASE, Host_KickID_f, nullptr);
|
||||
ConCommand::StaticCreate("ban", "Bans a client from the server by user name.", "ban <userId>", FCVAR_RELEASE, Host_Ban_f, nullptr);
|
||||
ConCommand::StaticCreate("banid", "Bans a client from the server by handle, nucleus id or ip address.", "banid \"<handle>\"/\"<nucleusId>/<ipAddress>\"", FCVAR_RELEASE, Host_BanID_f, nullptr);
|
||||
ConCommand::StaticCreate("unban", "Unbans a client from the server by nucleus id or ip address.", "unban \"<nucleusId>\"/\"<ipAddress>\"", FCVAR_RELEASE, Host_Unban_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_reloadbanlist", "Reloads the banned list.", nullptr, FCVAR_RELEASE, Host_ReloadBanList_f, nullptr);
|
||||
ConCommand::StaticCreate("sv_addbot", "Creates a bot on the server.", nullptr, FCVAR_RELEASE, CC_CreateFakePlayer_f, nullptr);
|
||||
ConCommand::StaticCreate("navmesh_hotswap", "Hot swap the NavMesh for all hulls.", nullptr, FCVAR_DEVELOPMENTONLY, Detour_HotSwap_f, nullptr);
|
||||
|
@ -2,6 +2,14 @@
|
||||
|
||||
typedef vector<std::pair<string, uint64_t>> BannedVec_t;
|
||||
|
||||
enum EKickType
|
||||
{
|
||||
KICK_NAME = 0,
|
||||
KICK_ID,
|
||||
BAN_NAME,
|
||||
BAN_ID
|
||||
};
|
||||
|
||||
class CBanSystem
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user