vote logging
This commit is contained in:
parent
96fcefaa01
commit
43e02bd19a
@ -100,6 +100,7 @@
|
||||
#include "tfmm.hpp"
|
||||
#include "hooks/hookedmethods.hpp"
|
||||
#include "classinfo/classinfo.hpp"
|
||||
#include "votelogger.hpp"
|
||||
#include "crits.hpp"
|
||||
#include "textmode.hpp"
|
||||
#include "backpacktf.hpp"
|
||||
|
19
include/votelogger.hpp
Normal file
19
include/votelogger.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* votelogger.hpp
|
||||
*
|
||||
* Created on: Dec 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class bf_read;
|
||||
|
||||
namespace votelogger
|
||||
{
|
||||
|
||||
void user_message(bf_read& buffer, int type);
|
||||
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,6 @@ void do_random_votekick()
|
||||
player_info_s info;
|
||||
if (!g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(target), &info))
|
||||
return;
|
||||
logging::Info("Calling vote to kick '%s' [U:1:%u] (%d / %u)", info.name, info.friendsID, target, targets.size());
|
||||
hack::ExecuteCommand("callvote kick " + std::to_string(target) + " cheating");
|
||||
}
|
||||
|
||||
|
@ -667,8 +667,8 @@ void FrameStageNotify_hook(void *_this, int stage)
|
||||
std::lock_guard<std::mutex> guard(hack::command_stack_mutex);
|
||||
while (!hack::command_stack().empty())
|
||||
{
|
||||
logging::Info("executing %s",
|
||||
hack::command_stack().top().c_str());
|
||||
//logging::Info("executing %s",
|
||||
// hack::command_stack().top().c_str());
|
||||
g_IEngine->ClientCmd_Unrestricted(
|
||||
hack::command_stack().top().c_str());
|
||||
hack::command_stack().pop();
|
||||
@ -782,7 +782,16 @@ bool DispatchUserMessage_hook(void *_this, int type, bf_read &buf)
|
||||
if (dispatch_log)
|
||||
{
|
||||
logging::Info("D> %i", type);
|
||||
std::ostringstream str{};
|
||||
while (buf.GetNumBytesLeft())
|
||||
{
|
||||
unsigned char byte = buf.ReadByte();
|
||||
str << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(byte) << ' ';
|
||||
}
|
||||
logging::Info("MESSAGE %d, DATA = [ %s ]", type, str.str().c_str());
|
||||
buf.Seek(0);
|
||||
}
|
||||
votelogger::user_message(buf, type);
|
||||
return original(_this, type, buf);
|
||||
}
|
||||
|
||||
|
59
src/votelogger.cpp
Normal file
59
src/votelogger.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* votelogger.cpp
|
||||
*
|
||||
* Created on: Dec 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
namespace votelogger
|
||||
{
|
||||
|
||||
static CatVar enabled(CV_SWITCH, "votelog", "0", "Log votes");
|
||||
|
||||
void user_message(bf_read& buffer, int type)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 45:
|
||||
// Call Vote Failed
|
||||
break;
|
||||
case 46: {
|
||||
unsigned char caller = buffer.ReadByte();
|
||||
// unknown
|
||||
buffer.ReadByte();
|
||||
char reason[64];
|
||||
char name[64];
|
||||
buffer.ReadString(reason, 64, false, nullptr);
|
||||
buffer.ReadString(name, 64, false, nullptr);
|
||||
unsigned char eid = buffer.ReadByte();
|
||||
buffer.Seek(0);
|
||||
eid >>= 1;
|
||||
|
||||
unsigned steamID = 0;
|
||||
player_info_s info;
|
||||
if (g_IEngine->GetPlayerInfo(eid, &info))
|
||||
{
|
||||
steamID = info.friendsID;
|
||||
}
|
||||
|
||||
logging::Info("Vote called to kick %s [U:1:%u] for %s", name, steamID, reason);
|
||||
break;
|
||||
}
|
||||
case 47:
|
||||
logging::Info("Vote passed");
|
||||
break;
|
||||
case 48:
|
||||
logging::Info("Vote failed");
|
||||
break;
|
||||
case 49:
|
||||
logging::Info("VoteSetup?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user