mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 11:53:14 +08:00
feat(menu): add invoker and some basic commands
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include "Scripts.hpp"
|
||||
#include "game/pointers/Pointers.hpp"
|
||||
#include "types/rage/atArray.hpp"
|
||||
#include "types/rage/tlsContext.hpp"
|
||||
#include "types/script/scrThread.hpp"
|
||||
|
||||
namespace YimMenu::Scripts
|
||||
{
|
||||
rage::scrThread* FindScriptThread(joaat_t hash)
|
||||
{
|
||||
for (auto& thread : *Pointers.ScriptThreads)
|
||||
{
|
||||
if (thread && thread->m_Context.m_ThreadId && thread->m_ScriptHash == hash)
|
||||
{
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void RunAsScript(rage::scrThread* thread, std::function<void()> callback)
|
||||
{
|
||||
auto og_thread = rage::tlsContext::Get()->m_CurrentScriptThread;
|
||||
auto og_running_in_scrthread = rage::tlsContext::Get()->m_ScriptThreadActive;
|
||||
rage::tlsContext::Get()->m_CurrentScriptThread = thread;
|
||||
rage::tlsContext::Get()->m_ScriptThreadActive = true;
|
||||
callback();
|
||||
rage::tlsContext::Get()->m_ScriptThreadActive = og_running_in_scrthread;
|
||||
rage::tlsContext::Get()->m_CurrentScriptThread = og_thread;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user