diff --git a/src/Components/Modules/Vote.cpp b/src/Components/Modules/Vote.cpp index 25150744..26246604 100644 --- a/src/Components/Modules/Vote.cpp +++ b/src/Components/Modules/Vote.cpp @@ -11,6 +11,8 @@ namespace Components {"typemap", HandleTypemap}, {"map", HandleMap}, {"g_gametype", HandleGametype}, + {"kick", HandleKick}, + {"tempBanUser", HandleKick} }; void Vote::DisplayVote(const Game::gentity_s* ent) @@ -150,6 +152,35 @@ namespace Components return true; } + bool Vote::HandleKick(const Game::gentity_s* ent, const Command::ServerParams* params) + { + char cleanName[0x40]{}; + + auto kicknum = Game::level->maxclients; + for (auto i = 0; i < Game::level->maxclients; ++i) + { + if (Game::level->clients[i].sess.connected == Game::CON_CONNECTED) + { + strncpy_s(cleanName, Game::level->clients[i].sess.cs.name, _TRUNCATE); + Game::I_CleanStr(cleanName); + if (Utils::String::Compare(cleanName, params->get(2))) + { + kicknum = i; + } + } + } + + if (kicknum == Game::level->maxclients) + { + Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_CLIENTNOTONSERVER\"", 0x65)); + return false; + } + + sprintf_s(Game::level->voteString, "%s \"%d\"", "tempBanClient", kicknum); // kick and tempBanClient do the same thing + sprintf_s(Game::level->voteDisplayString, "GAME_VOTE_KICK\x15(%i)%s", kicknum, Game::level->clients[kicknum].sess.cs.name); + return true; + } + void Vote::Scr_VoteCalled(Game::gentity_s* self, const char* command, const char* param1, const char* param2) { Game::Scr_AddString(param2); diff --git a/src/Components/Modules/Vote.hpp b/src/Components/Modules/Vote.hpp index ffc68d23..e8be3a43 100644 --- a/src/Components/Modules/Vote.hpp +++ b/src/Components/Modules/Vote.hpp @@ -12,7 +12,7 @@ namespace Components static std::unordered_map VoteCommands; static constexpr auto* CallVoteDesc = "%c \"GAME_VOTECOMMANDSARE\x15 map_restart, map_rotate, map , g_gametype , typemap , " - " kick , tempBanUser \""; + "kick , tempBanUser \""; static void DisplayVote(const Game::gentity_s* ent); static bool IsInvalidVoteString(const std::string& input); @@ -22,6 +22,7 @@ namespace Components static bool HandleTypemap(const Game::gentity_s* ent, const Command::ServerParams* params); static bool HandleMap(const Game::gentity_s* ent, const Command::ServerParams* params); static bool HandleGametype(const Game::gentity_s* ent, const Command::ServerParams* params); + static bool HandleKick(const Game::gentity_s* ent, const Command::ServerParams* params); static void Scr_VoteCalled(Game::gentity_s* self, const char* command, const char* param1, const char* param2); static void Scr_PlayerVote(Game::gentity_s* self, const char* option);