This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/util/scripts.hpp

47 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include "fiber_pool.hpp"
#include "natives.hpp"
#include "script.hpp"
namespace big::scripts
{
inline bool is_loaded(int hash)
{
return SCRIPT::HAS_SCRIPT_WITH_NAME_HASH_LOADED(hash);
}
inline bool is_running(int hash)
{
return SCRIPT::DOES_SCRIPT_WITH_NAME_HASH_EXIST(hash);
}
inline void request_script(int hash)
{
SCRIPT::REQUEST_SCRIPT_WITH_NAME_HASH(hash);
}
inline int start_script_with_args(int hash, int* args, int arg_size, int stack_size)
{
int thread_id = SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH_AND_ARGS(hash, args, arg_size, stack_size);
SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED(hash);
return thread_id;
}
inline bool wait_till_loaded(int hash)
{
if (is_loaded(hash)) return true;
for (int i = 0; i < 150 && !is_loaded(hash); i++)
script::get_current()->yield(10ms);
if (is_loaded(hash)) return true;
return false;
}
inline bool wait_till_running(int hash)
{
if (is_running(hash)) return true;
for (int i = 0; i < 150 && !is_running(hash); i++)
script::get_current()->yield(10ms);
if (is_running(hash)) return true;
return false;
}
}