Skip to content

Game

Reference for the game API.

Functions

game.is_session_free_roam

If you're in a free roam session (i.e, not in a mission).

lua
function game.is_session_free_roam(): bool

game.in_game

If you're loaded into a game.

lua
function game.in_game(): bool

game.net_obj_from_id

Net object memory address retrieved via an entity net id.

lua
---@param net_id integer
function game.net_obj_from_id(net_id): memory_address

game.net_obj_from_entity

Net object memory address retrieved via an entity handle.

lua
---@param entity integer
function game.net_obj_from_entity(entity): memory_address

game.update_net_obj_owner

Updates the owner of an entity.

lua
---@param entity integer
---@param new_owner_player_id integer
function game.update_net_obj_owner(entity, new_owner_player_id): bool

game.entity_from_guid

Entity memory address retrieved via an entity handle.

lua
---@param entity integer
function game.entity_from_guid(entity): memory_address

game.guid_from_entity

Entity handle retrieved via an entity address.

lua
---@param entity integer|memory_address
function game.guid_from_entity(entity): integer

game.send_friend_request

Sends a friend request to an account.

lua
---@param rockstar_id integer
function game.send_friend_request(rockstar_id): nil

game.is_sc_ui_showing

If the Social Club UI is open.

lua
function game.is_sc_ui_showing(): bool

game.is_transaction_busy

If there's an active basket transaction processing.

lua
function game.is_transaction_busy(): bool

game.sync_tree

Sync tree memory address retrieved via a net object type (0-13).

lua
---@param type net_object|integer
function game.sync_tree(type): memory_address

game.state

The current state of the game.

lua
function game.state(): integer

game.resolution

The game window resolution.

lua
function game.resolution(): vec2

game.delta

The game delta.

lua
function game.delta(): number

game.host

The session host as a player.

lua
function game.host(): player

game.basket_transaction

Processes a basket transaction.

lua
---@param category integer
---@param action integer
---@param destination integer
---@param items table[] { id, extra_inventory_id, price, stat, quantity }
function game.basket_transaction(category, action, destination, items): nil

game.invite_rockstar_id

Invites a player to your session.

lua
---@param rockstar_id integer|integer[]
function game.invite_rockstar_id(rockstar_id): nil

game.get_model_info

Model info memory address retrieved via the model.

lua
---@param model string|integer 
function game.get_model_info(model): memory_address

game.is_ptfx_playing_at_coords

Checks if a particle effect is playing at a position.

lua
---@param asset string 
---@param effect string 
---@param coords vec3 
---@param radius? number
function game.is_ptfx_playing_at_coords(asset, effect, coords, radius?): bool

game.network_unregister_entity

Force deletes an entity on the network.

lua
---@param handle integer 
---@param locally? boolean
function game.network_unregister_entity(handle, locally?): nil

game.local_unregister_entity

Force deletes an entity locally.

lua
---@param handle integer 
function game.local_unregister_entity(handle): nil

game.version

Returns the game version (e.g., "1013.34").

lua
function game.version(): string

game.online_version

Returns the online version (e.g., "1.72").

lua
function game.online_version(): string

game.build

Returns "Legacy" or "Enhanced".

lua
function game.build(): string

Examples

lua
-- add $15M to the bank (2 for bank, 1 for wallet) !! detected !!
game.basket_transaction(joaat('CATEGORY_SERVICE_WITH_THRESHOLD'), joaat('NET_SHOP_ACTION_EARN'), 2, { { joaat('SERVICE_EARN_BEND_JOB'), 1, 15000000, 0, 1 } })

-- print your ped address
print('CPed: ' .. tostring(game.entity_from_guid(players.me().ped)).value)

-- check for a particle at a position
local is_playing = game.is_ptfx_playing_at_coords('scr_indep_fireworks', 'scr_indep_firework_fountain', vec3(1178.653, 2666.179, 37.881), 2.0)