mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 20:03:17 +08:00
feat: try to implement a kick
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user