JRS COREDocs

Core object

The table returned by exports.jrs_core:GetCoreObject() and the core-wide exports, events and state bags around it.

jrs_core hands every script one table that holds its helpers. You get it with exports.jrs_core:GetCoreObject() (or the alias getCoreApi()), and the server and client each get their own version of the table. This page follows a player through the core: account and group, the character and its jobs, the state bags and events that track it, money, health and position, and then the helpers for notices, callbacks and logging.

Getting Started#

Shared

GetCoreObject

#
exports.jrs_core:GetCoreObject()

Builds the core table for the side you call it from. Call it once at the top of a file and keep the result in a local. getCoreApi() is the same function under another name.

lua
local JRS = exports.jrs_core:GetCoreObject()

RegisterCommand('whoami', function(src)
    local name = JRS.GetCharacterName(src)
    JRS.NotifyRightTip(src, ('You are %s'):format(name or 'nobody'), 4000)
end)
ReturnstableThe server table on the server, the client table on the client.

User Accounts#

A user is the account row of a connected player (one per Steam or license id). The character they are playing hangs off it as getUsedCharacter.

Field Type What it holds
identifier string Account identifier stored in jrs_users.
group string Permission group, for example user or admin.
chars number How many character slots the account may use.
warnings number Warning counter from the database.
banned number Ban flag from the database.
getUsedCharacter table or nil The selected character object (see Characters).
Server

getUser

#
JRS.getUser(source)

Looks up the account of an online player. Also available as JRS.GetUser and as the direct exports exports.jrs_core:GetUser(source) and exports.jrs_core:getUser(source).

lua
local user = JRS.getUser(src)
if not user then return end
print(user.identifier, user.group, user.chars)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable | nilThe user table, or nil when the player has no loaded account.
Server

user.setGroup

#
user.setGroup(source, targetId, groupName)

Changes the permission group of targetId. It forwards to JRS.SetGroup, so prefer calling that directly.

lua
user.setGroup(src, src, 'moderator')
ArgumentTypeMeaning
sourcenumberCaller id. Only checked for nil.
targetIdnumberPlayer whose group changes.
groupNamestringNew group name.
Returnsbooleantrue when the change was accepted.
Server

user.setUsedCharacter

#
user.setUsedCharacter(source, charIdentifier, characterRow?)

Selects one of the account's characters for the player. The character selector uses it; normal scripts rarely need it.

lua
local ok = user.setUsedCharacter(src, 12)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charIdentifiernumberCharacter id to select.
characterRowtableoptionalA jrs_characters row. Its id must match charIdentifier.
Returnsbooleantrue when the character is now selected.
Server

GetIdentifiers

#
JRS.GetIdentifiers(source)

Collects every identifier of a player into a table keyed by type.

lua
local ids = JRS.GetIdentifiers(src)
print(ids.discord or 'no discord linked')
ArgumentTypeMeaning
sourcenumberPlayer server id.
ReturnstableFor example { steam = 'steam:...', license = 'license:...', discord = 'discord:...' }.
Server

GetPlayerIdentity

#
exports.jrs_core:GetPlayerIdentity(source)

A light export that returns plain data only, handy for resources that check identity many times a second.

lua
local id = exports.jrs_core:GetPlayerIdentity(src)
if id then print('playing char', id.charIdentifier) end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable | nil{ identifier, charIdentifier }, or nil when no character is selected.

Groups And Permissions#

Server

GetGroup

#
JRS.GetGroup(source)

Reads the permission group from the core cache. Also exported as exports.jrs_core:GetGroup(source).

lua
if JRS.GetGroup(src) == 'admin' then
    -- admin only branch
end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsstring | nilGroup name, or nil for an unknown player.
Server

SetGroup

#
JRS.SetGroup(source, group, callback?)

Writes a new group to the cache and to jrs_users. Accounts listed as core owners can never be moved off owner. Also exported as exports.jrs_core:SetGroup(source, group).

lua
JRS.SetGroup(target, 'moderator', function(ok, group)
    print('group saved', ok, group)
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
groupstringNew group name.
callbackfunctionoptionalCalled as callback(ok, group, result) once the database write finishes.
Returnsbooleanfalse when the arguments are wrong, the user is not loaded or the account is protected.
Server

RefreshGroup

#
JRS.RefreshGroup(source, callback?)

Re-reads the group from the database. Use it after you edit jrs_users.group by hand while the player is online.

lua
JRS.RefreshGroup(src)
ArgumentTypeMeaning
sourcenumberPlayer server id.
callbackfunctionoptionalCalled when the refresh is done.
Server

IsAdmin

#
exports.jrs_core:IsAdmin(source)

Checks whether a player's group counts as an admin group in the core config. Source 0 (the server console) is always allowed.

lua
if not exports.jrs_core:IsAdmin(src) then return end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue for admin groups.
Server

CanUseCommand

#
exports.jrs_core:CanUseCommand(source, commandKey)

Asks the core permission table whether the player's group may run a named command. Use this instead of writing your own group lists.

lua
RegisterCommand('tpm', function(src)
    if not exports.jrs_core:CanUseCommand(src, 'tpm') then return end
    TriggerClientEvent('myscript:tpm', src)
end)
ArgumentTypeMeaning
sourcenumberPlayer server id. 0 is always allowed.
commandKeystringCommand key from the core permission config.
Returnsbooleantrue when allowed.

Joining the server is gated separately, before any group is read. The connect check is switched on with Config.Whitelist (or Config.WhitelistDiscord, which also allows the role in Config.DiscordWhitelistRole) in jrs_core/config/config.lua, and it lets a player in when their Steam or Discord id has a row in jrs_whitelist or jrs_discord_whitelist; core owners always pass. There is nothing to call from a script; add or remove rows in those tables instead.

Characters#

The character object is what getUser(source).getUsedCharacter or GetCharacter(source) returns. It is a live table: values change when the core changes them, so read them when you need them.

Field Type What it holds
identifier string Owning account identifier.
charIdentifier number Character id (jrs_characters.charidentifier).
firstname, lastname, nickname string Names.
gender, dateofbirth, occupation, character_desc string Identity fields.
money, gold, rol, dirtymoney number Balances.
job, jobgrade, joblabel string, number, string Active job.
onduty boolean Duty flag for the active job.
multijobs table Every job the character holds, keyed by job name: { grade, label }.
skills table Skill data keyed by skill name.
meta string JSON text of the character metadata.
skin, comp, inventory, coords string JSON text columns.
xp, level number Core level progress.
Server

GetCharacter

#
JRS.GetCharacter(source)

Returns the selected character, but only once it is fully ready. During loading, switching or logout it returns nil, which keeps half-loaded data out of your script. Lower-case getCharacter is the same function.

lua
local char = JRS.GetCharacter(src)
if not char then return end
print(char.firstname, char.job, char.money)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable | nilThe character object.
Server

IsCharacterReady

#
JRS.IsCharacterReady(source)

Quick yes or no for "is this player in game with a character". IsIdentityReady is an alias.

lua
if not JRS.IsCharacterReady(src) then return end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue when a character is selected and ready.
Server

GetCharacterState

#
JRS.GetCharacterState(source)

Short status record of the player's character. Also exported as exports.jrs_core:GetCharacterState(source).

lua
local state = JRS.GetCharacterState(src)
print(state.ready, state.charIdentifier)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable{ ready, version, identifier, charIdentifier }.
Server

ClearCharacter

#
JRS.ClearCharacter(source, reason?)

Marks the character as unloaded. It clears the character state bags and fires the unload events.

lua
JRS.ClearCharacter(src, 'kicked_to_selector')
ArgumentTypeMeaning
sourcenumberPlayer server id.
reasonstringoptionalText passed on to the characterUnloaded events.
Returnsbooleanfalse for an invalid source.
Server

GetCharacterData

#
JRS.GetCharacterData(source)

A flat copy of the most used character values. Safe to send over the network or to keep, because it has no functions in it. Also exported directly.

lua
local data = JRS.GetCharacterData(src)
TriggerClientEvent('myscript:profile', src, data)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable | nilsource, identifier, charIdentifier, charid, firstname, lastname, job, jobGrade, group, money, gold, rol, dirtymoney, xp.
Server

GetCharacterName

#
JRS.GetCharacterName(source)

First and last name joined with a space. Falls back to the player's Steam name when the character has no name.

lua
print(JRS.GetCharacterName(src) .. ' opened the shop')
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsstring | nilThe display name, or nil when no character is loaded.
Server

character.setJob

#
character.setJob(source, job, grade)

Sets the active job, saves it and updates the Job, JobGrade and JobLabel state bags. The job is also added to multijobs. It can refuse when the character has no valid identity yet.

lua
local char = JRS.GetCharacter(src)
local ok, why = char.setJob(src, 'sheriff', 2)
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstringJob name.
gradenumberGrade, defaults to 0.
Returnsboolean, string?true, or false plus a reason.
Server

character.setMeta

#
character.setMeta(source, metaTable)

Replaces the whole metadata table and saves it. For single keys use the Metadata helpers below.

lua
char.setMeta(src, { hunger = 80, thirst = 75 })
ArgumentTypeMeaning
sourcenumberPlayer server id.
metaTabletableFull metadata table.
Returnsbooleantrue when saved.
Server

character.addCurrency

#
character.addCurrency(source, currencyType, amount)

Adds to one balance, saves it and refreshes the HUD. Amounts must be above 0 and below one billion.

lua
char.addCurrency(src, 0, 12.50)
ArgumentTypeMeaning
sourcenumberPlayer server id.
currencyTypenumber0 money, 1 gold, 2 rol, 3 dirty money.
amountnumberAmount to add.
Returnsbooleantrue when added.
Server

character.removeCurrency

#
character.removeCurrency(source, currencyType, amount)

Takes from one balance. It does not check the balance first, so test it yourself or use removeAccount.

lua
if char.money >= 5 then char.removeCurrency(src, 0, 5) end
ArgumentTypeMeaning
sourcenumberPlayer server id.
currencyTypenumber0 money, 1 gold, 2 rol, 3 dirty money.
amountnumberAmount to remove.
Returnsbooleantrue when removed.
Server

character.changeSkin

#
character.changeSkin(source, clothingTable)

Hands a new outfit to jrs_clothing and reloads the clothes on the player. buySkin(source, name, clothingTable) does the same and takes an outfit name first.

lua
char.changeSkin(src, outfit)
ArgumentTypeMeaning
sourcenumberPlayer server id.
clothingTabletableClothing components.
Returnsbooleanfalse when jrs_clothing is not running or refuses the data.
Server

character.buySkinPlayer

#
character.buySkinPlayer(source, skinData)

Saves new body and face data into the skinPlayer column.

lua
char.buySkinPlayer(src, newSkin)
ArgumentTypeMeaning
sourcenumberPlayer server id.
skinDatatableSkin values.
Returnsbooleantrue when saved.
Server

character.addXP

#
character.addXP(amount, reason?, callback?)

XP helpers live on the character too: addXP, removeXP, setXP, setLevel, addLevel, removeLevel, plus the readers getXP() and getLevel(). You may pass the source first, as in addXP(source, amount, reason), or leave it out.

lua
char.addXP(25, 'fished_trout')
print('level', char.getLevel())
ArgumentTypeMeaning
amountnumberXP to add.
reasonstringoptionalReason saved with the change.
callbackfunctionoptionalCalled when the XP system finishes.
Returnsboolean, string?false plus player_not_found when the character has no online player.
Server

GetCharacterById

#
JRS.GetCharacterById(charId)

Fetches a character by id, online or not. GetOfflineCharacter(charId) reads the database row only.

lua
local row = JRS.GetCharacterById(42)
if row then print(row.firstname) end
ArgumentTypeMeaning
charIdnumberCharacter id.
Returnstable | nilCharacter data.
Server

GetCharactersByIdentifier

#
JRS.GetCharactersByIdentifier(identifier)

Lists every character that belongs to one account.

lua
for _, c in ipairs(JRS.GetCharactersByIdentifier(user.identifier)) do
    print(c.charIdentifier, c.firstname)
end
ArgumentTypeMeaning
identifierstringAccount identifier.
ReturnstableArray of characters, empty when none.
Server

FindCharactersByName

#
JRS.FindCharactersByName(firstname, lastname?)

Searches characters by name, for police records, mail and similar tools.

lua
local hits = JRS.FindCharactersByName('Arthur', 'Morgan')
ArgumentTypeMeaning
firstnamestringFirst name to search.
lastnamestringoptionalLast name to narrow the search.
ReturnstableArray of matches.
Server

GetCharacterCount

#
JRS.GetCharacterCount(source)

Number of characters the player's account already has. Pair it with GetMaxCharacters(source) and CanCreateCharacter(source).

lua
print(JRS.GetCharacterCount(src) .. ' / ' .. JRS.GetMaxCharacters(src))
if JRS.CanCreateCharacter(src) then print('free slot') end
ArgumentTypeMeaning
sourcenumberPlayer server id.
ReturnsnumberCharacter count.
Server

SaveCharacter

#
JRS.SaveCharacter(source)

Writes the in-memory character to the database right away. Use it before a risky action such as a server restart command.

lua
JRS.SaveCharacter(src)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue when saved.
Server

saveLocation

#
JRS.saveLocation(source, coords?, heading?)

Stores where the character will spawn next time. Without coords it uses the ped's current position.

lua
JRS.saveLocation(src, vector3(-281.0, 790.2, 118.6), 90.0)
ArgumentTypeMeaning
sourcenumberPlayer server id.
coordsvector3optionalPosition to store.
headingnumberoptionalHeading to store.
Returnsbooleantrue when saved.
Server

getLastSavedLocation

#
JRS.getLastSavedLocation(source)

Reads the last stored spawn position.

lua
local pos = JRS.getLastSavedLocation(src)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable | nil{ x, y, z, heading }.

Character Metadata#

Metadata is a free key and value store on each character, saved as JSON. Every write fires jrs_core:server:metadataChanged.

Server

Metadata.Get

#
JRS.Metadata.Get(source, key?, default?)

Reads one key, or the whole table when key is nil.

lua
local kills = JRS.Metadata.Get(src, 'bounty_kills', 0)
ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringoptionalKey to read.
defaultanyoptionalReturned when the key is missing or no character is loaded.
ReturnsanyThe stored value.
Server

Metadata.Set

#
JRS.Metadata.Set(source, key, value)

Writes one key and saves it.

lua
JRS.Metadata.Set(src, 'tutorial_done', true)
ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringKey to write.
valueanyValue to store.
Returnsbooleanfalse when no character is loaded.
Server

Metadata.Add

#
JRS.Metadata.Add(source, key, amount)

Adds to a number key. Metadata.Remove(source, key, amount) subtracts.

lua
JRS.Metadata.Add(src, 'bounty_kills', 1)
ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringNumber key.
amountnumberAmount to add.
ReturnsbooleanResult of the save.

Jobs#

A character can hold several jobs in multijobs but only one is active at a time.

Server

SetJob

#
exports.jrs_core:SetJob(source, job, grade)

The stable way to set the active job from another resource. It checks the character is ready, saves the job and tells the client. exports.jrs_core:setJob and JRS.setJob do the same.

lua
local ok, why = exports.jrs_core:SetJob(src, 'doctor', 1)
if not ok then print('hire failed: ' .. why) end
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstringJob name.
gradenumberGrade, rounded down, never below 0.
Returnsboolean, string?true, or false and a reason such as character_not_ready.
Server

setJobGrade

#
JRS.setJobGrade(source, grade)

Promotes or demotes inside the active job.

lua
JRS.setJobGrade(src, 3)
ArgumentTypeMeaning
sourcenumberPlayer server id.
gradenumberNew grade.
Returnsboolean, string?true, or false and a reason.
Server

getJob

#
JRS.getJob(source)

Active job name. getJobGrade(source) returns the grade.

lua
if JRS.getJob(src) == 'sheriff' and JRS.getJobGrade(src) >= 2 then
    -- deputy and above
end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsstring | nilJob name.
Server

GetJobPlayers

#
JRS.GetJobPlayers(job)

Finds online players whose active job matches.

lua
local docs = JRS.GetJobPlayers('doctor')
print(docs.count .. ' doctors online')
ArgumentTypeMeaning
jobstringJob name.
Returnstable{ players = { { source = id }, ... }, count = n }.
Server

Jobs.Get

#
JRS.Jobs.Get(source)

All jobs the character holds. The active job is always in the list.

lua
for job, info in pairs(JRS.Jobs.Get(src)) do
    print(job, info.grade, info.label)
end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable{ [job] = { grade, label } }.
Server

Jobs.Add

#
JRS.Jobs.Add(source, job, grade?, label?)

Gives the character another job without making it active. Respects the job limit in the character service config.

lua
JRS.Jobs.Add(src, 'farmer', 0, 'Farmer')
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstringJob name.
gradenumberoptionalGrade, defaults to 0.
labelstringoptionalDisplay label, defaults to the job name.
Returnsboolean, string?false and max_jobs or invalid_job on failure.
Server

Jobs.Remove

#
JRS.Jobs.Remove(source, job)

Takes a held job away. The active job cannot be removed.

lua
JRS.Jobs.Remove(src, 'farmer')
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstringJob name.
Returnsboolean, string?false and active_job or not_found on failure.
Server

Jobs.Switch

#
JRS.Jobs.Switch(source, job)

Makes a held job the active one, then sets the player off duty. A cooldown from config applies.

lua
local ok, why = JRS.Jobs.Switch(src, 'farmer')
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstringA job the character already holds.
Returnsboolean, string?false and job_not_owned or cooldown on failure.
Server

Jobs.SetDuty

#
JRS.Jobs.SetDuty(source, state)

Puts the player on or off duty, saves it and updates the OnDuty state bag. Jobs.ToggleDuty(source) flips it and returns the new value.

lua
JRS.Jobs.SetDuty(src, true)
local now = JRS.Jobs.ToggleDuty(src)
ArgumentTypeMeaning
sourcenumberPlayer server id.
statebooleantrue for on duty.
Returnsbooleanfalse when no character is loaded.
Server

Jobs.GetDutyPlayers

#
JRS.Jobs.GetDutyPlayers(job)

Players of a job who are on duty right now.

lua
local list, count = JRS.Jobs.GetDutyPlayers('sheriff')
ArgumentTypeMeaning
jobstringJob name.
Returnstable, numberThe list and the count.

State Bags#

The core keeps these keys on Player(source).state. They replicate to the owning client, so read them with LocalPlayer.state.Key on the client. Values reset to false when the character unloads.

Key Type Meaning
CharacterReady boolean A character is loaded and playable.
CharacterId number Character id.
CharacterIdentifier string Owning account identifier.
FirstName, LastName, Nickname string Names.
Gender string Character gender.
Job, JobGrade, JobLabel string, number, string Active job.
OnDuty boolean Duty flag.
Group string Permission group.
jrsPvp boolean PvP allowed for this player.
jrsLanguage string Chosen UI language.
jrsPerks table Unlocked level perks.
isDead boolean Free edition: the player is down.
IsInSession, jrsPlayer boolean, table Free edition: player object is active, and a snapshot of it.
lua
-- server
local job = Player(src).state.Job

-- client
AddStateBagChangeHandler('Job', ('player:%s'):format(GetPlayerServerId(PlayerId())), function(_, _, value)
    print('my job is now', value)
end)

Client Character Checks#

Client

IsCharacterReady (client)

#
JRS.IsCharacterReady()

Local check backed by the CharacterReady state bag.

lua
if not JRS.IsCharacterReady() then return end
Returnsbooleantrue once the character is in game.
Client

WaitForCharacterReady

#
JRS.WaitForCharacterReady(timeoutMs?)

Blocks the current thread until the character is ready or the time runs out.

lua
CreateThread(function()
    if JRS.WaitForCharacterReady(30000) then LoadMyHud() end
end)
ArgumentTypeMeaning
timeoutMsnumberoptionalDefaults to 10000.
Returnsbooleantrue when ready.
Client

GetCharacterStateLocal

#
exports.jrs_core:GetCharacterStateLocal()

Reads the character state bags of the local player into one table, without any server call.

lua
local me = exports.jrs_core:GetCharacterStateLocal()
print(me.firstname, me.job)
Returnstableready, charIdentifier, identifier, firstname, lastname, job, jobGrade, jobLabel, onDuty, gender.

Events#

All server events are local events (AddEventHandler). Client events arrive from the server, so register them with RegisterNetEvent.

Server

jrs_core:server:characterReady

#
AddEventHandler('jrs_core:server:characterReady', function(source, character) end)

Fires once the selected character is fully loaded. Start per-player work here instead of waiting for a spawn. jrs_core:server:characterLoaded fires right before it with the same arguments.

lua
AddEventHandler('jrs_core:server:characterReady', function(src, char)
    print(char.firstname .. ' is in game')
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charactertableThe character object.
Server

jrs_core:server:characterUnloaded

#
AddEventHandler('jrs_core:server:characterUnloaded', function(source, previous, reason) end)

Fires when a character leaves play: logout, switch or disconnect. Clean up your per-player tables here.

lua
AddEventHandler('jrs_core:server:characterUnloaded', function(src)
    ActiveJobs[src] = nil
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
previoustable | nilThe character that was active.
reasonstringWhy it was unloaded.
Server

jrs_core:server:characterCreated

#
AddEventHandler('jrs_core:server:characterCreated', function(source, charId, identifier) end)

A brand new character was written to the database.

lua
AddEventHandler('jrs_core:server:characterCreated', function(src, charId)
    print('welcome kit for char ' .. charId)
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charIdnumberNew character id.
identifierstringAccount identifier.
Server

jrs_core:server:characterSaved

#
AddEventHandler('jrs_core:server:characterSaved', function(source, character) end)

The character service finished a save.

lua
AddEventHandler('jrs_core:server:characterSaved', function(src) end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charactertableThe character object.
Server

jrs_core:server:jobChanged

#
AddEventHandler('jrs_core:server:jobChanged', function(source, job, grade) end)

The active job or grade changed.

lua
AddEventHandler('jrs_core:server:jobChanged', function(src, job, grade)
    if job ~= 'sheriff' then RemoveBadge(src) end
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstringNew job.
gradenumberNew grade.
Server

jrs_core:server:multiJobChanged

#
AddEventHandler('jrs_core:server:multiJobChanged', function(source, jobs) end)

A job was added to or removed from the held jobs.

lua
AddEventHandler('jrs_core:server:multiJobChanged', function(src, jobs) end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
jobstableThe new held jobs table.
Server

jrs_core:server:dutyChanged

#
AddEventHandler('jrs_core:server:dutyChanged', function(source, onDuty, job) end)

The duty flag changed.

lua
AddEventHandler('jrs_core:server:dutyChanged', function(src, onDuty, job)
    print(job, onDuty and 'clocked in' or 'clocked out')
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
onDutybooleanNew state.
jobstringActive job.
Server

jrs_core:server:metadataChanged

#
AddEventHandler('jrs_core:server:metadataChanged', function(source, key, value) end)

One metadata key was written.

lua
AddEventHandler('jrs_core:server:metadataChanged', function(src, key, value) end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringChanged key.
valueanyNew value.
Server

jrs_core:server:skillLevelChanged

#
AddEventHandler('jrs_core:server:skillLevelChanged', function(source, skill, newLevel, oldLevel) end)

Fires when JRS.Skills.SetXP or JRS.Skills.AddXP (or the SetSkillXP / AddSkillXP exports) leaves a skill on a different level than before. A negative AddXP can drop the level, so compare newLevel with oldLevel to tell a gain from a loss.

lua
AddEventHandler('jrs_core:server:skillLevelChanged', function(src, skill, new)
    if skill == 'hunting' and new == 10 then GiveTitle(src, 'Tracker') end
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
skillstringSkill name.
newLevelnumberLevel now.
oldLevelnumberLevel before.
Server

jrs_core:server:onPlayerDeath

#
AddEventHandler('jrs_core:server:onPlayerDeath', function(source) end)

Free edition. The player died. jrs_core:server:onPlayerRevived fires when they are revived or respawned.

lua
AddEventHandler('jrs_core:server:onPlayerDeath', function(src)
    CancelDelivery(src)
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Server

jrs_core:server:onGroupChange

#
AddEventHandler('jrs_core:server:onGroupChange', function(source, group) end)

Free edition. Fired by the player object's SetGroup. Its SetJob fires jrs_core:server:onJobChange with (source, job, grade).

lua
AddEventHandler('jrs_core:server:onGroupChange', function(src, group) end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
groupstringNew group.
Client

jrs_core:client:characterReady

#
RegisterNetEvent('jrs_core:client:characterReady', function(charId) end)

The local character is ready. The core also re-fires it locally as jrs_core:characterReady.

lua
RegisterNetEvent('jrs_core:client:characterReady', function(charId)
    SpawnCampProps()
end)
ArgumentTypeMeaning
charIdnumberCharacter id.
Client

jrs_core:client:characterUnloaded

#
RegisterNetEvent('jrs_core:client:characterUnloaded', function(reason) end)

The local character left play. Close menus and delete local entities here.

lua
RegisterNetEvent('jrs_core:client:characterUnloaded', function()
    DeleteCampProps()
end)
ArgumentTypeMeaning
reasonstringWhy it was unloaded.
Client

jrs_core:client:jobChanged

#
RegisterNetEvent('jrs_core:client:jobChanged', function(job, grade) end)

The local active job changed. Also re-fired locally as jrs_core:jobChanged.

lua
RegisterNetEvent('jrs_core:client:jobChanged', function(job)
    RefreshJobBlips(job)
end)
ArgumentTypeMeaning
jobstringNew job.
gradenumberNew grade.
Client

jrs_core:client:dutyChanged

#
RegisterNetEvent('jrs_core:client:dutyChanged', function(onDuty, job) end)

The local duty flag changed.

lua
RegisterNetEvent('jrs_core:client:dutyChanged', function(onDuty) end)
ArgumentTypeMeaning
onDutybooleanNew state.
jobstringActive job.
Client

jrs_core:client:skillLevelChanged

#
RegisterNetEvent('jrs_core:client:skillLevelChanged', function(skill, newLevel, oldLevel) end)

The server's copy of skillLevelChanged for the local character, sent from the same XP write. Also re-fired locally as jrs_core:skillLevelChanged.

lua
RegisterNetEvent('jrs_core:client:skillLevelChanged', function(skill, new) end)
ArgumentTypeMeaning
skillstringSkill name.
newLevelnumberLevel now.
oldLevelnumberLevel before.
Client

jrs:SelectedCharacter

#
RegisterNetEvent('jrs:SelectedCharacter', function(charId) end)

Sent the moment a character is picked in the selector, just before jrs:isPlayerready.

lua
RegisterNetEvent('jrs:SelectedCharacter', function(charId) end)
ArgumentTypeMeaning
charIdnumberCharacter id.
Client

jrs_core:instanceChanged

#
RegisterNetEvent('jrs_core:instanceChanged', function(bucket) end)

Sent by every SetPlayerInstance call, numeric or named, once the server has moved the local player.

lua
RegisterNetEvent('jrs_core:instanceChanged', function(bucket)
    InInterior = bucket ~= 0
end)
ArgumentTypeMeaning
bucketnumberNew bucket, 0 for the shared world.
Client

jrs_core:client:onDeath

#
AddEventHandler('jrs_core:client:onDeath', function(killer, cause) end)

Free edition, local event. The local player died. jrs_core:client:onRevived and jrs_core:client:onHospitalRespawn (with the clinic name) follow when they come back.

lua
AddEventHandler('jrs_core:client:onDeath', function(killer)
    if killer ~= 0 then print('killed by player ' .. killer) end
end)
ArgumentTypeMeaning
killernumberKiller server id, 0 when not a player.
causenumberWeapon or cause hash.

Accounts And Money#

Currency types are numbers everywhere: 0 money, 1 gold, 2 rol, 3 dirty money.

Server

getAccount

#
JRS.getAccount(source, currencyType)

Current balance of one currency, read from the live character.

lua
local gold = JRS.getAccount(src, 1)
ArgumentTypeMeaning
sourcenumberPlayer server id.
currencyTypenumber0 to 3.
ReturnsnumberBalance, 0 when unknown.
Server

addAccount

#
JRS.addAccount(source, currencyType, quantity)

Adds to a balance.

lua
JRS.addAccount(src, 0, 20)
ArgumentTypeMeaning
sourcenumberPlayer server id.
currencyTypenumber0 to 3.
quantitynumberAmount above 0.
Returnsbooleantrue when added.
Server

removeAccount

#
JRS.removeAccount(source, currencyType, quantity)

Takes from a balance. Unless the config allows negative balances it never goes below zero: an empty account returns false and a larger amount is cut down to what is there.

lua
if JRS.getAccount(src, 0) >= 15 then JRS.removeAccount(src, 0, 15) end
ArgumentTypeMeaning
sourcenumberPlayer server id.
currencyTypenumber0 to 3.
quantitynumberAmount above 0.
Returnsbooleantrue when something was removed.
Server

GetBalance

#
JRS.GetBalance(source)

All balances in one call. Also an export.

lua
local b = exports.jrs_core:GetBalance(src)
print(b.money, b.gold)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable{ money, gold, rol, dirtymoney, blackmoney }. blackmoney mirrors dirtymoney.

Health, Death And PvP#

Whether a player is alive, hurt or fair game for other players. The death checks and revive calls come from server/jrs_death.lua and client/jrs_death.lua, which ship with the free edition; healing and the PvP flag work in every edition.

Server

IsPlayerDead

#
exports.jrs_core:IsPlayerDead(source)

Whether the core has the player marked as dead.

lua
if exports.jrs_core:IsPlayerDead(src) then return end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue while dead.
Client

IsDead

#
exports.jrs_core:IsDead()

Local check for the death screen.

lua
if exports.jrs_core:IsDead() then return end
Returnsbooleantrue while the local player is down.
Server

RevivePlayer

#
exports.jrs_core:RevivePlayer(source)

Brings the player back where they fell, full health.

lua
exports.jrs_core:RevivePlayer(patient)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleanfalse when the player is not online.
Server

RespawnPlayer

#
exports.jrs_core:RespawnPlayer(source)

Sends the player to the nearest clinic and revives them there.

lua
exports.jrs_core:RespawnPlayer(src)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleanfalse when the player is not online.
Shared

HealPlayer

#
JRS.HealPlayer([source])

Fills health and stamina cores. On the server pass the player id; on the client it heals the local player.

lua
JRS.HealPlayer(src)
ArgumentTypeMeaning
sourcenumberServer only. Player server id.
Server

IsPlayerPvpEnabled

#
exports.jrs_core:IsPlayerPvpEnabled(source)

Whether a player can be damaged by other players. Reads the jrsPvp state bag, or the gameplay config when it is unset.

lua
if not exports.jrs_core:IsPlayerPvpEnabled(target) then return end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue when PvP is on.
Server

SetPlayerPvp

#
exports.jrs_core:SetPlayerPvp(source, state, silent?)

Turns PvP on or off for one player. TogglePlayerPvp(source) flips it.

lua
exports.jrs_core:SetPlayerPvp(src, false, true)
ArgumentTypeMeaning
sourcenumberPlayer server id.
statebooleantrue to allow PvP.
silentbooleanoptionaltrue hides the on-screen notice.

Online Players#

GetPlayers comes from the core table. The three exports after it belong to the free edition player object in server/jrs_player.lua, which wraps a loaded character in a table with methods.

Server

GetPlayers

#
JRS.GetPlayers()

Online players that have a character loaded. GetOnlinePlayerCount() counts everyone connected.

lua
for _, p in ipairs(JRS.GetPlayers().players) do
    JRS.NotifyTip(p.source, 'Server event starting', 5000)
end
Returnstable{ players = { { source = id }, ... }, count = n }.
Server

GetPlayer

#
exports.jrs_core:GetPlayer(source)

Returns the player object, built on first use. Methods are called with a colon: GetName, GetCharId, GetJob, GetJobGrade, GetJobLabel, SetJob(job, grade), GetGroup, SetGroup(group), IsAdmin, GetMoney, AddMoney(amount), RemoveMoney(amount), the same three for Gold and Rol, GetXP, GetLevel, AddXP(amount, reason), RemoveXP(amount, reason) and Notify(text, duration).

lua
local p = exports.jrs_core:GetPlayer(src)
if p and p:RemoveMoney(10) then
    p:Notify('Paid $10 for the room', 4000)
end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable | nilThe player object, or nil without a character.
Server

GetPlayerByCharId

#
exports.jrs_core:GetPlayerByCharId(charId)

Finds the online player object for a character id.

lua
local owner = exports.jrs_core:GetPlayerByCharId(house.owner)
ArgumentTypeMeaning
charIdnumberCharacter id.
Returnstable | nilPlayer object, or nil when that character is offline.
Server

GetAllPlayers

#
exports.jrs_core:GetAllPlayers()

Player objects for everyone in game with a character.

lua
for _, p in ipairs(exports.jrs_core:GetAllPlayers()) do print(p:GetName()) end
ReturnstableArray of player objects.

Position And Instances#

Moving a player, pointing them somewhere, or putting them in a routing bucket of their own. Players in different buckets do not see or hit each other, and the client hears about every bucket change through jrs_core:instanceChanged (see Events).

Server

TeleportPlayer

#
JRS.TeleportPlayer(source, x, y, z, heading?)

Sends a player to a position. On the client use JRS.TeleportToCoords(x, y, z, heading) or JRS.TeleportToWaypoint().

lua
JRS.TeleportPlayer(src, 2717.1, -1441.3, 46.1, 120.0)
ArgumentTypeMeaning
sourcenumberPlayer server id.
xnumberX.
ynumberY.
znumberZ.
headingnumberoptionalHeading.
Server

SetWaypoint

#
JRS.SetWaypoint(source, coords, name?, color?)

Shows the 3D destination marker to a player. RemoveWaypoint(source) hides it.

lua
JRS.SetWaypoint(src, vector3(-361.2, 791.7, 116.2), 'Doctor')
ArgumentTypeMeaning
sourcenumberPlayer server id.
coordsvector3Destination.
namestringoptionalLabel above the marker.
colorstringoptionalMarker colour.
Server

SetPlayerInstance

#
JRS.SetPlayerInstance(source, instance)

Moves a player into a routing bucket. A number goes straight to that bucket. A string is treated as a room name: the core reuses the bucket of a live room with that name, or picks a free one between 1 and 63 and remembers the name, so two scripts never have to agree on bucket numbers.

lua
local ok, bucket = JRS.SetPlayerInstance(src, 'house_' .. houseId)
-- later
JRS.SetPlayerInstance(src, 0)
ArgumentTypeMeaning
sourcenumberPlayer server id.
instancenumber | stringBucket id, or a room name. Use 0 for the shared world.
Returnsboolean, numbertrue and the bucket id, or false.
Client

SetPlayerInstance (client)

#
JRS.SetPlayerInstance(instance)

Sends the move request for the local player to the server, which applies the same room-name rules. Passing 0 also takes the player out of every named room, and an empty room is freed. JRS.instancePlayers(instance) is kept as an alias for older scripts.

lua
-- everyone seated at the same card table shares one room
JRS.SetPlayerInstance('cardtable_' .. tableId)
ArgumentTypeMeaning
instancenumber | stringRoom name, or 0 for the shared world.

Notifications#

Start with the toast helpers: Notify, Toast, ShowNotification and the client shortcuts render in the core's own toast style and are what most JRS scripts use. The native game feeds come after them, grouped by job: quick feedback lines, icon cards, banners, then mission results and alerts that play a sound. Every native style exists on both sides; on the server pass the player id first, on the client start at the text. Durations are in milliseconds, and each style is also an export, for example exports.jrs_core:NotifyTip(...).

Shared

Notify

#
JRS.Notify([source,] text, notifyType?, duration?, title?)

The general purpose notice. It goes through the right tip path, which the core routes to its toast renderer. On the server only text and duration are used.

lua
JRS.Notify(src, 'Saved', 'success', 3000)
ArgumentTypeMeaning
textstringMessage.
notifyTypestringoptionalClient only: info, success, error, warning or reward.
durationnumberoptionalDefaults to 3500.
titlestringoptionalClient only heading.
Returnsbooleanfalse for empty text.
Shared

Toast

#
JRS.Toast([source,] text, notifyType?, duration?, title?)

Shows a styled toast and tags it with the name of the calling resource.

lua
JRS.Toast(src, 'Horse stabled', 'info', 4000, 'Stable')
ArgumentTypeMeaning
textstringMessage.
notifyTypestringoptionalinfo, success, error, warning or reward.
durationnumberoptionalTime on screen.
titlestringoptionalHeading.
Returnsbooleanfalse for empty text.
Shared

ShowNotification

#
JRS.ShowNotification([source,] payload)

Toast built from one table, for when you want to set several options at once.

lua
JRS.ShowNotification(src, { text = 'Bounty claimed', type = 'reward', duration = 5000 })
ArgumentTypeMeaning
payloadtable{ text, type, duration, title }.
Returnsbooleanfalse when the payload is not a table.
Client

Success

#
JRS.Success(text, duration?, title?)

Shortcut toasts by type: Info, Success, ErrorNotify, WarningNotify and RewardNotify all take the same arguments.

lua
JRS.Success('Recipe learned')
JRS.ErrorNotify('Not enough wood', 3000)
ArgumentTypeMeaning
textstringMessage.
durationnumberoptionalTime on screen.
titlestringoptionalHeading.
Returnsbooleantrue when shown.
Shared

NotifyRightTip

#
JRS.NotifyRightTip([source,] text, duration)

Short message on the right side. Good default for "you received" style feedback.

lua
JRS.NotifyRightTip(src, 'You sold 4 pelts', 4000)
ArgumentTypeMeaning
sourcenumberServer only. Player server id.
textstringMessage.
durationnumberTime on screen.
Shared

NotifyTip

#
JRS.NotifyTip([source,] text, duration)

Small hint in the top left.

lua
JRS.NotifyTip('Press G to open the camp menu', 5000)
ArgumentTypeMeaning
textstringMessage.
durationnumberTime on screen.
Shared

NotifyBasicTop

#
JRS.NotifyBasicTop([source,] text, duration)

One plain line at the top.

lua
JRS.NotifyBasicTop(src, 'Storm incoming', 3000)
ArgumentTypeMeaning
textstringMessage.
durationnumberTime on screen.
Shared

NotifyBottomRight

#
JRS.NotifyBottomRight([source,] text, duration)

Small text in the lower right corner.

lua
JRS.NotifyBottomRight(src, 'Autosaved', 2000)
ArgumentTypeMeaning
textstringMessage.
durationnumberTime on screen.
Shared

NotifyCenter

#
JRS.NotifyCenter([source,] text, duration)

Text in the middle of the screen.

lua
JRS.NotifyCenter(src, 'Round two', 2500)
ArgumentTypeMeaning
textstringMessage.
durationnumberTime on screen.
Shared

NotifyLeft

#
JRS.NotifyLeft([source,] title, subtitle, dict, icon, duration, color?)

Card on the left with a texture icon.

lua
JRS.NotifyLeft(src, 'Bank', 'Deposit done', 'menu_textures', 'menu_icon_tick', 4000, 'COLOR_GREEN')
ArgumentTypeMeaning
titlestringBold first line.
subtitlestringSecond line.
dictstringTexture dictionary of the icon.
iconstringTexture name.
durationnumberTime on screen.
colorstringoptionalColour name, defaults to COLOR_WHITE.
Shared

NotifyLeftRank

#
JRS.NotifyLeftRank([source,] title, subtitle, dict, icon, duration, color?)

Same layout as NotifyLeft in the rank-up style.

lua
JRS.NotifyLeftRank(src, 'Level 12', 'Fishing', 'toast_awards_set_h', 'awards_set_h_006', 5000)
ArgumentTypeMeaning
titlestringFirst line.
subtitlestringSecond line.
dictstringTexture dictionary.
iconstringTexture name.
durationnumberTime on screen.
colorstringoptionalColour name.
Shared

NotifyAdvanced

#
JRS.NotifyAdvanced([source,] text, dict, icon, textColor, duration, quality?)

Transaction-style card on the right with a texture icon, coloured text and the positive transaction sound. The misspelled NotifyAvanced still works.

lua
JRS.NotifyAdvanced(src, 'Bought: fishing rod', 'menu_textures', 'menu_icon_tick', 'COLOR_PURE_WHITE', 4000)
ArgumentTypeMeaning
textstringMessage.
dictstringTexture dictionary.
iconstringTexture name.
textColorstringColour name.
durationnumberTime on screen.
qualitynumberoptionalAccepted for compatibility. The feed only draws it when an internal flag is set, which this wrapper never does, so today it has no visible effect.
Shared

NotifyTop

#
JRS.NotifyTop([source,] text, location, duration)

Big location banner at the top, like entering a town.

lua
JRS.NotifyTop(src, 'Welcome', 'Valentine', 4000)
ArgumentTypeMeaning
textstringMain text.
locationstringSmaller location line.
durationnumberTime on screen.
Shared

NotifySimpleTop

#
JRS.NotifySimpleTop([source,] title, subtitle, duration)

Two-line banner at the top centre.

lua
JRS.NotifySimpleTop(src, 'Race', 'Starts in 10 seconds', 3000)
ArgumentTypeMeaning
titlestringFirst line.
subtitlestringSecond line.
durationnumberTime on screen.
Shared

NotifyObjective

#
JRS.NotifyObjective([source,] text, duration)

Mission objective line at the bottom of the screen.

lua
JRS.NotifyObjective(src, 'Deliver the crate to Rhodes', 8000)
ArgumentTypeMeaning
textstringObjective.
durationnumberTime on screen.
Shared

NotifyUpdate

#
JRS.NotifyUpdate([source,] title, message, duration)

"Mission updated" style banner.

lua
JRS.NotifyUpdate(src, 'New stop', 'Head to Strawberry', 4000)
ArgumentTypeMeaning
titlestringFirst line.
messagestringSecond line.
durationnumberTime on screen.
Shared

NotifyFail

#
JRS.NotifyFail([source,] title, subtitle, duration)

Red "mission failed" style banner.

lua
JRS.NotifyFail(src, 'Delivery failed', 'The wagon was destroyed', 5000)
ArgumentTypeMeaning
titlestringFirst line.
subtitlestringSecond line.
durationnumberTime on screen.
Shared

NotifyWarning

#
JRS.NotifyWarning([source,] title, message, audioRef, audioName, duration)

Warning banner with a sound.

lua
JRS.NotifyWarning(src, 'Wanted', 'Lawmen are on the way', 'Ledger_Sounds', 'INFO_HIDE', 5000)
ArgumentTypeMeaning
titlestringFirst line.
messagestringSecond line.
audioRefstringSound set.
audioNamestringSound name.
durationnumberTime on screen.
Shared

NotifyDead

#
JRS.NotifyDead([source,] title, audioRef, audioName, duration)

Death screen style title with a sound.

lua
JRS.NotifyDead(src, 'You were shot', 'Ledger_Sounds', 'INFO_HIDE', 4000)
ArgumentTypeMeaning
titlestringText.
audioRefstringSound set.
audioNamestringSound name.
durationnumberTime on screen.

Native Buffers (DataView)#

Some RDR3 natives, including the UI feed calls behind the native notifications above, take pointers to C structs rather than plain values. Plain Lua cannot lay out those bytes, so the core carries DataView, a small byte buffer, and fills its own feed structs with it. The function below is the same call NotifyBasicTop makes inside the core, rebuilt for your own script:

lua
local JRS = exports.jrs_core:GetCoreObject()

local function TopLine(text, duration)
    local config = DataView.ArrayBuffer(8 * 7)
    config:SetInt32(0, duration)

    local data = DataView.ArrayBuffer(8 * 7)
    data:SetInt64(8 * 1, JRS.BigInt(CreateVarString(10, 'LITERAL_STRING', text)))

    Citizen.InvokeNative(0x7AE0589093A2E088, config:Buffer(), data:Buffer(), 1)
end

DataView is a global from client/dataview.lua, so your resource gets it by listing '@jrs_core/client/dataview.lua' in its client_scripts.

Client

DataView.ArrayBuffer

#
DataView.ArrayBuffer(length)

Makes a zero-filled buffer. Read and write it with GetInt32(offset), SetInt32(offset, value) and the same pair for Int8, Uint8, Int16, Uint16, Uint32, Int64, Uint64, Float32, Float64, LuaInt, LuaNum and String. Buffer() returns the raw string to pass to a native.

lua
local view = DataView.ArrayBuffer(16)
view:SetFloat32(0, 1.5)
print(view:GetFloat32(0), view:ByteLength())
ArgumentTypeMeaning
lengthnumberSize in bytes.
ReturnstableThe view.

Server And Client Callbacks#

Callbacks let one side ask the other for a value. The object methods below are limited to 30 calls per second per player, 64 KB of data, and give up after 10 seconds.

Server

RegisterServerCallback

#
JRS.RegisterServerCallback(name, handler)

Answers client requests. The handler gets the player id and the client's arguments; what it returns goes back.

lua
JRS.RegisterServerCallback('jrs_stores:price', function(src, item)
    return Prices[item] or 0
end)
ArgumentTypeMeaning
namestringUnique name, up to 128 characters.
handlerfunctionfunction(source, ...) return values end.
Returnsbooleanfalse for a bad name or handler.
Server

TriggerClientCallback

#
JRS.TriggerClientCallback(source, name, ...)

Asks one client for a value and waits for the answer. Call it inside a thread.

lua
local ok, street = JRS.TriggerClientCallback(src, 'myscript:street')
ArgumentTypeMeaning
sourcenumberPlayer server id.
namestringClient callback name.
...anyArguments.
Returnsboolean, ...true and the client's values, or false and a reason such as timeout.
Server

Rpc

#
JRS.Rpc(name, handler)

Registers a callback in the older ticket system that client JRS.Rpc calls reach. The handler returns its answer.

lua
JRS.Rpc('jrs_fishing:canFish', function(src, spot)
    return JRS.GetItemCount(src, 'fishing_rod') > 0
end)
ArgumentTypeMeaning
namestringCallback name.
handlerfunctionfunction(source, ...) return values end.
Returnsbooleantrue when registered.
Client

Rpc (client)

#
JRS.Rpc(name, callback, ...)

Calls a server Rpc handler without blocking. Your callback runs with the answer.

lua
JRS.Rpc('jrs_fishing:canFish', function(allowed)
    if allowed then StartFishing() end
end, 'lake_owanjila')
ArgumentTypeMeaning
namestringCallback name.
callbackfunctionReceives the returned values.
...anyArguments.
Client

CallServer

#
JRS.CallServer(name, ...)

Calls a RegisterServerCallback handler and waits. Run it in a thread.

lua
CreateThread(function()
    local ok, price = JRS.CallServer('jrs_stores:price', 'bread')
    if ok then print('bread costs', price) end
end)
ArgumentTypeMeaning
namestringServer callback name.
...anyArguments.
Returnsboolean, ...true and the values, or false and a reason.
Client

RegisterClientCallback

#
JRS.RegisterClientCallback(name, handler)

Answers server requests on this client.

lua
JRS.RegisterClientCallback('myscript:street', function()
    local c = GetEntityCoords(PlayerPedId())
    return GetStreetNameFromHashKey(GetStreetNameAtCoord(c.x, c.y, c.z))
end)
ArgumentTypeMeaning
namestringCallback name.
handlerfunctionfunction(...) return values end.
Returnsbooleanfalse for a bad name or handler.

Console Logging#

Server

Debug

#
JRS.Debug(text)

Prints a green tagged line to the server console. JRS.Error(text) prints a red one.

lua
JRS.Debug('jrs_ranch loaded 14 ranches')
JRS.Error('jrs_ranch: missing config for ranch 3')
ArgumentTypeMeaning
textstringMessage.
Server

Report

#
JRS.Report(id, title, text)

Prints a highlighted report block, useful for problems an admin must see in the log.

lua
JRS.Report('RANCH-01', 'Duplicate ranch id', 'Ranch 3 appears twice in config.lua')
ArgumentTypeMeaning
idstringShort report id.
titlestringHeading.
textstringDetails.