feat(toxic): add ceo kick

This commit is contained in:
maybegreat48
2025-03-24 20:38:14 -04:00
parent e90b165f67
commit 51bc0d439f
7 changed files with 74 additions and 32 deletions
+30 -24
View File
@@ -7,6 +7,9 @@
// TODO: serialization isn't stable
#include "game/pointers/Pointers.hpp" // game import in core!
#include "game/gta/Natives.hpp" // game import in core!
namespace YimMenu
{
HotkeySystem::HotkeySystem() :
@@ -94,37 +97,40 @@ namespace YimMenu
{
while (g_Running)
{
for (auto& [hash, link] : m_CommandHotkeys)
if (GetForegroundWindow() == *Pointers.Hwnd && !HUD::IS_PAUSE_MENU_ACTIVE() && !HUD::IS_SOCIAL_CLUB_ACTIVE())
{
if (link.m_Chain.empty() || link.m_BeingModified)
continue;
bool all_keys_pressed = true;
for (auto modifier : link.m_Chain)
for (auto& [hash, link] : m_CommandHotkeys)
{
if (!(GetAsyncKeyState(modifier) & 0x8000))
{
all_keys_pressed = false;
}
}
if (link.m_Chain.empty() || link.m_BeingModified)
continue;
if (all_keys_pressed && std::chrono::system_clock::now() - m_LastHotkeyTriggerTime > 100ms)
{
auto command = Commands::GetCommand(hash);
if (command)
bool all_keys_pressed = true;
for (auto modifier : link.m_Chain)
{
// TODO: this is the only way I can prevent chat from blocking the main loop while keeping everything else fast
if (hash != "chathelper"_J)
command->Call();
else
if (!(GetAsyncKeyState(modifier) & 0x8000))
{
FiberPool::Push([command] {
command->Call();
});
all_keys_pressed = false;
}
}
m_LastHotkeyTriggerTime = std::chrono::system_clock::now();
if (all_keys_pressed && std::chrono::system_clock::now() - m_LastHotkeyTriggerTime > 100ms)
{
auto command = Commands::GetCommand(hash);
if (command)
{
// TODO: this is the only way I can prevent chat from blocking the main loop while keeping everything else fast
if (hash != "chathelper"_J)
command->Call();
else
{
FiberPool::Push([command] {
command->Call();
});
}
}
m_LastHotkeyTriggerTime = std::chrono::system_clock::now();
}
}
}
ScriptMgr::Yield();
@@ -0,0 +1,25 @@
#include "game/commands/PlayerCommand.hpp"
#include "types/script/ScriptEvent.hpp"
namespace YimMenu::Features
{
class CeoKick : public PlayerCommand
{
using PlayerCommand::PlayerCommand;
virtual void OnCall(Player player) override
{
OnCall(std::vector{player});
}
virtual void OnCall(const std::vector<Player>& players) override
{
SCRIPT_EVENT_KICK_FROM_CEO message;
for (auto& player : players)
message.SetPlayer(player.GetId());
message.Send();
}
};
static CeoKick _CeoKick{"ceokick", "CEO Kick", "Kicks the player from their organization or motorcycle club"};
}
+1
View File
@@ -32,6 +32,7 @@ namespace YimMenu::Submenus
toxicGroup->AddItem(std::make_shared<CommandItem>("killall"_J, "Kill All"));
toxicGroup->AddItem(std::make_shared<CommandItem>("killexploitall"_J, "Permadeath All"));
toxicGroup->AddItem(std::make_shared<CommandItem>("explodeall"_J, "Explode All"));
toxicGroup->AddItem(std::make_shared<CommandItem>("ceokickall"_J, "CEO Kick All"));
enhancements->AddItem(std::make_shared<BoolCommandItem>("fastjoin"_J));
+9 -5
View File
@@ -6,12 +6,16 @@ namespace YimMenu::Submenus
{
auto menu = std::make_shared<Category>("Toxic");
auto general = std::make_shared<Group>("Damage", 1);
general->AddItem(std::make_shared<PlayerCommandItem>("kill"_J));
general->AddItem(std::make_shared<PlayerCommandItem>("killexploit"_J));
general->AddItem(std::make_shared<PlayerCommandItem>("explode"_J));
auto damage = std::make_shared<Group>("Damage", 1);
damage->AddItem(std::make_shared<PlayerCommandItem>("kill"_J));
damage->AddItem(std::make_shared<PlayerCommandItem>("killexploit"_J));
damage->AddItem(std::make_shared<PlayerCommandItem>("explode"_J));
menu->AddItem(general);
auto griefing = std::make_shared<Group>("Griefing");
griefing->AddItem(std::make_shared<PlayerCommandItem>("ceokick"_J));
menu->AddItem(damage);
menu->AddItem(griefing);
return menu;
}
-1
View File
@@ -45,7 +45,6 @@ namespace YimMenu
DECORATOR::DECOR_SET_INT(veh.GetHandle(), "MPBitset", 0);
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(NETWORK::VEH_TO_NET(veh.GetHandle()), true);
VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(veh.GetHandle(), 0);
ENTITY::SET_ALLOW_MIGRATE_TO_SPECTATOR(veh.GetHandle(), true);
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model);
return veh;
+1 -1
View File
@@ -25,7 +25,7 @@ enum class WheelTypes
WHEEL_TYPE_TRACK
};
enum class VehicleWeapons
enum class VehicleWeapons : std::uint32_t
{
VEHICLE_WEAPON_AKULA_BARRAGE = 0x880D14F2,
VEHICLE_WEAPON_AKULA_MINIGUN = 0x19B95679,
+8 -1
View File
@@ -48,7 +48,7 @@ enum class ScriptEventIndex
Spectate = 1840946429, // SPEC_TCK1
Teleport = -1321657966, // Mission_Pass_Notify
TeleportToWarehouse = -1253241415, // .f_4 == 50
TransactionError = -830063381, // NETWORK_RECEIVE_PLAYER_JOBSHARE_CASH
// TransactionError = -830063381, // NETWORK_RECEIVE_PLAYER_JOBSHARE_CASH
VehicleKick = -503325966, // PIM_RFMOC
MCTeleport = 1103127469, // NETWORK::NETWORK_HASH_FROM_PLAYER_HANDLE(PLAYER::PLAYER_ID()) == (first one)
StartActivity = 1450115979, // (Var0.f_2, -1); first match
@@ -145,4 +145,11 @@ struct SCRIPT_EVENT_SEND_TEXT_LABEL_MESSAGE : public SCRIPT_EVENT
};
static_assert(sizeof(SCRIPT_EVENT_SEND_TEXT_LABEL_MESSAGE) == 9 * 8);
struct SCRIPT_EVENT_KICK_FROM_CEO : public SCRIPT_EVENT
{
REGISTER_SCRIPT_EVENT(SCRIPT_EVENT_KICK_FROM_CEO, CeoKick);
};
static_assert(sizeof(SCRIPT_EVENT_KICK_FROM_CEO) == 3 * 8);
#undef REGISTER_SCRIPT_EVENT