JRS COREالوثائق

Server API

The server side API and the player object returned by getInformation

Note
هذه الصفحة غير مترجمة بعد. يتم عرض النسخة الإنجليزية.
Note

Server side. The examples describe the JRS Core bridge. GUM and RSG share most names, but not all (for example the weapon helpers), so check your bridge file before relying on one.

Getting the API#

lua
local gum
TriggerEvent("getApi", function(api) gum = api end)

getApi is a local server event. It is intentionally not a net event, so a client can never trigger it.

Functions#

registerItem#

Makes an inventory item usable.

lua
gum.registerItem("bandage", function(data)
    print(data.source, data.item.id, data.item.name)
    -- data.item.metadata is always a table
end)
notify#
lua
gum.notify(source, "Title", "Message", "bread", 4000)
getAllItems#

Returns a table keyed by item name with item, label and weight.

setGrade / removeJob#

Works for online and offline characters. Offline changes go through a prepared database statement.

lua
gum.setGrade(identifier, charIdentifier, "police", 2)
gum.removeJob(identifier, charIdentifier, "police")
Database helpers#

CharacterTable(), JobColumn(), JobGradeColumn(), SteamColumn(), CharIdColumn() and getFramework() return the table and column names of the active framework. For JRS they are jrs_characters, job, jobgrade, identifier, charidentifier and jrs.

The player object#

lua
gum.getInformation(source, function(player)
    if not player then return end -- character not selected yet
    local money = player.getMoney()
end)

The callback receives nil until the character is ready. On JRS every function re-checks that the same character is still selected, so a stale player object cannot act on another character after a relog.

Group Functions
Identity getGroup, getFirstname, getLastname, getSteamIdentifier, getCharIdentifier
Money getMoney, getGold, addMoney, removeMoney, addGold, removeGold
Job getJob, getGrade, setJob(job, grade, active), setGrade(job, grade)
Items getInventory, getCountItem, canCarryItem, addItem, removeItem, removeItemId
Metadata getMetadata(id, item, key), setMetadata(id, key, value, item)
Weapons canCarryWeapon, createWeapon, giveWeapon
Storage createStorage, openStorage, updateStorage, closeInv
Other chanceSkin(skin), discord(webhook, title, lines, color, steam, charId, first, last)

Discord logs#

lua
player.discord(
    "https://discord.com/api/webhooks/123/abc",
    "Bought a horse",
    { "Price: 120", "Horse: Arabian" },
    3447003,
    player.getSteamIdentifier(), player.getCharIdentifier(),
    player.getFirstname(), player.getLastname()
)
  • Only real discord.com webhook URLs are accepted. Anything else is rejected and logged.
  • Mentions are switched off (allowed_mentions), so a character called @everyone cannot ping your staff.
  • Title, description and fields are cut to Discord's limits.
Warning

Keep webhook URLs in server side config files. Never put them in a client script or send them to a client.