This commit is contained in:
Quentin
2023-07-02 00:59:02 +02:00
committed by GitHub
parent f96356960a
commit 3bdd0796f4
56 changed files with 2804 additions and 24 deletions

View File

@ -0,0 +1,20 @@
# Table: Global Table
Custom fields, functions, etc added to The Lua [Global Table](https://www.lua.org/pil/15.4.html).
## Functions (1)
### `joaat(str)`
- **Parameters:**
- `str` (string): The string that needs to be joaat hashed.
- **Returns:**
- `integer`: The joaat hashed input string.
**Exemple Usage:**
```lua
integer = joaat(str)
```

View File

@ -0,0 +1,34 @@
# Table: command
Table for calling menu commands.
## Functions (2)
### `call(command_name, _args)`
Call a menu command.
- **Parameters:**
- `command_name` (string): The name of the command that will be called.
- `_args` (table): Optional. List of arguments for the command.
**Exemple Usage:**
```lua
command.call(command_name, _args)
```
### `call_player(player_idx, command_name, _args)`
Call a menu command on a given player.
- **Parameters:**
- `player_idx` (integer): Index of the player on which the menu command will be executed.
- `command_name` (string): The name of the command that will be called.
- `_args` (table): Optional. List of arguments for the command.
**Exemple Usage:**
```lua
command.call_player(player_idx, command_name, _args)
```

20
docs/lua/tables/event.md Normal file
View File

@ -0,0 +1,20 @@
# Table: event
Table for responding to various events. The list of events is available in the menu_event table.
## Functions (1)
### `register_handler(menu_event, func)`
Register a function that will be called each time the corresponding menu_event is triggered.
- **Parameters:**
- `menu_event` (menu_event): The menu_event that we want to respond to.
- `func` (function): The function that will be called.
**Exemple Usage:**
```lua
event.register_handler(menu_event, func)
```

106
docs/lua/tables/globals.md Normal file
View File

@ -0,0 +1,106 @@
# Table: globals
Table containing functions for manipulating gta script globals.
## Functions (7)
### `get_int(global)`
Retrieves an int global value.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `integer`: value of the global
**Exemple Usage:**
```lua
integer = globals.get_int(global)
```
### `get_float(global)`
Retrieves a float global value.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `float`: value of the global
**Exemple Usage:**
```lua
float = globals.get_float(global)
```
### `get_string(global)`
Retrieves a string global value.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `string`: value of the global
**Exemple Usage:**
```lua
string = globals.get_string(global)
```
### `set_int(global, val)`
Sets an int global value.
- **Parameters:**
- `global` (integer): index of the global
- `val` (integer): new value for the global
**Exemple Usage:**
```lua
globals.set_int(global, val)
```
### `set_float(global, val)`
Sets a float global value.
- **Parameters:**
- `global` (integer): index of the global
- `val` (float): new value for the global
**Exemple Usage:**
```lua
globals.set_float(global, val)
```
### `set_string(global, str)`
Sets a string global value.
- **Parameters:**
- `global` (integer): index of the global
- `str` (string): new value for the global
**Exemple Usage:**
```lua
globals.set_string(global, str)
```
### `get_pointer(global)`
Retrieves a pointer global.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `pointer`: value of the global
**Exemple Usage:**
```lua
pointer = globals.get_pointer(global)
```

69
docs/lua/tables/gui.md Normal file
View File

@ -0,0 +1,69 @@
# Table: gui
Table containing functions for modifying the menu GUI.
## Functions (5)
### `get_tab(tab_name)`
- **Parameters:**
- `tab_name` (string): Name of the tab to get.
- **Returns:**
- `tab`: A tab instance which corresponds to the tab in the GUI.
**Exemple Usage:**
```lua
tab = gui.get_tab(tab_name)
```
### `show_message(title, message)`
Shows a message to the user with the given title and message.
- **Parameters:**
- `title` (string)
- `message` (string)
**Exemple Usage:**
```lua
gui.show_message(title, message)
```
### `show_warning(title, message)`
Shows a warning to the user with the given title and message.
- **Parameters:**
- `title` (string)
- `message` (string)
**Exemple Usage:**
```lua
gui.show_warning(title, message)
```
### `show_error(title, message)`
Shows an error to the user with the given title and message.
- **Parameters:**
- `title` (string)
- `message` (string)
**Exemple Usage:**
```lua
gui.show_error(title, message)
```
### `is_open()`
- **Returns:**
- `bool`: Returns true if the GUI is open.
**Exemple Usage:**
```lua
bool = gui.is_open()
```

73
docs/lua/tables/locals.md Normal file
View File

@ -0,0 +1,73 @@
# Table: locals
Table for manipulating GTA scripts locals.
## Functions (5)
### `get_int(script, index)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- **Returns:**
- `integer`: The value of the given local.
**Exemple Usage:**
```lua
integer = locals.get_int(script, index)
```
### `get_float(script, index)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- **Returns:**
- `float`: The value of the given local.
**Exemple Usage:**
```lua
float = locals.get_float(script, index)
```
### `set_int(script, index, val)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- `val` (integer): The new value of the given local.
**Exemple Usage:**
```lua
locals.set_int(script, index, val)
```
### `set_float(script, index, val)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- `val` (float): The new value of the given local.
**Exemple Usage:**
```lua
locals.set_float(script, index, val)
```
### `get_pointer(script, index)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- **Returns:**
- `pointer`: The pointer to the given local.
**Exemple Usage:**
```lua
pointer = locals.get_pointer(script, index)
```

43
docs/lua/tables/log.md Normal file
View File

@ -0,0 +1,43 @@
# Table: log
Table containing functions for printing to console / log file.
## Functions (3)
### `info(data)`
Logs an informational message.
- **Parameters:**
- `data` (string)
**Exemple Usage:**
```lua
log.info(data)
```
### `warning(data)`
Logs a warning message.
- **Parameters:**
- `data` (string)
**Exemple Usage:**
```lua
log.warning(data)
```
### `debug(data)`
Logs a debug message.
- **Parameters:**
- `data` (string)
**Exemple Usage:**
```lua
log.debug(data)
```

71
docs/lua/tables/memory.md Normal file
View File

@ -0,0 +1,71 @@
# Table: memory
Table containing helper functions related to process memory.
## Functions (5)
### `scan_pattern(pattern)`
Scans the specified memory pattern within the "GTA5.exe" module and returns a pointer to the found address.
- **Parameters:**
- `pattern` (string): byte pattern (IDA format)
- **Returns:**
- `pointer`: A pointer to the found address.
**Exemple Usage:**
```lua
pointer = memory.scan_pattern(pattern)
```
### `handle_to_ptr(entity)`
- **Parameters:**
- `entity` (number): script game entity handle
- **Returns:**
- `pointer`: A rage::CDynamicEntity pointer to the script game entity handle
**Exemple Usage:**
```lua
pointer = memory.handle_to_ptr(entity)
```
### `ptr_to_handle(mem_addr)`
- **Parameters:**
- `mem_addr` (pointer): A rage::CDynamicEntity pointer.
- **Returns:**
- `number`: The script game entity handle linked to the given rage::CDynamicEntity pointer.
**Exemple Usage:**
```lua
number = memory.ptr_to_handle(mem_addr)
```
### `allocate(size)`
- **Parameters:**
- `size` (integer): The number of bytes to allocate on the heap.
- **Returns:**
- `pointer`: A pointer to the newly allocated memory.
**Exemple Usage:**
```lua
pointer = memory.allocate(size)
```
### `free(ptr)`
- **Parameters:**
- `ptr` (pointer): The pointer that must be freed.
**Exemple Usage:**
```lua
memory.free(ptr)
```

View File

@ -0,0 +1,81 @@
# Table: menu_event
Table containing all possible events to which you can respond.
## Fields (6)
### `PlayerLeave`
Event that is triggered when a player leave the game session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerLeave, function (player_name)
log.info(player_name)
end)
```
- Type: `integer`
### `PlayerJoin`
Event that is triggered when a player join the game session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerJoin, function (player_name, player_id)
log.info(player_name)
log.info(player_id)
end)
```
- Type: `integer`
### `PlayerMgrInit`
Event that is triggered when the player manager initialize. Usually called when we are joining a session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerMgrInit, function ()
log.info("Player manager inited, we just joined a session.")
end)
```
- Type: `integer`
### `PlayerMgrShutdown`
Event that is triggered when the player manager shutdown. Usually called when we are leaving a session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerMgrShutdown, function ()
log.info("Player manager inited, we just joined a session.")
end)
```
- Type: `integer`
### `ChatMessageReceived`
Event that is triggered when we receive a in-game chat message.
**Exemple Usage:**
```lua
event.register_handler(menu_event.ChatMessageReceived, function (player_id, chat_message)
log.info(player_id)
log.info(chat_message)
end)
```
- Type: `integer`
### `ScriptedGameEventReceived`
Event that is triggered when we receive a scripted game event.
**Exemple Usage:**
```lua
event.register_handler(menu_event.ScriptedGameEventReceived, function (player_id, script_event_args)
log.info(player_id)
log.info(script_event_args)
end)
```
- Type: `integer`

132
docs/lua/tables/network.md Normal file
View File

@ -0,0 +1,132 @@
# Table: network
Table containing helper functions for network related features.
## Functions (10)
### `trigger_script_event(bitset, _args)`
Call trigger_script_event (TSE)
- **Parameters:**
- `bitset` (integer)
- `_args` (table)
**Exemple Usage:**
```lua
network.trigger_script_event(bitset, _args)
```
### `give_pickup_rewards(player, reward)`
Give the given pickup reward to the given player.
- **Parameters:**
- `player` (integer): Index of the player.
- `reward` (integer): Index of the reward pickup.
**Exemple Usage:**
```lua
network.give_pickup_rewards(player, reward)
```
### `set_player_coords(player_idx, x, y, z)`
Teleport the given player to the given position.
- **Parameters:**
- `player_idx` (integer): Index of the player.
- `x` (float): New x position.
- `y` (float): New y position.
- `z` (float): New z position.
**Exemple Usage:**
```lua
network.set_player_coords(player_idx, x, y, z)
```
### `set_all_player_coords(x, y, z)`
Teleport all players to the given position.
- **Parameters:**
- `x` (float): New x position.
- `y` (float): New y position.
- `z` (float): New z position.
**Exemple Usage:**
```lua
network.set_all_player_coords(x, y, z)
```
### `get_selected_player()`
- **Returns:**
- `integer`: Returns the index of the currently selected player in the GUI.
**Exemple Usage:**
```lua
integer = network.get_selected_player()
```
### `get_selected_database_player_rockstar_id()`
- **Returns:**
- `integer`: Returns the rockstar id of the currently selected player in the GUI.
**Exemple Usage:**
```lua
integer = network.get_selected_database_player_rockstar_id()
```
### `flag_player_as_modder(player_idx)`
Flags the given player as a modder in our local database.
- **Parameters:**
- `player_idx` (integer): Index of the player.
**Exemple Usage:**
```lua
network.flag_player_as_modder(player_idx)
```
### `is_player_flagged_as_modder(player_idx)`
- **Parameters:**
- `player_idx` (integer): Index of the player.
- **Returns:**
- `boolean`: Returns true if the given player is flagged as a modder.
**Exemple Usage:**
```lua
boolean = network.is_player_flagged_as_modder(player_idx)
```
### `force_script_host(script_name)`
Try to force ourself to be host for the given GTA Script.
- **Parameters:**
- `script_name` (string): Name of the script
**Exemple Usage:**
```lua
network.force_script_host(script_name)
```
### `send_chat_message(msg, team_only)`
Sends a message to the in game chat.
- **Parameters:**
- `msg` (string): Message to be sent.
- `team_only` (boolean): Should be true if the msg should only be sent to our team.
**Exemple Usage:**
```lua
network.send_chat_message(msg, team_only)
```

53
docs/lua/tables/script.md Normal file
View File

@ -0,0 +1,53 @@
# Table: script
Table containing helper functions related to gta scripts.
## Functions (4)
### `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.
**Exemple Usage:**
```lua
script.register_looped(name, func)
```
### `run_in_fiber(func)`
Executes a function inside the fiber pool, you can call natives inside it.
- **Parameters:**
- `func` (function): function that will be executed once in the fiber pool, you can call natives inside it.
**Exemple Usage:**
```lua
script.run_in_fiber(func)
```
### `yield()`
Yield execution.
**Exemple Usage:**
```lua
script.yield()
```
### `sleep(ms)`
Sleep for the given amount of time, time is in milliseconds.
- **Parameters:**
- `ms` (integer): The amount of time in milliseconds that we will sleep for.
**Exemple Usage:**
```lua
script.sleep(ms)
```

View File

@ -0,0 +1,79 @@
# Table: tunables
Table for manipulating gta tunables.
## Functions (6)
### `get_int(tunable_name)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- **Returns:**
- `integer`: The value of the given tunable.
**Exemple Usage:**
```lua
integer = tunables.get_int(tunable_name)
```
### `get_float(tunable_name)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- **Returns:**
- `float`: The value of the given tunable.
**Exemple Usage:**
```lua
float = tunables.get_float(tunable_name)
```
### `get_bool(tunable_name)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- **Returns:**
- `boolean`: The value of the given tunable.
**Exemple Usage:**
```lua
boolean = tunables.get_bool(tunable_name)
```
### `set_int(tunable_name, val)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- `val` (integer): The new value of the given tunable.
**Exemple Usage:**
```lua
tunables.set_int(tunable_name, val)
```
### `set_float(tunable_name, val)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- `val` (float): The new value of the given tunable.
**Exemple Usage:**
```lua
tunables.set_float(tunable_name, val)
```
### `set_bool(tunable_name, val)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- `val` (boolean): The new value of the given tunable.
**Exemple Usage:**
```lua
tunables.set_bool(tunable_name, val)
```