feat(ScriptEventHandler): Improved logging and added join msg

This commit is contained in:
Yimura 2021-01-13 15:35:21 +01:00
parent d461afdccd
commit 045fffd7ba
2 changed files with 36 additions and 3 deletions

View File

@ -1687,6 +1687,17 @@ enum PedBones : std::uint32_t
FB_Tongue_001 = 0xB987
};
enum FreemodePlayerEvents : int64_t
{
PlayerJoined = 1120313136, //args 2 JOINED = 1289518925
PlayerPaused = 2383153667,
PlayerUnpaused = 3717680613,
ChatOpened = 2965958374,
ChatClosed = 1841943281,
LsCustomsEntered = 2098987581,
LsCustomsExit = 465570678,
};
enum RemoteEvents : int64_t
{
Bounty = -116602735,

View File

@ -1,17 +1,39 @@
#include "hooking.hpp"
#include "features.hpp"
#include "pointers.hpp"
#include "natives.hpp"
#include "gta/enums.hpp"
namespace big
{
bool hooks::script_event_handler(std::int64_t NetEventStruct, std::int64_t CNetGamePlayer)
{
auto args = reinterpret_cast<std::int64_t*>(NetEventStruct + 0x70);
Player SenderID = *reinterpret_cast<std::int8_t*>(CNetGamePlayer + 0x2D);
Player player = *reinterpret_cast<std::int8_t*>(CNetGamePlayer + 0x2D);
const auto ScriptEventHash = args[0];
int64_t hash = args[0];
switch (hash)
{
case FreemodePlayerEvents::PlayerJoined:
if (g_settings.options["join_message"].get<bool>() && args[2] == 1289518925)
{
char join_msg[128];
sprintf(join_msg, "<C>%s</C> is joining...", g_pointers->m_get_player_name((Player)args[1]));
features::notify::above_map(join_msg);
}
}
if (g_settings.options["settings"]["logging"]["script_events"])
LOG(INFO) << "Received Script Event " << ScriptEventHash << " from Player " << PLAYER::GET_PLAYER_NAME(SenderID);
{
LOG(INFO) << "Received Script Event";
LOG(INFO) << "Player: " << PLAYER::GET_PLAYER_NAME(player);
LOG(INFO) << "Hash: " << hash;
for (int i = 1; i < sizeof(args); i++)
LOG(INFO) << "Arg #" << i << ": " << args[i];
}
return g_hooking->m_script_event_hook.get_original<decltype(&script_event_handler)>()(NetEventStruct, CNetGamePlayer);
}