Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool __fastcall hkDispatchUserMessage(void* _this, void* edx, int type, unsigned int a3, unsigned int length, const void* msg_data) {
- static auto oDispatchUserMessage = hlclient_hook.get_original<decltype(&hkDispatchUserMessage)>(index::DispatchUserMessage);
- if (!g_EngineClient->IsConnected() || !g_EngineClient->IsInGame())
- return oDispatchUserMessage(g_CHLClient, edx, type, a3, length, msg_data);
- static auto msgOnce = false;
- switch (type) {
- case CS_UM_VoteStart: {
- int team = -1, vote_t = -1, voting_player = -1;
- const auto localName = g_LocalPlayer->GetPlayerInfo().szName;
- if (!msgOnce) {
- bf_read data = bf_read(reinterpret_cast<uintptr_t>(msg_data));
- data.set_offset(1);
- team = data.read_byte();
- if (team != -1) {
- data.skip(1);
- voting_player = data.read_byte();
- data.skip(1);
- auto vPlayer = C_BasePlayer::GetPlayerByIndex(voting_player);
- auto msgType = data.read_string();
- auto message = data.read_string();
- auto playerToKick = data.read_string();
- const auto from = vPlayer->GetPlayerInfo().szName;
- if (strstr(message.c_str(), "#SFUI_vote_kick_player_other")) {
- if (strstr(playerToKick.c_str(), localName)) {
- Utils::ConsolePrint("player to kick : %p\n", playerToKick.c_str());
- Utils::ConsolePrint("from : %p\n", from);
- static bool voteType = false;
- if (!voteType) {
- g_EngineClient->ClientCmd_Unrestricted("callvote SwapTeams");
- voteType = true;
- }
- else {
- g_EngineClient->ClientCmd_Unrestricted("callvote ChangeLevel de_inferno");
- g_EngineClient->ClientCmd_Unrestricted("callvote ChangeLevel de_mirage");
- voteType = false;
- }
- }
- }
- }
- msgOnce = true;
- }
- break;
- }
- return oDispatchUserMessage(g_CHLClient, edx, type, a3, length, msg_data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement