Lua Documentation
Globals
string SCRIPT_NAME
The name of your script, e.g., "Example Script".
Example:
notification.send(SCRIPT_NAME .. " Has loaded")
string SCRIPT_FULLNAME
The full name of your script, e.g., "Example Script.lua".
Example:
notification.send(SCRIPT_FULLNAME .. " Has loaded")
string SCRIPT_PATH
The full path to your script, e.g., "C:\Users\Jhon Wick\AppData\Roaming\SaturnV\Lua Scripts\Example Script.lua".
Example:
local my_root = menu.my_root()
menu.action(my_root, "Show Script Path", "Shows the path to your script", function()
notification.send(SCRIPT_PATH)
end)
bool IS_PREMIUM_USER
Returns if the user is using premium.
string VERSION
Returns the version as 11.5.5
Gui Functions
int menu.my_root()
This is the base of your GUI.
Example:
local my_root = menu.my_root()
int menu.list(int parent, string name, string desc)
Example:
local my_root = menu.my_root()
local my_list = menu.list(my_root, "Example List", "Hello guys")
int menu.action(int parent, string name, string desc, function callback)
Example:
local my_root = menu.my_root()
local my_action = menu.action(my_root, "Click Me", "", function()
notification.show("Hello")
end)
int menu.toggle(int parent, string name, string desc, bool default, bool loop, function callback)
"Default" is the standard state of the toggle. Loop is wether to run every frame.
Example:
local toggled = false
local my_root = menu.my_root()
local my_toggle = menu.toggle(my_root, "Toggle Me", "", false, false, function(state)
toggled = state
end)
int menu.slider(int parent, string name, string desc, int minval, int maxval, int increment, int defaultval, bool isSliderClick, function callback)
if isSliderClick is set to false, then when this slider is clicked the user will be prompted to enter a value.
Example:
local my_root = menu.my_root()
local my_slider = menu.slider(my_root, "Example Slider", "", 0, 100, 1, 0, false, function(value)
notification.show("You Selected " .. value)
end)
int menu.slider_float(int parent, string name, string desc, float minval, float maxval, float increment, float defaultval, bool isSliderClick, function callback)
Slider floats work like sliders but support decimal values.
Example:
local my_root = menu.my_root()
local my_sliderfloat = menu.slider_float(my_root, "Example Slider Float", "", 0.0, 100.0, 0.5, 0.0, false, function(value)
notification.show("You Selected " .. value)
end)
int menu.text_slider(int parent, string name, string desc, int defaultindex, {Options table}, function callback)
Works like sliders but displays texts instead from a table.
Example:
local my_root = menu.my_root()
local my_text_slider = menu.text_slider(my_root, "Example Text Slider", 0, {"First", "Second"}, function(index)
if index == 0 then
notification.show("You selected 'First'")
else if index == 1 then
notification.show("You selected 'Second'")
end
end
end)
int menu.list_select(int parent, string name, string desc, {Actions table}, function callback)
Displays actions inside of a list. When that action is clicked it will return its index, eg the first action will return 0.
Example:
local my_root = menu.my_root()
local my_list_select = menu.list_select(my_root, "Example List Select", 0, {"First", "Second"}, function(index)
if index == 0 then
notification.show("You selected 'First'")
else if index == 1 then
notification.show("You selected 'Second'")
end
end
end)
int menu.text_input(int parent, string name, string desc, function callback)
Allows the user to input a string value, returns what they input.
Example:
local my_root = menu.my_root()
local my_text_input = menu.text_input(my_root, "Example Text Input", function(result)
notification.show("You input " .. result)
end)
int menu.place_holder(int parent, string name)
Sort of like a header that cant be selected.
Example:
local my_root = menu.my_root()
local my_place_holder = menu.place_holder(my_root, "Example Place Holder")
int menu.hyper_link(int parent, string name, string desc, string url)
When clicked will take the user to the given url.
Example:
local my_root = menu.my_root()
local my_hyper_link = menu.hyper_link(my_root, "Youtube", "Takes you to youtube", "https://youtube.com")
int menu.read_only(int parent, string name, string desc)
Read-only items display information that can be copied but not interacted with.
Example:
local my_root = menu.my_root()
local my_read_only = menu.read_only(my_root, "Example Read Only", "Hi")
Node Functions
void node.rename(int node, string name)
Renames the node to the given name.
Example:
local my_root = menu.my_root()
local test_node = menu.read_only(my_root, "To Be Changed", "")
node.rename(test_node, "Hello")
void node.rename_desc(int node, string desc)
Changes the description shown for the node.
Example:
local my_root = menu.my_root()
local test_node = menu.read_only(my_root, "To Be Changed", "To Be Changed Aswell")
node.rename_desc(test_node, "Hello")
void node.parent(int node, int parent)
Moves the node into a new parent node.
Example:
local my_root = menu.my_root()
local test_list = menu.list(my_root, "Open Me", "")
local test_node = menu.read_only(my_root, "To Be Changed", "")
node.parent(test_node, test_list)
void node.delete(int node)
Deletes the node and all of its children.
Example:
local my_root = menu.my_root()
local test_node = menu.read_only(my_root, "To Be Changed", "")
node.delete(test_node)
bool node.exists(int node)
Returns whether the node still exists.
Example:
local my_root = menu.my_root()
local test_node = menu.read_only(my_root, "To Be Changed", "")
if node.exists(test_node, test_list) then
notification.show("Node Exists")
end
Clipboard Functions
void user_clipboard.set(string text)
Sets the user's clipboard to the given text.
Example:
user_clipboard.set("SaturnV")
string user_clipboard.read()
Returns the text currently stored in the user's clipboard.
Example:
notification.show(user_clipboard.read())
Entity Functions
table <int, int> entity.get_all_objects()
Returns a table containing all object handles currently loaded in the world. Objects include props such as signs, trashcans, seats, etc.
Example:
local table1 = entity.get_all_objects()
local size = #table1
for i = 1, size do
local object = table1[i]
-- Do something with the objects
end
table <int, int> entity.get_all_pickups()
Returns a table containing all pickup handles currently loaded in the world. Pickups include items such as weapons or collectibles.
Example:
local table1 = entity.get_all_pickups()
local size = #table1
for i = 1, size do
local pickup = table1[i]
-- Do something with the pickups
end
table <int, int> entity.get_all_peds(bool includeplayer)
Returns a table containing all ped handles in the world. if includeplayer is set to true the players ped will be included in the table.
Example:
local table1 = entity.get_all_peds(true)
local size = #table1
for i = 1, size do
local ped = table1[i]
-- Do something with the peds
end
table <int, int> entity.get_all_vehicles(bool includeplayersvehicle)
Returns a table of all vehicle handles.
Example:
local table1 = entity.get_all_vehicles(true)
local size = #table1
for i = 1, size do
local vehicle = table1[i]
-- Do something with the vehicles
end
int entity.delete( int entityhandle)
Deletes an entity, you dont need to set it to a mission entity beforehand.
Example:
local vehiclehandle = PED.GET_VEHICLE_PED_IS_IN(PLAYER.PLAYER_PED_ID(), false) -- vehiclehandle will initially be set to the handle like 29292323 if the vehicle exists
if ENTITY.DOES_ENTITY_EXIST(vehiclehandle)
vehiclehandle = entity.delete(vehiclehandle) -- This will set your handle to 0, you can do this manually but this is quicker
end
Memory Functions
int memory.scan(string pattern)
Scans memory for a pattern and returns the address of the first match.
int memory.read_int(int address)
Reads a 32-bit signed integer from memory.
float memory.read_float(int address)
Reads a floating-point value from memory.
uint memory.read_uint(int address)
Reads a 32-bit unsigned integer from memory.
long memory.read_long(int address)
Reads a 64-bit signed integer from memory.
short memory.read_short(int address)
Reads a 16-bit signed integer from memory.
ushort memory.read_ushort(int address)
Reads a 16-bit unsigned integer from memory.
void memory.write_int(int address)
Writes a 32-bit signed integer to memory.
void memory.write_float(int address)
Writes a floating-point value to memory.
void memory.write_uint(int address)
Writes a 32-bit unsigned integer to memory.
void memory.write_long(int address)
Writes a 64-bit signed integer to memory.
void memory.write_short(int address)
Writes a 16-bit signed integer to memory.
void memory.write_ushort(int address)
Writes a 16-bit unsigned integer to memory.
Util Functions
int util.joaat(string name)
Calculates the hash key for a given model or string.
Example:
cop_hash = util.joaat("S_M_Y_COP_01")
void util.load_model(int model)
Loads a model into memory so it can be used in-game.
Example:
util.load_model(util.joaat("S_M_Y_COP_01"))
local cop = PED.CREATE_PED(6, util.joaat("S_M_Y_COP_01"), 123, 456, 789, 50, false, true)
STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(util.joaat("S_M_Y_COP_01"))
-- Do something with the ped/cop you made
Notification Functions
void notification.show(string message)
Example:
notification.show("Hello")
void notification.log(string info, bool includeDate)
Prints info to the log. If includedate is false it wont show the timestamp that the log was sent.
Example:
notification.log("Hello from the exampe script", true)
void notification.log_error(string info)
Prints info in the error format to the log
Example:
notification.log_error("An error occured")
Filesystem Functions
void filesystem.create_dir(string path)
Creates a directory/folder at the path given
bool filesystem.exists(string path)
Returns if the file at the path exists or not
bool filesystem.is_regular_file(string path)
bool filesystem.is_dir(string path)
string filesystem.lua_scripts_dir()
Returns the directory of the Lua Scripts directory