Core
Core Functions
The main API exposed by rsg-core.
Every RSG resource starts by grabbing the core object, which exposes the framework's shared functions.
local RSGCore = exports['rsg-core']:GetCoreObject()Server functions
Commonly used helpers on the server:
| Function | Description |
|---|---|
RSGCore.Functions.GetPlayer(source) | Returns the player object for a session id. |
RSGCore.Functions.GetPlayerByCitizenId(cid) | Returns a player by their unique citizen id. |
RSGCore.Functions.GetPlayers() | Returns a table of all online player sources. |
RSGCore.Functions.CreateCallback(name, cb) | Registers a server callback. |
RSGCore.Functions.CreateUseableItem(item, cb) | Makes an inventory item usable. |
Server callbacks
Callbacks let the client request data from the server and wait for a response:
RSGCore.Functions.CreateCallback('rsg-reward:server:getBalance', function(source, cb)
local Player = RSGCore.Functions.GetPlayer(source)
cb(Player.PlayerData.money['cash'])
end)RSGCore.Functions.TriggerCallback('rsg-reward:server:getBalance', function(balance)
print('You have $' .. balance)
end)Client functions
Commonly used helpers on the client:
| Function | Description |
|---|---|
RSGCore.Functions.GetPlayerData() | Returns the local player's cached data. |
RSGCore.Functions.Notify(text, type) | Shows a notification. |
RSGCore.Functions.TriggerCallback(name, cb, ...) | Calls a server callback. |
RSGCore.Functions.SpawnVehicle(model, cb, coords) | Spawns a vehicle/horse. |
Tip
Prefer callbacks over manually pairing TriggerServerEvent / TriggerClientEvent when
you need a response — they are cleaner and less error prone.

