Skip to content

Reference

Server API ​

All these functions come from lib/rlx.lua. A function that fails returns nil (or false) and the reason.

Players ​

FunctionReturns
RLX.GetPlayer(source) · RLX.GetPlayerFromId(source)The xPlayer, or nil if the player has not chosen a character.
RLX.GetPlayerFromCitizenId(cid) · RLX.GetPlayerFromIdentifier(cid) · RLX.GetPlayerFromCharId(id)The xPlayer in game.
RLX.GetPlayers()List of { source, charId, citizenid, name, job, jobGrade, onDuty, gang }.
RLX.GetExtendedPlayers(key, value)xPlayers, all or filtered ("job", "gang").
RLX.GetPlayersByJob(job, onDutyOnly) · RLX.GetPlayersByGang(gang)sources.
RLX.GetDutyCounts(){ police = 3, ambulance = 1 }: players on duty.
RLX.GetPlayerCount()Characters in game.
RLX.GetClosestPlayer(coords, maxDistance, exclude)source, distance.
RLX.GetClosestVehicle(coords, maxDistance, dimension)netId or nil.
RLX.GetEntitiesInRadius(coords, radius, { types, dimension })List of netId.
RLX.IsSpotFree(coords, radius, dimension)true if no vehicle is in the way (spawn spots).
RLX.IsPlayerLoaded(source)
RLX.GetPlayersInRadius(coords, radius, exclude) · RLX.GetVehiclesInRadius(coords, radius){ { source, distance } } · netIds, closest first.
RLX.Cooldown(source, key, ms) · RLX.ResetCooldown(source, key)Anti-spam: true, or false and the remaining time (source nil: for the whole server).
RLX.Notify(source, text, kind, ms) · RLX.NotifyAll(text, kind, ms, job)kind: info, success, error, warning.
RLX.NotifyJob(job, text, kind, onDutyOnly, ms)Alerts a job (911 call, EMS); returns how many players were told.
RLX.GetPlayerCoords(source) · RLX.SetPlayerCoords(source, coords, { heading, keepVehicle, findGround })The player's position; move them (server setter).
RLX.FreezePlayer(source, yes) · RLX.SetPlayerInvincible(source, yes)No more control (cuffed, cutscene); invincible.
RLX.PlayPlayerAnim(source, dict, clip, { flag, duration }) · RLX.StopPlayerAnim(source)Animation decided by the server (handcuffs, frisk).
RLX.GetClock() · RLX.SetClock({ hours, minutes, paused, msPerGameMinute }) · RLX.SetClock(nil)Game time for everyone (like /time, kept across restarts).
RLX.SetWeather(type, minutes) · RLX.SetWeather("auto")Weather for everyone.
RLX.HasPermission(source, permission)LS:MP permission.
RLX.Revive(source) · RLX.Logout(source)
Config.Death.reviveAbovetrue by default. The game clears the area where a player is resurrected (NPCs, cars, objects around vanished on a revive). The player is brought back above the spot, then put down where they were: nothing around disappears. The RLX NPCs and props near are also put back at once (event rlx:playerResurrected).
RLX.SetRespawnDelay(seconds) · RLX.SetRespawnDelay(seconds, source)Seconds before respawning at the hospital: for every next death (nil: back to Config.Death.respawnSeconds), or for this player's current death. The death screen counts again. rlx_ambulance uses it while a medic is on duty.
RLX.GetDeathInfo(source){ dead, since, respawnIn, killer } (seconds), or { dead = false }.
RLX.SavePlayer(source) · RLX.SaveAll()Wait for the database.
RLX.UseItem(source, slot)Uses an item as if the player did.
RLX.OpenSkinMenu(source, opts) · RLX.OpenInventory(source)Opens the appearance editor / the inventory for the player.
RLX.GetVersion() · RLX.IsModuleEnabled(name) · RLX.GetConfig(key)

Registries (while running, from any resource) ​

lua
RLX.RegisterJob("taxi", {
  label = { en = "Taxi", fr = "Taxi" },
  defaultDuty = true,          -- on duty on connection
  society = true,              -- company account created automatically
  -- duty = false,             -- job without duty (always paid)
  grades = {
    { grade = 0, name = "driver", label = { en = "Driver", fr = "Chauffeur" }, salary = 80 },
    { grade = 1, name = "boss",   label = { en = "Boss", fr = "Patron" },      salary = 150, isBoss = true },
  },
})
RLX.RegisterGang("lost", { label = "The Lost", grades = { { grade = 0, name = "member", label = "Member" } } })
RLX.RegisterItem("donut", { label = "Donut", weight = 120, usable = true, close = true, description = "Sweet." })
RLX.RegisterAccount({ name = "crypto", label = "Crypto", starting = 0 })
RLX.RegisterStatus("drunk", { label = "Drunk", default = 0, max = 100, decay = 5, inverse = true, color = "#e0b0ff" })
RLX.RegisterLicense("pilot", "Pilot license")
RLX.RegisterSociety("bar", "The Bar", 0)

Reading: RLX.GetJobs(), GetJob(name), GetGangs(), GetGang(name), GetItems(), GetItem(name), GetAccounts(), GetStatuses(), GetLicenses(), GetShared() (everything at once). Connected players get the changes right away.

Usable items ​

lua
RLX.RegisterUsableItem("donut", function(source, item)
  -- item = { slot, name, label, count, weight, metadata... }
  local xPlayer = RLX.GetPlayer(source)
  if xPlayer.removeItem("donut", 1, item.slot) then
    xPlayer.addStatus("hunger", 20)
  end
end)

The item must have usable = true. The framework does not remove it: you decide.

Callbacks ​

lua
-- server
RLX.RegisterServerCallback("bank:getBalance", function(source)
  return RLX.GetPlayer(source).getAccountMoney("bank")
end)
lua
-- client
RLX.TriggerServerCallback("bank:getBalance", function(balance) print(balance) end)
local balance = RLX.Callback("bank:getBalance")   -- in a thread

These are lsmp.onCall / lsmp.callServer: always check what the client sends.