[Vote] Handle client commands for kick & tempbanuser
This commit is contained in:
parent
77c25bc11f
commit
a8a3d7c918
@ -11,6 +11,8 @@ namespace Components
|
|||||||
{"typemap", HandleTypemap},
|
{"typemap", HandleTypemap},
|
||||||
{"map", HandleMap},
|
{"map", HandleMap},
|
||||||
{"g_gametype", HandleGametype},
|
{"g_gametype", HandleGametype},
|
||||||
|
{"kick", HandleKick},
|
||||||
|
{"tempBanUser", HandleKick}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Vote::DisplayVote(const Game::gentity_s* ent)
|
void Vote::DisplayVote(const Game::gentity_s* ent)
|
||||||
@ -150,6 +152,35 @@ namespace Components
|
|||||||
return true;
|
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)
|
void Vote::Scr_VoteCalled(Game::gentity_s* self, const char* command, const char* param1, const char* param2)
|
||||||
{
|
{
|
||||||
Game::Scr_AddString(param2);
|
Game::Scr_AddString(param2);
|
||||||
|
@ -12,7 +12,7 @@ namespace Components
|
|||||||
static std::unordered_map<std::string, CommandHandler> VoteCommands;
|
static std::unordered_map<std::string, CommandHandler> VoteCommands;
|
||||||
|
|
||||||
static constexpr auto* CallVoteDesc = "%c \"GAME_VOTECOMMANDSARE\x15 map_restart, map_rotate, map <mapname>, g_gametype <typename>, typemap <typename> <mapname>, "
|
static constexpr auto* CallVoteDesc = "%c \"GAME_VOTECOMMANDSARE\x15 map_restart, map_rotate, map <mapname>, g_gametype <typename>, typemap <typename> <mapname>, "
|
||||||
" kick <player>, tempBanUser <player>\"";
|
"kick <player>, tempBanUser <player>\"";
|
||||||
|
|
||||||
static void DisplayVote(const Game::gentity_s* ent);
|
static void DisplayVote(const Game::gentity_s* ent);
|
||||||
static bool IsInvalidVoteString(const std::string& input);
|
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 HandleTypemap(const Game::gentity_s* ent, const Command::ServerParams* params);
|
||||||
static bool HandleMap(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 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_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);
|
static void Scr_PlayerVote(Game::gentity_s* self, const char* option);
|
||||||
|
Loading…
Reference in New Issue
Block a user