---@meta gampeon -- GAMPEON Lua API, generated from api/gampeon-api.json. Do not edit by hand. -- Version 0.10.0 (preview). Docs: https://create.gampeon.com/docs/scripting/reference/ ---Returned by AddEventHandler and RegisterNetEvent. ---@class EventHandle ---@field key integer Internal ID of the handler. ---@field name string Name of the event. ---Read-only vector with 2 components. Supports + - * /, # (length) and swizzles like v.xy. ---@class vector2 ---@field x number x component. ---@field y number y component. ---Read-only vector with 3 components. Supports + - * /, # (length) and swizzles like v.xy. ---@class vector3 ---@field x number x component. ---@field y number y component. ---@field z number z component. ---Read-only vector with 4 components. Supports + - * /, # (length) and swizzles like v.xy. ---@class vector4 ---@field x number x component. ---@field y number y component. ---@field z number z component. ---@field w number w component. ---Result that arrives later. Use p:resolve(...), p:reject(err), p:next(onResolved, onRejected) and Citizen.Await(p). ---@class promise ---@field resolve fun(self: promise, ...: any) Fulfil the promise with values. ---@field reject fun(self: promise, err: any) Fail the promise. ---@field next fun(self: promise, onResolved?: function, onRejected?: function): promise Run a function when it is done. ---ID of the player who sent the network event that is being handled. ---Only set while a network event handler runs; nil otherwise. Copy it into a local variable before calling Wait, because another event can change it. ---@type integer? source = nil Citizen = {} Gampeon = {} MySQL = {} json = {} promise = {} ---Run a function whenever an event fires. --- ---Handlers run for local events from TriggerEvent and, once the event is registered with RegisterNetEvent, for events from the other side. Each handler runs in its own thread, so it may call Wait. --- ---```lua ---AddEventHandler('myshop:opened', function(shopId) --- print('Shop opened: ' .. shopId) ---end) ---``` ---@param eventName string Name of the event, for example "myshop:buy". Prefix it with your resource name to avoid clashes. ---@param handler fun(...: any) Called with the arguments of the event. ---@return EventHandle # Pass it to RemoveEventHandler to remove the handler again. function AddEventHandler(eventName, handler) end ---Remove a handler added with AddEventHandler. --- ---```lua ---local h = AddEventHandler('tick', function() end) ---RemoveEventHandler(h) ---``` ---@param handle EventHandle Value returned by AddEventHandler or RegisterNetEvent. function RemoveEventHandler(handle) end ---Allow an event to arrive from the other side (client to server or server to client). --- ---Without this call, events from the network never reach your handlers. On the server, treat every network event as untrusted input: check `source` and every argument, because players can send any values. --- ---```lua ---RegisterNetEvent('myshop:buy', function(itemId) --- local player = source --- if type(itemId) ~= 'string' then return end --- -- check that the player may buy the item, then give it ---end) ---``` ---@param eventName string Name of the event. ---@param handler? fun(...: any) Optional handler, same as calling AddEventHandler afterwards. ---@return EventHandle? # The handle when a handler was given, otherwise nothing. function RegisterNetEvent(eventName, handler) end ---Old name of RegisterNetEvent, kept for ported FiveM scripts. ---@deprecated Use RegisterNetEvent. ---@param eventName string Name of the event. ---@param handler? fun(...: any) Optional handler. ---@return EventHandle? # The handle when a handler was given. function RegisterServerEvent(eventName, handler) end ---Fire an event for all resources on the same side. --- ---Handlers of every running resource on this side receive the event. It never leaves the machine. --- ---```lua ---TriggerEvent('myshop:opened', 'downtown') --- ----- callback pattern from ESX ---TriggerEvent('myframework:getSharedObject', function(obj) Framework = obj end) ---``` ---@param eventName string Name of the event. ---@param ... any Arguments. Values are copied: tables, strings, numbers, booleans and nil. Functions arrive as callable functions that run in the resource that passed them. function TriggerEvent(eventName, ...) end ---Cancel the event whose handler is running. --- ---Other handlers still run. The code that fired the event checks WasEventCanceled right after TriggerEvent and can skip its default action. Only works before the handler calls Wait. --- ---```lua ---AddEventHandler('chatMessage', function(source, name, message) --- if message:find('badword') then --- CancelEvent() --- end ---end) ---``` function CancelEvent() end ---Check if a handler canceled the last event fired with TriggerEvent. --- ---```lua ---TriggerEvent('myshop:beforeBuy', source, item) ---if WasEventCanceled() then --- return ---end ---``` ---@return boolean # true if a handler called CancelEvent. function WasEventCanceled() end ---Send an event from the client to the server. --- ---The server only receives it if a resource registered it with RegisterNetEvent. The server sees the sending player in `source`. --- ---Available on the client only. --- ---```lua ---TriggerServerEvent('myshop:buy', 'water') ---``` ---@param eventName string Name of the event. ---@param ... any Arguments, copied like in TriggerEvent. Functions do not travel over the network and arrive as nil. function TriggerServerEvent(eventName, ...) end ---Send an event from the server to one player or to everyone. --- ---Available on the server only. --- ---```lua ---TriggerClientEvent('myshop:bought', source, 'water') ---TriggerClientEvent('chat:announce', -1, 'Server restart in 5 minutes') ---``` ---@param eventName string Name of the event. ---@param target integer Player ID, or -1 for all players. ---@param ... any Arguments, copied like in TriggerEvent. Functions do not travel over the network and arrive as nil. function TriggerClientEvent(eventName, target, ...) end ---Run a function as its own thread, starting with the next tick. --- ---Use threads for loops that run over time. Always call Wait inside a loop, otherwise the script exceeds its instruction budget and is stopped. --- ---```lua ---CreateThread(function() --- while true do --- Wait(1000) --- print('one second passed') --- end ---end) ---``` ---@param fn fun() Body of the thread. function CreateThread(fn) end ---Pause the current thread. --- ---Only works inside a thread, event handler or timeout. The rest of the game keeps running. --- ---```lua ---Wait(500) ---``` ---@param ms? integer Milliseconds to wait. 0 or nothing waits until the next tick. function Wait(ms) end ---Run a function once after a delay. --- ---```lua ---SetTimeout(5000, function() --- print('five seconds later') ---end) ---``` ---@param ms integer Delay in milliseconds. ---@param fn fun() Function to run. It runs as a thread and may call Wait. function SetTimeout(ms, fn) end ---Same as CreateThread. Kept for ported FiveM scripts. ---@param fn fun() Body of the thread. function Citizen.CreateThread(fn) end ---Same as Wait. Kept for ported FiveM scripts. ---@param ms? integer Milliseconds to wait. function Citizen.Wait(ms) end ---Same as SetTimeout. Kept for ported FiveM scripts. ---@param ms integer Delay in milliseconds. ---@param fn fun() Function to run. function Citizen.SetTimeout(ms, fn) end ---Name of the resource this script belongs to. --- ---```lua ---print('Started ' .. GetCurrentResourceName()) ---``` ---@return string # Folder name of the resource. function GetCurrentResourceName() end ---Milliseconds since the runtime started. Use it to measure time. --- ---```lua ---local started = GetGameTimer() ---Wait(250) ---print(GetGameTimer() - started) ---``` ---@return integer # Milliseconds. function GetGameTimer() end ---Hash of a name, for example of a model name. Same numbers as in FiveM. --- ---Jenkins one-at-a-time hash of the lower-case text as a signed 32-bit number. Functions that take a model accept the hash or the name itself. --- ---```lua ---local model = GetHashKey('prop_cube') ---print(IsModelValid(model)) ---``` ---@param name string Text to hash, for example "prop_cube". Upper and lower case give the same hash. ---@return integer # Hash between -2147483648 and 2147483647. function GetHashKey(name) end ---True on the server, false on the client. --- ---Useful in shared scripts that run on both sides. --- ---```lua ---if IsDuplicityVersion() then --- print('running on the server') ---end ---``` ---@return boolean # true on the server. function IsDuplicityVersion() end ---Turn a Lua value into a JSON string. --- ---```lua ---local text = json.encode({ name = 'Max', cash = 100 }) ---``` ---@param value any Table, string, number, boolean or nil. ---@return string # JSON text. function json.encode(value) end ---Turn a JSON string into a Lua value. --- ---```lua ---local data, err = json.decode('{"cash": 100}') ---if not data then print(err) end ---``` ---@param text string JSON text. ---@return any # The value, or nil if the text is not valid JSON. ---@return string? # Error message when decoding failed. function json.decode(text) end ---Add a command for the console, the chat (/name) or key bindings. --- ---Commands are shared by all resources on the same side. If two resources register the same name, the later one wins and a warning is logged. Commands of a stopped resource are removed. --- ---```lua ---RegisterCommand('heal', function(source, args, raw) --- local target = tonumber(args[1]) or source --- TriggerClientEvent('myres:heal', target) ---end, true) ---``` ---@param commandName string Name without slash, for example "car". Not case-sensitive. ---@param handler fun(source: integer, args: string[], rawCommand: string) Called with the player ID (0 for the server console), the words after the command and the whole line. ---@param restricted? boolean If true, only players with the permission command. may use it (see add_ace in server.cfg). function RegisterCommand(commandName, handler, restricted) end ---Run a console command, as if typed into the server console. --- ---```lua ---ExecuteCommand('add_principal identifier.gampeon:42 group.admin') ---``` ---@param commandString string The whole command line, for example "restart myresource". function ExecuteCommand(commandString) end ---List all commands that resources registered on this side. --- ---```lua ---for _, cmd in ipairs(GetRegisteredCommands()) do --- print(cmd.name, cmd.resource) ---end ---``` ---@return {name: string, resource: string, arity: integer, restricted: boolean}[] # One entry per command. arity is always -1. restricted is true for commands that need an ACE permission. function GetRegisteredCommands() end ---Check if a player has a permission (ACE). --- ---Available on the server only. --- ---```lua ---if IsPlayerAceAllowed(source, 'myres.admin') then --- -- ... ---end ---``` ---@param playerSrc integer|string Player ID. ---@param object string Permission, for example "command.heal" or "myres.admin". ---@return boolean # true if allowed. function IsPlayerAceAllowed(playerSrc, object) end ---Read a convar as text. --- ---```lua ---local locale = GetConvar('myres_locale', 'en') ---``` ---@param varName string Name, for example "sv_hostname". ---@param default string Returned if the convar is not set. ---@return string # The value or the default. function GetConvar(varName, default) end ---Read a convar as a whole number. --- ---```lua ---local slots = GetConvarInt('sv_maxclients', 64) ---``` ---@param varName string Name. ---@param default integer Returned if the convar is not set or not a number. ---@return integer # The value or the default. function GetConvarInt(varName, default) end ---Read a convar as a number with decimals. --- ---```lua ---local rate = GetConvarFloat('myres_tax', 0.19) ---``` ---@param varName string Name. ---@param default number Returned if the convar is not set or not a number. ---@return number # The value or the default. function GetConvarFloat(varName, default) end ---Read a convar as true or false. --- ---```lua ---if GetConvarBool('myres_debug', false) then print('debug on') end ---``` ---@param varName string Name. ---@param default boolean Returned if the convar is not set or not a yes/no value. ---@return boolean # true for true, 1, yes, on; false for false, 0, no, off; otherwise the default. function GetConvarBool(varName, default) end ---Set a convar on the server. --- ---Available on the server only. --- ---```lua ---SetConvar('myres_mode', 'event') ---``` ---@param varName string Name. ---@param value string New value. function SetConvar(varName, value) end ---Set a convar that clients can read too. --- ---Available on the server only. --- ---```lua ---SetConvarReplicated('myres_theme', 'dark') ---``` ---@param varName string Name. ---@param value string New value. function SetConvarReplicated(varName, value) end ---Set a convar that is shown in the server list. --- ---Available on the server only. --- ---```lua ---SetConvarServerInfo('tags', 'roleplay,economy') ---``` ---@param varName string Name. ---@param value string New value. function SetConvarServerInfo(varName, value) end ---Send a web request and get the answer in a callback. --- ---Available on the server only. --- ---```lua ---PerformHttpRequest('https://example.com/api/status', function(status, body, headers, err) --- if status == 200 then --- local data = json.decode(body) --- else --- print('request failed', status, err) --- end ---end, 'GET', '', { ['Accept'] = 'application/json' }) ---``` ---@param url string http:// or https:// address. Addresses in private networks and localhost are blocked unless the server operator allows them. ---@param callback? fun(statusCode: integer, body: string?, headers: table, errorData: string?) Called with the result. body is nil for errors; then errorData has the reason or the error body. ---@param method? string GET (default), POST, PUT, PATCH, DELETE, HEAD or OPTIONS. ---@param data? string Request body, at most 1 MB by default. ---@param headers? table Request headers. ---@param options? {timeout: integer?} timeout in milliseconds (at most the server limit, 30 s by default). ---@return integer # ID of the request. function PerformHttpRequest(url, callback, method, data, headers, options) end ---Name of the resource that called the current export or triggered the current local event. --- ---```lua ---exports('Pay', function(amount) --- print(GetInvokingResource() .. ' wants to pay ' .. amount) ---end) ---``` ---@return string? # Resource name, or nil inside network events, threads and timers. function GetInvokingResource() end ---Read a file from a resource folder. --- ---```lua ---local items = json.decode(LoadResourceFile(GetCurrentResourceName(), 'data/items.json')) ---``` ---@param resourceName string Resource, for example GetCurrentResourceName(). ---@param fileName string Path inside the resource, for example "data/items.json". ---@return string? # File content, or nil if the file does not exist. function LoadResourceFile(resourceName, fileName) end ---Write a file into the own resource folder. --- ---Available on the server only. --- ---```lua ---SaveResourceFile(GetCurrentResourceName(), 'data/state.json', json.encode(state), -1) ---``` ---@param resourceName string Must be the own resource. ---@param fileName string Path inside the resource. The folder must exist. ---@param data string Content. ---@param dataLength? integer Number of bytes to write, or -1 for all. ---@return boolean # true if written. function SaveResourceFile(resourceName, fileName, data, dataLength) end ---Check if a resource runs. --- ---```lua ---if GetResourceState('gp_inventory') ~= 'started' then --- print('inventory missing') ---end ---``` ---@param resourceName string Resource name. ---@return string # "started", "stopped" (known but not running) or "missing". function GetResourceState(resourceName) end ---Number of running resources on this side. --- ---```lua ---print(GetNumResources()) ---``` ---@return integer # Count. function GetNumResources() end ---Name of the running resource at an index, for loops over all resources. --- ---```lua ---for i = 0, GetNumResources() - 1 do --- print(GetResourceByFindIndex(i)) ---end ---``` ---@param findIndex integer 0 to GetNumResources() - 1. ---@return string? # Resource name. function GetResourceByFindIndex(findIndex) end ---Folder of a resource on the server. --- ---Available on the server only. --- ---```lua ---print(GetResourcePath(GetCurrentResourceName())) ---``` ---@param resourceName string Resource name. ---@return string? # Path, or nil if unknown. function GetResourcePath(resourceName) end ---Read a value from the manifest of a running resource. --- ---```lua ---local version = GetResourceMetadata(GetCurrentResourceName(), 'version', 0) ---``` ---@param resourceName string Resource name. ---@param metadataKey string Directive, for example "version", "author" or "ui_page". ---@param index? integer 0 for the first value. ---@return string? # The value, or nil. function GetResourceMetadata(resourceName, metadataKey, index) end ---How many values a manifest directive has. --- ---```lua ---print(GetNumResourceMetadata('myres', 'dependency')) ---``` ---@param resourceName string Resource name. ---@param metadataKey string Directive. ---@return integer # Count. function GetNumResourceMetadata(resourceName, metadataKey) end ---Create a vector2 with 2 numbers (x, y). --- ---```lua ---local size = vector2(1920, 1080) ---print(size.x, size.y) ---``` ---@param x? number x component. With only one number, all components get it. ---@param y? number y component. With only one number, all components get it. ---@return vector2 # Read-only vector. function vector2(x, y) end ---Short name for vector2. --- ---```lua ---local v = vec2(1, 2) ---``` ---@param x? number x component. ---@param y? number y component. ---@return vector2 # Read-only vector. function vec2(x, y) end ---Create a vector3 with 3 numbers (x, y, z). --- ---Vectors are values: components cannot be changed, create a new vector instead. They keep their type in events between server and client and in exports. --- ---```lua ---local spawn = vector3(120.0, -45.5, 30.0) ---local dist = #(GetEntityCoords(ped) - spawn) ---``` ---@param x? number x component. With only one number, all components get it. ---@param y? number y component. With only one number, all components get it. ---@param z? number z component. With only one number, all components get it. ---@return vector3 # Read-only vector. function vector3(x, y, z) end ---Short name for vector3. --- ---```lua ---local v = vec3(1, 2, 3) ---``` ---@param x? number x component. ---@param y? number y component. ---@param z? number z component. ---@return vector3 # Read-only vector. function vec3(x, y, z) end ---Create a vector4 with 4 numbers (x, y, z, w). --- ---```lua ---local spawnWithHeading = vector4(120.0, -45.5, 30.0, 90.0) ---print(spawnWithHeading.w) ---``` ---@param x? number x component. With only one number, all components get it. ---@param y? number y component. With only one number, all components get it. ---@param z? number z component. With only one number, all components get it. ---@param w? number w component. With only one number, all components get it. ---@return vector4 # Read-only vector. function vector4(x, y, z, w) end ---Short name for vector4. --- ---```lua ---local v = vec4(1, 2, 3, 4) ---``` ---@param x? number x component. ---@param y? number y component. ---@param z? number z component. ---@param w? number w component. ---@return vector4 # Read-only vector. function vec4(x, y, z, w) end ---Create a vector with 2, 3 or 4 numbers. --- ---```lua ---local v = vec(1, 2, 3) -- vector3 ---``` ---@param x number x ---@param y number y ---@param z? number z ---@param w? number w ---@return vector2|vector3|vector4 # Vector with as many components as arguments. function vec(x, y, z, w) end ---Create a promise that is resolved later. --- ---Call p:resolve(value) or p:reject(err) once. p:next(onResolved, onRejected) chains a follow-up and returns a new promise. --- ---```lua ---local p = promise.new() ---PerformHttpRequest(url, function(status, body) --- p:resolve(body) ---end) ---local body = Citizen.Await(p) ---``` ---@param executor? fun(resolve: function, reject: function) Optional: called right away with resolve and reject. ---@return promise # The promise. function promise.new(executor) end ---Create a promise that is already resolved. --- ---```lua ---local p = promise.resolve(42) ---``` ---@param ... any Values. ---@return promise # The promise. function promise.resolve(...) end ---Create a promise that is already rejected. --- ---```lua ---local p = promise.reject('no money') ---``` ---@param err any Error. ---@return promise # The promise. function promise.reject(err) end ---Wait for several promises; resolves with a list of their first values. --- ---```lua ---local results = Citizen.Await(promise.all({ p1, p2 })) ---``` ---@param promises promise[] Promises. ---@return promise # Resolves when all are resolved, rejects on the first error. function promise.all(promises) end ---Resolve with the first promise that finishes. --- ---```lua ---local winner = Citizen.Await(promise.first({ p1, p2 })) ---``` ---@param promises promise[] Promises. ---@return promise # The new promise. function promise.first(promises) end ---Same as promise.first. --- ---```lua ---local winner = Citizen.Await(promise.race({ p1, p2 })) ---``` ---@param promises promise[] Promises. ---@return promise # The new promise. function promise.race(promises) end ---Pause the current thread until a promise is resolved, then return its values. --- ---```lua ---local data = Citizen.Await(p) ---``` ---@param p promise The promise. ---@return any # Values from resolve. A rejected promise raises the error here. function Citizen.Await(p) end ---Run a query. SELECT returns the rows; other statements return { affectedRows, insertId }. --- ---Add .await to wait for the result in the current thread instead of a callback: local rows = MySQL.query.await(sql, params). On an error the callback is not called and the error is logged; .await raises the error in the calling thread. --- ---Available on the server only. --- ---```lua ---MySQL.query('SELECT name, money FROM users WHERE job = ?', { 'police' }, function(rows) --- for _, row in ipairs(rows) do print(row.name, row.money) end ---end) --- ---local rows = MySQL.query.await('SELECT * FROM users WHERE identifier = @id', { id = identifier }) ---``` ---@param query string SQL with ? or @name placeholders. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: table) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.query ---@overload fun(query: string, parameters?: table|any[], cb?: fun(result: table)) MySQL.query = {} ---Waits in the current thread and returns the result of MySQL.query. ---@param query string SQL with ? or @name placeholders. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@return table function MySQL.query.await(query, parameters) end ---Run a query and return only the first row. --- ---Add .await to wait for the result in the current thread instead of a callback: local row = MySQL.single.await(sql, params). nil if there is no row. --- ---Available on the server only. --- ---```lua ---local user = MySQL.single.await('SELECT * FROM users WHERE identifier = ? LIMIT 1', { identifier }) ---if user then print(user.money) end ---``` ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: table?) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.single ---@overload fun(query: string, parameters?: table|any[], cb?: fun(result: table?)) MySQL.single = {} ---Waits in the current thread and returns the result of MySQL.single. ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@return table? function MySQL.single.await(query, parameters) end ---Run a query and return the first column of the first row. --- ---Add .await to wait for the result in the current thread instead of a callback: local value = MySQL.scalar.await(sql, params). --- ---Available on the server only. --- ---```lua ---local count = MySQL.scalar.await('SELECT COUNT(*) FROM vehicles WHERE owner = ?', { identifier }) ---``` ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: any) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.scalar ---@overload fun(query: string, parameters?: table|any[], cb?: fun(result: any)) MySQL.scalar = {} ---Waits in the current thread and returns the result of MySQL.scalar. ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@return any function MySQL.scalar.await(query, parameters) end ---Run an INSERT and return the new ID. --- ---Add .await to wait for the result in the current thread instead of a callback: local id = MySQL.insert.await(sql, params). --- ---Available on the server only. --- ---```lua ---local id = MySQL.insert.await('INSERT INTO bills (owner, amount) VALUES (?, ?)', { identifier, 250 }) ---``` ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: integer) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.insert ---@overload fun(query: string, parameters?: table|any[], cb?: fun(result: integer)) MySQL.insert = {} ---Waits in the current thread and returns the result of MySQL.insert. ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@return integer function MySQL.insert.await(query, parameters) end ---Run an UPDATE or DELETE and return the number of changed rows. --- ---Add .await to wait for the result in the current thread instead of a callback: local count = MySQL.update.await(sql, params). --- ---Available on the server only. --- ---```lua ---local changed = MySQL.update.await('UPDATE users SET money = money + ? WHERE identifier = ?', { 100, identifier }) ---``` ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: integer) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.update ---@overload fun(query: string, parameters?: table|any[], cb?: fun(result: integer)) MySQL.update = {} ---Waits in the current thread and returns the result of MySQL.update. ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@return integer function MySQL.update.await(query, parameters) end ---Run a statement with ? placeholders, also many times with a list of parameter lists. --- ---Add .await to wait for the result in the current thread instead of a callback: local result = MySQL.prepare.await(sql, params). --- ---Available on the server only. --- ---```lua ---MySQL.prepare('INSERT INTO items (owner, name) VALUES (?, ?)', { { 1, 'bread' }, { 1, 'water' } }) ---local money = MySQL.prepare.await('SELECT money FROM users WHERE id = ?', { 1 }) ---``` ---@param query string SQL with ? placeholders. ---@param parameters any[]|any[][] One list of values, or a list of lists to run the statement once per entry. ---@param cb? fun(result: any) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.prepare ---@overload fun(query: string, parameters: any[]|any[][], cb?: fun(result: any)) MySQL.prepare = {} ---Waits in the current thread and returns the result of MySQL.prepare. ---@param query string SQL with ? placeholders. ---@param parameters any[]|any[][] One list of values, or a list of lists to run the statement once per entry. ---@return any function MySQL.prepare.await(query, parameters) end ---Run a query and return the raw result. --- ---Add .await to wait for the result in the current thread instead of a callback: local result = MySQL.rawExecute.await(sql, params). --- ---Available on the server only. --- ---```lua ---local rows = MySQL.rawExecute.await('SHOW TABLES') ---``` ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: table) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.rawExecute ---@overload fun(query: string, parameters?: table|any[], cb?: fun(result: table)) MySQL.rawExecute = {} ---Waits in the current thread and returns the result of MySQL.rawExecute. ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@return table function MySQL.rawExecute.await(query, parameters) end ---Old name of MySQL.query. --- ---Available on the server only. --- ---```lua ---MySQL.execute('DELETE FROM sessions WHERE expires < NOW()') ---``` ---@param query string SQL. ---@param parameters? table|any[] Values for ? placeholders (list) or for @name/:name placeholders (table with keys "name" or "@name"). A list as a value for ? expands for IN (?). ---@param cb? fun(result: table) Called with the result. Leave it out and use .await to get the result directly. function MySQL.execute(query, parameters, cb) end ---Run several statements in one transaction. If one fails, none of them is kept. --- ---Add .await to wait for the result in the current thread instead of a callback: local ok = MySQL.transaction.await(queries, params). --- ---Available on the server only. --- ---```lua ---local ok = MySQL.transaction.await({ --- { query = 'UPDATE users SET money = money - ? WHERE id = ?', values = { 100, from } }, --- { query = 'UPDATE users SET money = money + ? WHERE id = ?', values = { 100, to } }, ---}) ---``` ---@param queries (string|{query: string, values: table?})[] Statements as strings (using the shared parameters) or tables with query and values. ---@param parameters? table Shared parameters for statements given as strings. ---@param cb? fun(result: boolean) Called with the result. Leave it out and use .await to get the result directly. ---@class MySQL.transaction ---@overload fun(queries: (string|{query: string, values: table?})[], parameters?: table, cb?: fun(result: boolean)) MySQL.transaction = {} ---Waits in the current thread and returns the result of MySQL.transaction. ---@param queries (string|{query: string, values: table?})[] Statements as strings (using the shared parameters) or tables with query and values. ---@param parameters? table Shared parameters for statements given as strings. ---@return boolean function MySQL.transaction.await(queries, parameters) end ---Run a function once the database is ready. --- ---Available on the server only. --- ---```lua ---MySQL.ready(function() --- print('database ready') ---end) ---``` ---@param cb function Called in a new thread. function MySQL.ready(cb) end ---Old mysql-async names: fetchAll, fetchScalar, fetchSingle, insert, execute, transaction (callback form). --- ---Available on the server only. --- ---```lua ---MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier', { ['@identifier'] = id }, function(rows) end) ---``` ---@type table MySQL.Async = {} ---Old mysql-async names that wait for the result: fetchAll, fetchScalar, fetchSingle, insert, execute, transaction. --- ---Available on the server only. --- ---```lua ---local rows = MySQL.Sync.fetchAll('SELECT * FROM jobs') ---``` ---@type table MySQL.Sync = {} ---List the IDs of all players on the server. --- ---Available on the server only. --- ---```lua ---for _, id in ipairs(GetPlayers()) do --- print(id, GetPlayerName(id)) ---end ---``` ---@return string[] # Player IDs as strings, like in FiveM. function GetPlayers() end ---Number of players on the server. --- ---Available on the server only. ---@return integer # Player count. function GetNumPlayerIndices() end ---Player ID at a position in the player list. --- ---Available on the server only. ---@param index integer 0 to GetNumPlayerIndices() - 1. ---@return string? # Player ID, or nil if the index is out of range. function GetPlayerFromIndex(index) end ---Check whether a player ID is on the server. --- ---Available on the server only. ---@param playerSrc string|integer Player ID (source). ---@return boolean # true if the player is connected. function DoesPlayerExist(playerSrc) end ---Display name of a player. ---@param playerSrc string|integer Player ID (source) on the server. On the client only your own player (PlayerId()) for now. ---@return string? # The name, or nil for unknown IDs on the server. On the client "**Invalid**" for other players. function GetPlayerName(playerSrc) end ---All identifiers of a player. --- ---The first is always `gampeon:`. `license:<40 hex>` is derived from the account and the convar sv_licenseSalt, so databases from ESX and Qbox that key players by license keep working. --- ---Available on the server only. --- ---```lua ---for _, id in ipairs(GetPlayerIdentifiers(source)) do print(id) end ---``` ---@param playerSrc string|integer Player ID (source). ---@return string[] # Identifiers like "gampeon:42" and "license:…". function GetPlayerIdentifiers(playerSrc) end ---Number of identifiers of a player. --- ---Available on the server only. ---@param playerSrc string|integer Player ID (source). ---@return integer # Count, 0 for unknown IDs. function GetNumPlayerIdentifiers(playerSrc) end ---One identifier of a player by position. --- ---Available on the server only. ---@param playerSrc string|integer Player ID (source). ---@param index integer 0-based position. ---@return string? # The identifier, or nil. function GetPlayerIdentifier(playerSrc, index) end ---The identifier of a player with a given prefix. --- ---Available on the server only. --- ---```lua ---local license = GetPlayerIdentifierByType(source, 'license') ---``` ---@param playerSrc string|integer Player ID (source). ---@param identifierType string Prefix without colon, for example "license" or "gampeon". ---@return string? # For example "license:3f2a…", or nil. function GetPlayerIdentifierByType(playerSrc, identifierType) end ---Network address of a player, as far as the server shares it. --- ---Available on the server only. ---@param playerSrc string|integer Player ID (source). ---@return string? # Address text, may be empty. function GetPlayerEndpoint(playerSrc) end ---Round-trip time to a player in milliseconds. --- ---Available on the server only. ---@param playerSrc string|integer Player ID (source). ---@return integer # Ping in ms, 0 for unknown IDs. function GetPlayerPing(playerSrc) end ---Milliseconds since the last network event from a player. --- ---Available on the server only. ---@param playerSrc string|integer Player ID (source). ---@return integer # Time in ms. function GetPlayerLastMsg(playerSrc) end ---Handle of your own player on the client. Pass it to GetPlayerServerId or GetPlayerName. --- ---Available on the client only. --- ---```lua ---local myId = GetPlayerServerId(PlayerId()) ---print('my server id is ' .. myId) ---``` ---@return integer # Always 0 for now (the local player). function PlayerId() end ---Server ID (source) of a player, as server scripts see it. --- ---Available on the client only. --- ---```lua ---TriggerServerEvent('myres:ready', GetPlayerServerId(PlayerId())) ---``` ---@param player integer Player handle, for now only PlayerId(). ---@return integer # The server ID, 0 for unknown players. function GetPlayerServerId(player) end ---Disconnect a player with a reason. --- ---Available on the server only. --- ---```lua ---DropPlayer(source, 'You were kicked for spamming.') ---``` ---@param playerSrc string|integer Player ID (source). ---@param reason? string Shown to the player. function DropPlayer(playerSrc, reason) end ---A player's character (ped). --- ---On the server, pass the player ID (source). On the client, pass -1 or PlayerId() for your own character; other players follow later. Returns 0 while the player has no character, for example right after joining. --- ---```lua ---RegisterCommand('pos', function(source) --- local ped = GetPlayerPed(source) --- print(GetPlayerName(source) .. ' is at ' .. GetEntityCoords(ped)) ---end) ---``` ---@param playerSrc string|integer Server: player ID (source). Client: -1 or PlayerId(). ---@return integer # Entity handle of the ped, or 0. function GetPlayerPed(playerSrc) end ---Your own character (ped) on the client. --- ---Available on the client only. --- ---```lua ---local coords = GetEntityCoords(PlayerPedId()) ---print(('I am at %.1f, %.1f, %.1f'):format(coords.x, coords.y, coords.z)) ---``` ---@return integer # Entity handle of your ped, or 0 before it spawned. function PlayerPedId() end ---Check if an entity handle still points to an entity. --- ---```lua ---local ped = GetPlayerPed(source) ---if DoesEntityExist(ped) then --- print('ped exists') ---end ---``` ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return boolean # true if the entity exists. function DoesEntityExist(entity) end ---Position of an entity in meters. --- ---```lua ---local a = GetEntityCoords(GetPlayerPed(source)) ---local b = vector3(100.0, 20.0, 1.0) ---if #(a - b) < 5.0 then --- print('near the shop') ---end ---``` ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return vector3 # Position in meters. vector3(0, 0, 0) for unknown entities. function GetEntityCoords(entity) end ---Direction an entity faces, in degrees. ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return number # 0 up to 360. 0 faces +x, 90 faces +y. 0 for unknown entities. function GetEntityHeading(entity) end ---Unit vector in the direction an entity faces. --- ---```lua ---local ped = GetPlayerPed(source) ---local inFront = GetEntityCoords(ped) + GetEntityForwardVector(ped) * 2.0 ---``` ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return vector3 # Length 1, z is 0. Follows GetEntityHeading: heading 0 gives (1, 0, 0), 90 gives (0, 1, 0). (0, 0, 0) for unknown entities. function GetEntityForwardVector(entity) end ---X part of GetEntityForwardVector. ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return number # -1 up to 1. 0 for unknown entities. function GetEntityForwardX(entity) end ---Y part of GetEntityForwardVector. ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return number # -1 up to 1. 0 for unknown entities. function GetEntityForwardY(entity) end ---Speed and direction of an entity in meters per second. --- ---```lua ---local speed = #GetEntityVelocity(GetPlayerPed(source)) ---print(('%.1f m/s'):format(speed)) ---``` ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return vector3 # Velocity in meters per second. #velocity is the speed. function GetEntityVelocity(entity) end ---Kind of entity. ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@return integer # 0 = no entity, 1 = ped, 2 = vehicle, 3 = object. function GetEntityType(entity) end ---Teleport an entity to a position in meters. --- ---The server owns the world, so only server scripts move entities. Players see the new position through the normal replication. Coordinates must be finite and within 1,000,000 meters. For a character the position is the middle of its body, about 0.9 meters above its feet, so add that to the ground height (GetEntityCoords returns the same point). --- ---Available on the server only. --- ---```lua ---RegisterCommand('tpspawn', function(source) --- SetEntityCoords(GetPlayerPed(source), vector3(0.0, 0.0, 2.0)) ---end, true) ---``` ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@param x number|vector3 x in meters, or a vector3 with x, y and z. ---@param y? number y in meters (not needed with a vector3). ---@param z? number z in meters (not needed with a vector3). function SetEntityCoords(entity, x, y, z) end ---Turn an entity to face a direction in degrees. --- ---Available on the server only. --- ---```lua ---SetEntityHeading(GetPlayerPed(source), 90.0) ---``` ---@param entity integer Entity handle, for example from GetPlayerPed. 0 means no entity. ---@param heading number Degrees. Any value works, it is wrapped to 0 up to 360. 0 faces +x, 90 faces +y. function SetEntityHeading(entity, heading) end ---Model of an entity as a hash. --- ---```lua ---if GetEntityModel(obj) == GetHashKey('prop_cube') then --- print('a cube') ---end ---``` ---@param entity integer Entity handle. 0 means no entity. ---@return integer # GetHashKey of the model name, 0 for player characters and missing entities. function GetEntityModel(entity) end ---Check if the game knows a model that CreateObject or CreateVehicle can create. --- ---```lua ---print(IsModelValid('prop_cube')) ---``` ---@param model string|integer Model name such as "prop_cube" or its hash from GetHashKey. ---@return boolean # true if the model exists. function IsModelValid(model) end ---Check if a model is a vehicle model. ---@param model string|integer Model name such as "prop_cube" or its hash from GetHashKey. ---@return boolean # true for vehicle models, false for objects and unknown models. function IsModelAVehicle(model) end ---Create an object in the world for every player. --- ---The object belongs to your resource and is deleted when the resource stops. It has physics but sleeps until something hits it, like props in FiveM; FreezeEntityPosition holds it in place. A resource may have 1000 entities at once. Unknown models return 0 and write a warning to the log. --- ---Available on the server only. --- ---```lua ---local c = GetEntityCoords(GetPlayerPed(source)) ---local box = CreateObject('prop_cube', c.x + 2.0, c.y, c.z, true, true, false) ---FreezeEntityPosition(box, true) ---``` ---@param model string|integer Model name such as "prop_cube" or its hash from GetHashKey. ---@param x number Position in meters (or a vector3 here and leave out y and z). ---@param y number Meters. ---@param z number Meters, up. ---@param isNetwork? boolean Ignored: objects from the server always exist for every player. ---@param netMissionEntity? boolean Ignored. ---@param doorFlag? boolean Ignored. ---@return integer # Entity handle, 0 if it could not be created. function CreateObject(model, x, y, z, isNetwork, netMissionEntity, doorFlag) end ---Same as CreateObject. --- ---Available on the server only. ---@param model string|integer Model name such as "prop_cube" or its hash from GetHashKey. ---@param x number Position in meters (or a vector3 here and leave out y and z). ---@param y number Meters. ---@param z number Meters, up. ---@param isNetwork? boolean Ignored. ---@param netMissionEntity? boolean Ignored. ---@param doorFlag? boolean Ignored. ---@return integer # Entity handle, 0 if it could not be created. function CreateObjectNoOffset(model, x, y, z, isNetwork, netMissionEntity, doorFlag) end ---Create a vehicle in the world for every player. --- ---Belongs to your resource and is deleted when it stops. The game has no vehicle models yet, so for now this returns 0 and writes a warning to the log. --- ---Available on the server only. ---@param model string|integer Model name such as "prop_cube" or its hash from GetHashKey. ---@param x number Position in meters (or a vector3 here and leave out y and z). ---@param y number Meters. ---@param z number Meters, up. ---@param heading? number Degrees, 0 faces +x, 90 faces +y. ---@param isNetwork? boolean Ignored: vehicles from the server always exist for every player. ---@param netMissionEntity? boolean Ignored. ---@return integer # Entity handle, 0 if it could not be created. function CreateVehicle(model, x, y, z, heading, isNetwork, netMissionEntity) end ---Delete an entity that a script created. --- ---Works for objects and vehicles from CreateObject and CreateVehicle of any resource. Player characters cannot be deleted. --- ---Available on the server only. --- ---```lua ---DeleteEntity(box) ---``` ---@param entity integer Entity handle. 0 does nothing. function DeleteEntity(entity) end ---Hold an entity in place without physics, or let it move again. --- ---Available on the server only. --- ---```lua ---FreezeEntityPosition(box, true) ---``` ---@param entity integer Entity handle. ---@param toggle boolean true holds it in place, false turns physics back on. function FreezeEntityPosition(entity, toggle) end ---Show a line in the chat window of the game. --- ---Most scripts use the chat:addMessage event instead, which the chat resource turns into this call. Line breaks become spaces, other control characters are removed, the author is cut at 64 bytes and the text at 1024 bytes. --- ---Available on the client only. --- ---```lua ---Gampeon.ChatAddMessage('System', 'Welcome to the server', {0, 200, 255}) ---``` ---@param author string Shown before the text. Empty for a line without author. ---@param text string The message. ---@param color? {integer, integer, integer} Color as {r, g, b} from 0 to 255. Default white. function Gampeon.ChatAddMessage(author, text, color) end ---Remove all lines from the chat window. --- ---Available on the client only. function Gampeon.ChatClear() end ---Suggest a command while the player types in the chat window. --- ---Available on the client only. ---@param name string The command with slash, for example "/tp". ---@param help? string Short help text. function Gampeon.ChatAddSuggestion(name, help) end ---Remove a command suggestion. --- ---Available on the client only. ---@param name string The command with slash. function Gampeon.ChatRemoveSuggestion(name) end ---Start a resource and its dependencies. --- ---Needs the permission command.start for the calling resource: `add_ace resource. command.start allow`. --- ---Available on the server only. ---@param resourceName string Resource name. ---@return boolean # true if it runs afterwards. function StartResource(resourceName) end ---Stop a resource and everything that depends on it. --- ---Needs the permission command.stop for the calling resource. --- ---Available on the server only. ---@param resourceName string Resource name. ---@return boolean # true if it was running. function StopResource(resourceName) end ---Send data to the page of this resource. --- ---The page receives it as the data of a message event: window.addEventListener('message', (e) => { ... e.data ... }). The data is sent as JSON, at most 1 MB. --- ---Available on the client only. --- ---```lua ---SendNUIMessage({ type = 'open', items = { 'bread', 'water' } }) ---``` ---@param data table Any value that converts to JSON, usually a table with a type field. ---@return boolean # Always true. function SendNUIMessage(data) end ---Send a JSON text to the page of this resource. --- ---Available on the client only. ---@param jsonString string A JSON text, for example from json.encode. ---@return boolean # false if the text is not valid JSON. function SendNuiMessage(jsonString) end ---Answer requests from the page of this resource. --- ---The page calls fetch(`https://${GetParentResourceName()}/name`, { method: 'POST', body: JSON.stringify(data) }). The handler gets the decoded body and a function cb to answer; the page gets the answer as JSON. If the handler fails or does not answer within 30 seconds, the page gets an error. --- ---Available on the client only. --- ---```lua ---RegisterNUICallback('close', function(data, cb) --- SetNuiFocus(false, false) --- cb('ok') ---end) ---``` ---@param callbackType string Name in the URL, for example "close". ---@param callback fun(data: any, cb: fun(result: any)) Called with the request body; call cb once with the answer. ---@return EventHandle # Handle for RemoveEventHandler. function RegisterNUICallback(callbackType, callback) end ---Give keyboard and mouse to the pages, or give them back to the game. --- ---Focus is shared by all resources; the last call wins. When the resource that set the focus stops, the focus goes back to the game. Players can always take the focus back with a fixed key of the game. --- ---Available on the client only. --- ---```lua ---RegisterCommand('inventory', function() --- SendNUIMessage({ type = 'open' }) --- SetNuiFocus(true, true) ---end) ---``` ---@param hasFocus boolean Pages get the keyboard. ---@param hasCursor boolean Pages get the mouse and the cursor is shown. function SetNuiFocus(hasFocus, hasCursor) end ---Let the game keep getting keyboard input while a page has focus. --- ---Available on the client only. ---@param keepInput boolean true: player can still move while the page has focus. function SetNuiFocusKeepInput(keepInput) end ---Whether a page has the keyboard focus. --- ---Available on the client only. ---@return boolean # true while a page has focus. function IsNuiFocused() end ---Whether the game keeps keyboard input while a page has focus. --- ---Available on the client only. ---@return boolean # The value set with SetNuiFocusKeepInput. function IsNuiFocusKeepingInput() end ---Switch on the block world of this server. --- ---Call it once when your resource starts, before players spawn. The world stays on until the server stops, also when your resource restarts; calling it again with the same options does nothing. Every client generates the same terrain from the seed, so only changed blocks travel over the network. With `save`, the server keeps changed blocks in a save file and loads them on the next start. Zones are flat areas without blocks for fixed buildings, for example a city: nobody can dig or build there, scripts neither. --- ---Available on the server only. --- ---```lua ---EnableBlockWorld({ --- seed = 1337, --- save = 'main', --- zones = { { minX = -60, minY = -60, maxX = 60, maxY = 60, groundZ = 6 } }, ---}) ---``` ---@param options table { seed = integer, save = string?, zones = { { minX, minY, maxX, maxY, groundZ, blend?, floorZ? } }? }. seed: 0 to 4294967295. save: 1 to 32 characters a-z, 0-9, _ and -. Zone values are blocks; groundZ is the height of the fixed floor, blend (default 24) the width of the smooth edge, floorZ (default groundZ - 2) the top block of the hidden foundation inside the zone. Set floorZ lower to keep water or low ground of your own map visible. At most 8 zones. ---@return boolean # true when the world is on. Errors explain wrong options. function EnableBlockWorld(options) end ---Check whether this server has a block world. --- ---On clients it turns true once the world settings arrived from the server, shortly after joining. ---@return boolean # true when there is a block world. function IsBlockWorldEnabled() end ---Seed of the block world. --- ---Available on the server only. ---@return integer|nil # The seed, nil without a block world. function GetBlockWorldSeed() end ---Block at a position. --- ---Works everywhere in the world, also far from players. GetBlock(GetEntityCoords(ped)) is the block the feet of a character are in. --- ---```lua ---local pos = GetEntityCoords(GetPlayerPed(source)) ---if GetBlock(pos.x, pos.y, pos.z - 1) == 'sand' then --- print('on the beach') ---end ---``` ---@param x number Block x (or a vector3 here and leave out y and z). Decimals are rounded down. ---@param y number Block y. ---@param z number Block z, up. ---@return string|nil # Block name such as "stone" or "air", nil without a block world. function GetBlock(x, y, z) end ---Change a block for every player. --- ---Scripts may set any block, including ones players cannot place. Fires blockChanged. Changes inside zones, outside the world and on the bottom layer are refused. --- ---Available on the server only. --- ---```lua ----- a small tower of bricks ---for z = 10, 14 do --- SetBlock(20, 30, z, 'brick') ---end ---``` ---@param x number Block x (or a vector3 here and leave out y and z). Decimals are rounded down. ---@param y number Block y. ---@param z number Block z, up. ---@param block string Block name, see GetBlockTypes. "air" removes the block. ---@return boolean # false if the position is protected or outside the world. function SetBlock(x, y, z, block) end ---Height of the highest solid block in a column. --- ---```lua ---local z = GetBlockSurfaceZ(100, 100) ---SetEntityCoords(GetPlayerPed(source), 100.5, 100.5, z + 2.0) ---``` ---@param x number Block x (or a vector2/vector3 here and leave out y). ---@param y number Block y. ---@return integer|nil # z of the top solid block, nil without a block world. Its top face is at z + 1, so a character stands there with its middle at about z + 2. function GetBlockSurfaceZ(x, y) end ---Check whether a position is inside a zone or outside the world, where nobody can change blocks. ---@param x number Block x (or a vector3 here and leave out y and z). Decimals are rounded down. ---@param y number Block y. ---@param z number Block z, up. ---@return boolean # true where blocks cannot change. function IsBlockProtected(x, y, z) end ---All block types. --- ---The list only grows. Blocks with breakable = false (deepstone) cannot be dug by players; placeable = false means players cannot place them (ores), but scripts can. ---@return table # List of { id = 'stone', name = 'Stone', solid = true, breakable = true, placeable = true }, without air. function GetBlockTypes() end ---Block under the crosshair within reach. --- ---Available on the client only. --- ---```lua ---local x, y, z = GetBlockTarget() ---if x then --- print('looking at ' .. GetBlock(x, y, z)) ---end ---``` ---@return integer|nil # x of the block, nil when the crosshair points at nothing within reach. ---@return integer # y ---@return integer # z ---@return integer # nx: side the crosshair points at (-1, 0 or 1). Placing puts the new block at x + nx. ---@return integer # ny ---@return integer # nz function GetBlockTarget() end ---Blocks the player can place, in the slots of the hotbar. --- ---The player picks a slot with the mouse wheel or keys 1 to 9 and places it with the right mouse button. An empty list switches placing off. Send the list from your server inventory with an event; the server still asks blockPlace before anything changes. --- ---Available on the client only. --- ---```lua ---RegisterNetEvent('mygame:inventory', function(items) --- SetBlockHotbar(items) -- { { block = 'stone', count = 32 }, ... } ---end) ---``` ---@param slots table Up to 9 entries: a block name, or { block = 'planks', count = 12 } to show a number. function SetBlockHotbar(slots) end ---Selected slot of the hotbar. --- ---Available on the client only. ---@return integer # Slot from 1, 0 when the hotbar is empty. function GetBlockHotbarSlot() end ---Turn digging and placing with the mouse on or off for this player. --- ---On by default. Turn it off while a menu is open or in areas where your game does not allow building. --- ---Available on the client only. ---@param enabled boolean false turns the controls off. function SetBlockControlsEnabled(enabled) end ---Show or hide the built-in crosshair, block outline and hotbar. --- ---Hide it when your resource draws its own hotbar with a web interface (NUI). The controls keep working. --- ---Available on the client only. ---@param visible boolean false hides it. function SetBlockHudVisible(visible) end ---Offer a function to other resources, or call one. --- ---Call `exports('name', fn)` to offer a function. Other resources call it with `exports.yourresource:name(...)` or `exports['your-resource']:name(...)`. Arguments and return values are copied. Functions in them, also inside tables, stay callable and run in the resource they come from, so an export can return an object with methods. Such a function stops working when its resource stops or restarts. Exports only work between resources on the same side. ---@type table> | fun(name: string, fn: function) exports = nil