feat: try to implement a kick

This commit is contained in:
maybegreat48
2025-03-29 00:33:35 -04:00
parent eb192e7b4b
commit 6e0df48ce2
11 changed files with 222 additions and 6 deletions
+25
View File
@@ -4,8 +4,11 @@
#include "types/rage/tlsContext.hpp"
#include "types/script/GtaThread.hpp"
#include "types/script/CGameScriptHandler.hpp"
#include "types/script/CGameScriptHandlerNetComponent.hpp"
#include "types/script/CGameScriptId.hpp"
#include "types/script/globals/GlobalPlayerBD.hpp"
#include "game/gta/Packet.hpp"
#include "game/backend/Players.hpp"
#include "game/backend/Self.hpp"
namespace YimMenu::Scripts
@@ -77,4 +80,26 @@ namespace YimMenu::Scripts
return false;
}
void ForceScriptHost(rage::scrThread* thread)
{
if (auto net_component = reinterpret_cast<GtaThread*>(thread)->m_NetComponent)
{
if (net_component->IsLocalPlayerHost())
return;
net_component->DoHostMigration(Self::GetPlayer().GetHandle(), net_component->m_HostToken + 1, false);
Packet pkt;
pkt.WriteMessageHeader(rage::netMessage::Type::ScriptVerifyHostAck);
net_component->m_ScriptHandler->GetId()->Serialize(&pkt.GetBuffer());
pkt.GetBuffer().Write<bool>(true, 1);
pkt.GetBuffer().Write<bool>(true, 1);
pkt.GetBuffer().Write<std::uint16_t>(net_component->m_HostToken, 16);
for (auto& player : Players::GetPlayers())
if (!player.second.IsLocal())
pkt.Send(player.second.GetMessageId());
}
}
}