feat(Lua)!: New Lua bindings (#3563)

* feat(Lua): Make independent imgui independent.
feat(Lua): Add a `pointer:set_address` binding.
feat(Lua): Added `menu_event.Wndproc` event.
fix(Lua): Fix `ImGui.SliderFloat3` binding.
fix(Lua Docs): Partially fixed auto generated documentation.
* fix(gui.cpp): include `lua_manager.hpp`.
* fix(lua_manager.hpp): Added `draw_less_dependent_gui` function.
* chore(Lua): Rename `add_independent_imgui` to `add_always_draw_imgui`.
* docs(menu_event): Added docs for Wndporc event.
* docs: Fixed a few more errors.
* add reasoning and use native underlying format

Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
Co-authored-by: xiaoxiao921 <837334+xiaoxiao921@users.noreply.github.com>
This commit is contained in:
tupoy-ya 2024-08-14 06:40:09 +00:00 committed by GitHub
parent e4e1b6b63b
commit eecd20beaf
22 changed files with 380 additions and 113 deletions

View File

@ -16,7 +16,7 @@ Returns a memory instance, with the given address.
myInstance = pointer:new(address)
```
## Functions (23)
## Functions (26)
### `add(offset)`
@ -63,18 +63,6 @@ Rips the current memory address and returns a new pointer object.
pointer = pointer:rip(offset)
```
### `get_int()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `number`: the value stored at the memory address as the specified type.
**Example Usage:**
```lua
number = pointer:get_int()
```
### `get_byte()`
Retrieves the value stored at the memory address as the specified type.
@ -99,6 +87,18 @@ Retrieves the value stored at the memory address as the specified type.
number = pointer:get_word()
```
### `get_int()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `number`: the value stored at the memory address as the specified type.
**Example Usage:**
```lua
number = pointer:get_int()
```
### `get_dword()`
Retrieves the value stored at the memory address as the specified type.
@ -135,18 +135,6 @@ Retrieves the value stored at the memory address as the specified type.
number = pointer:get_qword()
```
### `set_int(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (number): new value.
**Example Usage:**
```lua
pointer:set_int(value)
```
### `set_byte(value)`
Sets the value at the memory address to the specified value of the given type.
@ -171,6 +159,18 @@ Sets the value at the memory address to the specified value of the given type.
pointer:set_word(value)
```
### `set_int(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (number): new value.
**Example Usage:**
```lua
pointer:set_int(value)
```
### `set_dword(value)`
Sets the value at the memory address to the specified value of the given type.
@ -343,4 +343,16 @@ Retrieves the memory address stored in the pointer object.
number = pointer:get_address()
```
### `set_address(address)`
Sets the memory address stored in the pointer object.
- **Parameters:**
- `address` (integer): new address.
**Example Usage:**
```lua
pointer:set_address(address)
```

View File

@ -23,13 +23,19 @@ Clear the tab of all its custom lua content that you own.
tab:clear()
```
### `add_tab()`
### `add_tab(tab_name)`
Add a sub tab to this tab.
- **Parameters:**
- `tab_name` (string): Name of the tab to add.
- **Returns:**
- `tab`: A tab instance which corresponds to the new tab in the GUI.
**Example Usage:**
```lua
tab:add_tab()
tab = tab:add_tab(tab_name)
```
### `add_button(name, callback)`

View File

@ -26,7 +26,7 @@ z component of the vector.
### `new(x, y, z)`
Returns a vector that contains the x, y, and z values.
Returns: vec3: a vector that contains the x, y, and z values.
- **Parameters:**
- `x` (float): x component of the vector.

View File

@ -2,7 +2,7 @@
Table containing functions for modifying the menu GUI.
## Functions (8)
## Functions (12)
### `get_tab(tab_name)`
@ -92,6 +92,38 @@ gui.show_error(title, message)
bool = gui.is_open()
```
### `toggle(toggle)`
Opens and closes the gui.
- **Parameters:**
- `toggle` (boolean)
**Example Usage:**
```lua
gui.toggle(toggle)
```
### `mouse_override()`
- **Returns:**
- `bool`: Returns true if the mouse is overridden.
**Example Usage:**
```lua
bool = gui.mouse_override()
```
### `override_mouse(override)`
- **Parameters:**
- `override` (boolean)
**Example Usage:**
```lua
gui.override_mouse(override)
```
### `add_imgui(imgui_rendering)`
Registers a function that will be called every rendering frame, you can call ImGui functions in it, please check the ImGui.md documentation file for more info.
@ -118,4 +150,30 @@ end)
gui.add_imgui(imgui_rendering)
```
### `add_always_draw_imgui(imgui_rendering)`
Registers a function that will be called every rendering frame, you can call ImGui functions in it, please check the ImGui.md documentation file for more info. This function will be called even when the menu is closed.
**Example Usage:**
```lua
gui.add_always_draw_imgui(function()
if ImGui.Begin("My Custom Window") then
if ImGui.Button("Label") then
script.run_in_fiber(function(script)
-- call natives in there
end)
end
ImGui.End()
end
end)
``
- **Parameters:**
- `imgui_rendering` (function): Function that will be called every rendering frame, you can call ImGui functions in it, please check the ImGui.md documentation file for more info.
**Example Usage:**
```lua
gui.add_always_draw_imgui(imgui_rendering)
```

View File

@ -2,7 +2,7 @@
Table containing all possible events to which you can respond.
## Fields (8)
## Fields (9)
### `PlayerLeave`
@ -103,3 +103,16 @@ end)
- Type: `integer`
### `Wndproc`
Event that is triggered when Wndproc is called
**Example Usage:**
```lua
event.register_handler(menu_event.Wndproc, function (hwnd, msg, wparam, lparam)
if msg == 132 then return end
log.debug("hwnd = " .. tostring(hwnd) .. ", msg = " .. tostring(msg) .. ", wparam = " .. tostring(wparam) .. ", lparam = " .. tostring(lparam))
end)
```
- Type: `integer`

View File

@ -2,7 +2,7 @@
Table containing helper functions for network related features.
## Functions (17)
## Functions (22)
### `trigger_script_event(bitset, _args)`
@ -146,7 +146,7 @@ string = network.get_flagged_modder_reason(player_idx)
Try to force ourself to be host for the given GTA Script. Needs to be called in the fiber pool or a loop.
- **Parameters:**
- `script_name` (string): Name of the script
- `script_name` (string): Name of the script.
**Example Usage:**
```lua
@ -164,7 +164,7 @@ Forces the given GTA script to be started on a player. Needs to be called in the
**Example Usage:**
```lua
network.force_script_on_player(script_name)
network.force_script_on_player(player_idx, script_name, instance_id)
```
### `send_chat_message(msg, team_only)`
@ -198,14 +198,14 @@ network.send_chat_message_to_player(player_idx, msg)
Call get_player_rank(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `int`: Returns an integer which contains the players rank.
- `integer`: An integer which contains the players rank.
**Example Usage:**
```lua
network.get_player_rank(pid)
integer = network.get_player_rank(pid)
```
### `get_player_rp(pid)`
@ -213,14 +213,14 @@ network.get_player_rank(pid)
Call get_player_rp(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `int`: Returns an integer which contains the players rp.
- `integer`: An integer which contains the players rp.
**Example Usage:**
```lua
network.get_player_rp(pid)
integer = network.get_player_rp(pid)
```
### `get_player_money(pid)`
@ -228,14 +228,14 @@ network.get_player_rp(pid)
Call get_player_money(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `int`: Returns an integer which contains the players money.
- `integer`: An integer which contains the players money.
**Example Usage:**
```lua
network.get_player_money(pid)
integer = network.get_player_money(pid)
```
### `get_player_wallet(pid)`
@ -243,14 +243,14 @@ network.get_player_money(pid)
Call get_player_wallet(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `int`: Returns an integer which contains the players wallet.
- `integer`: An integer which contains the players wallet.
**Example Usage:**
```lua
network.get_player_wallet(pid)
integer = network.get_player_wallet(pid)
```
### `get_player_bank(pid)`
@ -258,14 +258,14 @@ network.get_player_wallet(pid)
Call get_player_bank(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `int`: Returns an integer which contains the players bank.
- `integer`: An integer which contains the players bank.
**Example Usage:**
```lua
network.get_player_bank(pid)
integer = network.get_player_bank(pid)
```
### `get_player_language_id(pid)`
@ -273,14 +273,14 @@ network.get_player_bank(pid)
Call get_player_language_id(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `int`: Returns an integer which contains the players language id.
- `integer`: An integer which contains the players language id.
**Example Usage:**
```lua
network.get_player_language_id(pid)
integer = network.get_player_language_id(pid)
```
### `get_player_language_name(pid)`
@ -288,12 +288,14 @@ network.get_player_language_id(pid)
Call get_player_language_name(playerID)
- **Parameters:**
- `pid` (int)
- `pid` (integer): Index of the player.
- **Returns:**
- `string`: Returns a string which contains the players language name.
- `string`: A string which contains the players language name.
**Example Usage:**
```lua
network.get_player_language_name(pid)
string = network.get_player_language_name(pid)
```

View File

@ -1,43 +1,52 @@
# Table: scr_function
Table for calling GTA script functions. Needs to be called in the fiber pool or a GTA script. Only call the function when necessary.
Table for calling GTA script functions. Needs to be called in the fiber pool. Only call the function when necessary.
## Functions (2)
### `call_script_function(script_name, function_name, pattern, return_type_string, args_)`
Calls a script function with the given arguments. Returns the return value as the given type.
**Example Usage:**
```lua
local value = scr_function.call_script_function("freemode", "wear_sunglasses_at_night", "69 42 06 66", "bool", {
{ "int", 69 },
{ "float", 4.20 },
{ "int", 666 }
})
```
- **Parameters:**
- `script_name` (string): Name of the script.
- `function_name` (string): Name of the function. This parameter needs to be unique.
- `pattern` (string): Pattern to scan for within the script.
- `return_type_string` (string): Return type of the function. Supported types are **"int"**, **"bool"**, **"const char\*/string"**, **"ptr/pointer/*"**, **"float"**, and **"vector3"**. Anything different will be rejected.
- `_args` (table): Arguments to pass to the function. Supported types are the same as return types.
- `args_` (table): Arguments to pass to the function. Supported types are the same as return types.
**Example Usage:**
```lua
local value = scr_function.call_script_function("freemode", "wear_sunglasses_at_night", "69 42 06 66", "bool", {
{ "int", 69 },
{ "float", 4.20 },
{ "int", 666 }
})
scr_function.call_script_function(script_name, function_name, pattern, return_type_string, args_)
```
### `call_script_function(script_name, instruction_pointer, return_type_string, args_)`
Calls a script function directly using the function position with the given arguments. Returns the return value as the given type.
- **Parameters:**
- `script_name` (string): Name of the script.
- `function_name` (string): Name of the function.
- `instruction_pointer` (integer): Position of the function within the script.
- `return_type_string` (string): Return type of the function. Supported types are **"int"**, **"bool"**, **"const char\*/string"**, **"ptr/pointer/*"**, **"float"**, and **"vector3"**. Anything different will be rejected.
- `_args` (table): Arguments to pass to the function. Supported types are the same as return types.
**Example Usage:**
```lua
local value = scr_function.call_script_function("freemode", 0xE792, "string", {
{ "int", 191 }
{ "int", 191 }
})
```
- **Parameters:**
- `script_name` (string): Name of the script.
- `instruction_pointer` (integer): Position of the function within the script.
- `return_type_string` (string): Return type of the function. Supported types are **"int"**, **"bool"**, **"const char\*/string"**, **"ptr/pointer/*"**, **"float"**, and **"vector3"**. Anything different will be rejected.
- `args_` (table): Arguments to pass to the function. Supported types are the same as return types.
**Example Usage:**
```lua
scr_function.call_script_function(script_name, instruction_pointer, return_type_string, args_)
```

View File

@ -2,16 +2,11 @@
Table containing helper functions related to gta scripts.
## Functions (7)
## Functions (6)
### `register_looped(name, func)`
Registers a function that will be looped as a gta script.
- **Parameters:**
- `name` (string): name of your new looped script
- `func` (function): function that will be executed in a forever loop.
**Example Usage:**
```lua
script.register_looped("nameOfMyLoopedScript", function (script)
@ -36,13 +31,18 @@ script.register_looped("nameOfMyLoopedScript", function (script)
end)
```
- **Parameters:**
- `name` (string): name of your new looped script
- `func` (function): function that will be executed in a forever loop.
**Example Usage:**
```lua
script.register_looped(name, func)
```
### `run_in_fiber(func)`
Executes a function once inside the fiber pool, you can call natives inside it and yield or sleep.
- **Parameters:**
- `func` (function): function that will be executed once in the fiber pool.
**Example Usage:**
```lua
script.run_in_fiber(function (script)
@ -67,16 +67,28 @@ script.run_in_fiber(function (script)
end)
```
- **Parameters:**
- `func` (function): function that will be executed once in the fiber pool.
**Example Usage:**
```lua
script.run_in_fiber(func)
```
### `is_active(script_name)`
Returns true if the specified script is currently active/running.
**Example Usage:**
```lua
local is_freemode_active = script.is_active("freemode")
```
- **Parameters:**
- `script_name` (string): The name of the script.
**Example Usage:**
```lua
local is_freemode_active = script.is_active("freemode")
script.is_active(script_name)
```
### `execute_as_script(script_name, func)`
@ -93,29 +105,39 @@ script.execute_as_script(script_name, func)
### `add_patch(script_name, name, pattern, offset, _patch)`
Adds a patch for the specified script.
- **Parameters:**
- `script_name` (string): The name of the script.
- `name` (string): The name of the patch.
- `pattern` (string): Pattern to scan for within the script.
- `offset` (integer): The position within the pattern.
- `_patch` (table): The bytes to be written into the script's bytecode.
**Example Usage:**
```lua
script.add_patch("fm_content_xmas_truck", "Flickering Fix", "56 ? ? 4F ? ? 40 ? 5D ? ? ? 74", 0, {0x2B, 0x00, 0x00})
```
### `start_launcher_script(script_name)`
Tries to start a launcher script. Needs to be called in the fiber pool or a loop.
- **Parameters:**
- `name` (string): The name of the script.
- `script_name` (string): The name of the script.
- `name` (string): The name of the patch.
- `pattern` (string): The pattern to scan for within the script.
- `offset` (integer): The position within the pattern.
- `_patch` (table): The bytes to be written into the script's bytecode.
**Example Usage:**
```lua
script.add_patch(script_name, name, pattern, offset, _patch)
```
### `start_launcher_script(script_name)`
Tries to start a launcher script. Needs to be called in the fiber pool or a loop.
**Example Usage:**
```lua
script.run_in_fiber(function()
script.start_launcher_script("am_hunt_the_beast")
script.start_launcher_script("am_hunt_the_beast")
end)
```
- **Parameters:**
- `script_name` (string): The name of the script.
**Example Usage:**
```lua
script.start_launcher_script(script_name)
```

View File

@ -10,4 +10,5 @@ enum class menu_event
ScriptedGameEventReceived,
MenuUnloaded,
ScriptsReloaded,
Wndproc,
};

View File

@ -1,5 +1,6 @@
#include "gui.hpp"
#include "lua/lua_manager.hpp"
#include "natives.hpp"
#include "renderer/renderer.hpp"
#include "script.hpp"
@ -21,6 +22,7 @@ namespace big
// medium priority
MENU = 0x1000,
VEHICLE_CONTROL,
LUA,
// high priority
INFO_OVERLAY = 0x2000,
@ -53,6 +55,15 @@ namespace big
},
eRenderPriority::MENU);
g_renderer.add_dx_callback(
[] {
g_lua_manager->draw_always_draw_gui();
},
eRenderPriority::LUA);
g_renderer.add_wndproc_callback([](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
g_lua_manager->trigger_event<menu_event::Wndproc>(hwnd, msg, wparam, lparam);
});
g_renderer.add_wndproc_callback([this](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
wndproc(hwnd, msg, wparam, lparam);
});

View File

@ -98,6 +98,18 @@ namespace lua::event
// end)
// ```
// Lua API: Field
// Table: menu_event
// Field: Wndproc: integer
// Event that is triggered when Wndproc is called
// **Example Usage:**
// ```lua
// event.register_handler(menu_event.Wndproc, function (hwnd, msg, wparam, lparam)
// if msg == 132 then return end
// log.debug("hwnd = " .. tostring(hwnd) .. ", msg = " .. tostring(msg) .. ", wparam = " .. tostring(wparam) .. ", lparam = " .. tostring(lparam))
// end)
// ```
// Lua API: Table
// Name: event
// Table for responding to various events. The list of events is available in the menu_event table.
@ -125,8 +137,9 @@ namespace lua::event
{"PlayerMgrShutdown", menu_event::PlayerMgrShutdown},
{"ChatMessageReceived", menu_event::ChatMessageReceived},
{"ScriptedGameEventReceived", menu_event::ScriptedGameEventReceived},
{"MenuUnloaded", menu_event::MenuUnloaded},
{"ScriptsReloaded", menu_event::ScriptsReloaded},
{"MenuUnloaded", menu_event::MenuUnloaded},
{"ScriptsReloaded", menu_event::ScriptsReloaded},
{"Wndproc", menu_event::Wndproc},
});

View File

@ -11,6 +11,13 @@ namespace lua::gui
module->m_independent_gui.push_back(std::move(element));
}
static void add_always_draw_element(lua_State* state, std::unique_ptr<lua::gui::gui_element> element)
{
big::lua_module* module = sol::state_view(state)["!this"];
module->m_always_draw_gui.push_back(std::move(element));
}
static void add_element(lua_State* state, uint32_t hash, std::unique_ptr<lua::gui::gui_element> element)
{
big::lua_module* module = sol::state_view(state)["!this"];
@ -296,6 +303,35 @@ namespace lua::gui
return big::g_gui->is_open();
}
// Lua API: Function
// Table: gui
// Name: toggle
// Param: toggle: boolean
// Opens and closes the gui.
static void toggle(bool toggle)
{
big::g_gui->toggle(toggle);
}
// Lua API: Function
// Table: gui
// Name: mouse_override
// Returns: bool: Returns true if the mouse is overridden.
static bool mouse_override()
{
return big::g_gui->mouse_override();
}
// Lua API: Function
// Table: gui
// Name: override_mouse
// Param: override: boolean
static void override_mouse(bool override)
{
big::g_gui->override_mouse(override);
}
// Lua API: Function
// Table: gui
// Name: add_imgui
@ -323,17 +359,48 @@ namespace lua::gui
return el_ptr;
}
// Lua API: Function
// Table: gui
// Name: add_always_draw_imgui
// Param: imgui_rendering: function: Function that will be called every rendering frame, you can call ImGui functions in it, please check the ImGui.md documentation file for more info.
// Registers a function that will be called every rendering frame, you can call ImGui functions in it, please check the ImGui.md documentation file for more info. This function will be called even when the menu is closed.
// **Example Usage:**
// ```lua
// gui.add_always_draw_imgui(function()
// if ImGui.Begin("My Custom Window") then
// if ImGui.Button("Label") then
// script.run_in_fiber(function(script)
// -- call natives in there
// end)
// end
//
// ImGui.End()
// end
// end)
// ``
static lua::gui::raw_imgui_callback* add_always_draw_imgui(sol::protected_function imgui_rendering, sol::this_state state)
{
auto element = std::make_unique<lua::gui::raw_imgui_callback>(imgui_rendering);
auto el_ptr = element.get();
add_always_draw_element(state, std::move(element));
return el_ptr;
}
void bind(sol::state& state)
{
auto ns = state["gui"].get_or_create<sol::table>();
ns["get_tab"] = get_tab;
ns["add_tab"] = add_tab;
ns["show_success"] = show_success;
ns["show_message"] = show_message;
ns["show_warning"] = show_warning;
ns["show_error"] = show_error;
ns["is_open"] = is_open;
ns["add_imgui"] = add_imgui;
auto ns = state["gui"].get_or_create<sol::table>();
ns["get_tab"] = get_tab;
ns["add_tab"] = add_tab;
ns["show_success"] = show_success;
ns["show_message"] = show_message;
ns["show_warning"] = show_warning;
ns["show_error"] = show_error;
ns["is_open"] = is_open;
ns["toggle"] = toggle;
ns["mouse_override"] = mouse_override;
ns["override_mouse"] = override_mouse;
ns["add_imgui"] = add_imgui;
ns["add_always_draw_imgui"] = add_always_draw_imgui;
auto button_ut = ns.new_usertype<lua::gui::button>("button");
button_ut["get_text"] = &lua::gui::button::get_text;

View File

@ -50,6 +50,8 @@ namespace lua::gui
// Lua API: Function
// Class: tab
// Name: add_tab
// Param: tab_name: string: Name of the tab to add.
// Returns: tab: A tab instance which corresponds to the new tab in the GUI.
// Add a sub tab to this tab.
tab add_tab(const std::string& name, sol::this_state state);

View File

@ -1260,7 +1260,7 @@ namespace lua::imgui
float value[3] = {static_cast<float>(v1), static_cast<float>(v2), static_cast<float>(v3)};
bool used = ImGui::SliderFloat3(label.c_str(), value, v_min, v_max);
sol::as_table_t float3 = sol::as_table(std::vector<float>{value[0], value[1], value[3]});
sol::as_table_t float3 = sol::as_table(std::vector<float>{value[0], value[1], value[2]});
return std::make_tuple(float3, used);
}
@ -1272,7 +1272,7 @@ namespace lua::imgui
float value[3] = {static_cast<float>(v1), static_cast<float>(v2), static_cast<float>(v3)};
bool used = ImGui::SliderFloat3(label.c_str(), value, v_min, v_max, format.c_str());
sol::as_table_t float3 = sol::as_table(std::vector<float>{value[0], value[1], value[3]});
sol::as_table_t float3 = sol::as_table(std::vector<float>{value[0], value[1], value[2]});
return std::make_tuple(float3, used);
}
@ -1284,7 +1284,7 @@ namespace lua::imgui
float value[3] = {static_cast<float>(v1), static_cast<float>(v2), static_cast<float>(v3)};
bool used = ImGui::SliderFloat3(label.c_str(), value, v_min, v_max, format.c_str(), flags);
sol::as_table_t float3 = sol::as_table(std::vector<float>{value[0], value[1], value[3]});
sol::as_table_t float3 = sol::as_table(std::vector<float>{value[0], value[1], value[2]});
return std::make_tuple(float3, used);
}

View File

@ -62,6 +62,11 @@ namespace lua::memory
return m_address;
}
void pointer::set_address(uint64_t address)
{
m_address = address;
}
// Lua API: Table
// Name: memory
// Table containing helper functions related to process memory.
@ -647,6 +652,7 @@ namespace lua::memory
pointer_ut["is_valid"] = &pointer::is_valid;
pointer_ut["deref"] = &pointer::deref;
pointer_ut["get_address"] = &pointer::get_address;
pointer_ut["set_address"] = &pointer::set_address;
auto patch_ut = ns.new_usertype<big::lua_patch>("patch", sol::no_constructor);
patch_ut["apply"] = &big::lua_patch::apply;

View File

@ -58,6 +58,12 @@ namespace lua::memory
// Returns: number: the value stored at the memory address as the specified type.
// Retrieves the value stored at the memory address as the specified type.
// Lua API: Function
// Class: pointer
// Name: get_int
// Returns: number: the value stored at the memory address as the specified type.
// Retrieves the value stored at the memory address as the specified type.
// Lua API: Function
// Class: pointer
// Name: get_dword
@ -94,6 +100,12 @@ namespace lua::memory
// Param: value: number: new value.
// Sets the value at the memory address to the specified value of the given type.
// Lua API: Function
// Class: pointer
// Name: set_int
// Param: value: number: new value.
// Sets the value at the memory address to the specified value of the given type.
// Lua API: Function
// Class: pointer
// Name: set_dword
@ -204,6 +216,13 @@ namespace lua::memory
// Returns: number: The memory address stored in the pointer object as a number.
// Retrieves the memory address stored in the pointer object.
uint64_t get_address() const;
// Lua API: Function
// Class: pointer
// Name: set_address
// Param: address: integer: new address.
// Sets the memory address stored in the pointer object.
void set_address(uint64_t address);
};
// Lua API: Class

View File

@ -188,11 +188,11 @@ namespace lua::network
}
// Lua API: function
// Table: script
// Table: network
// Name: force_script_on_player
// Param: player_idx: integer: Index of the player.
// Param: script_name: string: Name of the script.
// Param: script_name: integer: Instance ID of the script.
// Param: instance_id: integer: Instance ID of the script.
// Forces the given GTA script to be started on a player. Needs to be called in the fiber pool or a loop.
static void force_script_on_player(int player_idx, const std::string& script_name, int instance_id)
{
@ -229,6 +229,7 @@ namespace lua::network
// Table: network
// Name: get_player_rank
// Param: pid: integer: Index of the player.
// Returns: integer: An integer which contains the players rank.
// Call get_player_rank(playerID)
static int get_player_rank(int pid)
{
@ -244,6 +245,7 @@ namespace lua::network
// Table: network
// Name: get_player_rp
// Param: pid: integer: Index of the player.
// Returns: integer: An integer which contains the players rp.
// Call get_player_rp(playerID)
static int get_player_rp(int pid)
{
@ -259,6 +261,7 @@ namespace lua::network
// Table: network
// Name: get_player_money
// Param: pid: integer: Index of the player.
// Returns: integer: An integer which contains the players money.
// Call get_player_money(playerID)
static int get_player_money(int pid)
{
@ -274,6 +277,7 @@ namespace lua::network
// Table: network
// Name: get_player_wallet
// Param: pid: integer: Index of the player.
// Returns: integer: An integer which contains the players wallet.
// Call get_player_wallet(playerID)
static int get_player_wallet(int pid)
{
@ -289,6 +293,7 @@ namespace lua::network
// Table: network
// Name: get_player_bank
// Param: pid: integer: Index of the player.
// Returns: integer: An integer which contains the players bank.
// Call get_player_bank(playerID)
static int get_player_bank(int pid)
{
@ -304,6 +309,7 @@ namespace lua::network
// Table: network
// Name: get_player_language_id
// Param: pid: integer: Index of the player.
// Returns: integer: An integer which contains the players language id.
// Call get_player_language_id(playerID)
static int get_player_language_id(int pid)
{
@ -319,6 +325,7 @@ namespace lua::network
// Table: network
// Name: get_player_language_name
// Param: pid: integer: Index of the player.
// Returns: string: A string which contains the players language name.
// Call get_player_language_name(playerID)
static std::string get_player_language_name(int pid)
{

View File

@ -188,8 +188,8 @@ namespace lua::script
// Param: script_name: string: The name of the script.
// Param: name: string: The name of the patch.
// Param: pattern: string: The pattern to scan for within the script.
// Param offset: integer: The position within the pattern.
// Param _patch: table: The bytes to be written into the script's bytecode.
// Param: offset: integer: The position within the pattern.
// Param: _patch: table: The bytes to be written into the script's bytecode.
// Adds a patch for the specified script.
// **Example Usage:**
// ```lua

View File

@ -11,7 +11,7 @@ namespace lua::vector
// Param: x: float: x component of the vector.
// Param: y: float: y component of the vector.
// Param: z: float: z component of the vector.
// Returns a vector that contains the x, y, and z values.
// Returns: vec3: a vector that contains the x, y, and z values.
// Lua API: Field
// Class: vec3

View File

@ -150,6 +150,19 @@ namespace big
}
}
void lua_manager::draw_always_draw_gui()
{
std::lock_guard guard(m_module_lock);
for (const auto& module : m_modules)
{
for (const auto& element : module->m_always_draw_gui)
{
element->draw();
}
}
}
void lua_manager::draw_gui(rage::joaat_t tab_hash)
{
std::lock_guard guard(m_module_lock);
@ -303,6 +316,10 @@ namespace big
return {};
}
// Some scripts are library scripts, they do nothing on their own and are intended to be used with require, they take up space in the script list for no reason.
if (std::filesystem::relative(module_path.parent_path(), m_scripts_folder.get_path()).wstring().contains(L"includes"))
return {};
const auto module_name = module_path.filename().string();
const auto id = rage::joaat(module_name);

View File

@ -48,6 +48,7 @@ namespace big
bool has_gui_to_draw(rage::joaat_t tab_hash);
void draw_independent_gui();
void draw_always_draw_gui();
void draw_gui(rage::joaat_t tab_hash);
bool dynamic_hook_pre_callbacks(const uintptr_t target_func_ptr, lua::memory::type_info_t return_type, lua::memory::runtime_func_t::return_value_t* return_value, std::vector<lua::memory::type_info_t> param_types, const lua::memory::runtime_func_t::parameters_t* params, const uint8_t param_count);

View File

@ -34,6 +34,7 @@ namespace big
std::unordered_map<big::tabs, std::vector<big::tabs>> m_tab_to_sub_tabs;
std::vector<std::unique_ptr<lua::gui::gui_element>> m_independent_gui;
std::vector<std::unique_ptr<lua::gui::gui_element>> m_always_draw_gui;
std::unordered_map<rage::joaat_t, std::vector<std::unique_ptr<lua::gui::gui_element>>> m_gui;
std::unordered_map<menu_event, std::vector<sol::protected_function>> m_event_callbacks;
std::vector<void*> m_allocated_memory;