Server Side - CodexCore API

This documentation is for developers


🧠 CodexCore.RequestCoreAPI()

Returns the core object based on the configured framework.

βœ… Correct Usage:

local Core = CodexCore.RequestCoreAPI()

❌ Wrong Usage:

local Core = exports['vorp_core']:GetCore() -- Avoid calling directly

πŸ—ƒοΈ CodexCore.ExecuteSql(query, params)

Executes SQL using the configured SQL plugin.

βœ… Correct Usage:

local users = CodexCore.ExecuteSql("SELECT * FROM users WHERE job = @job", {["@job"] = "sheriff"})

❌ Wrong Usage:

MySQL.Sync.fetchAll(...) -- Don't call database plugins directly

πŸŽ’ CodexCore.RequestInventoryAPI()

Returns the inventory object (VORP only).

βœ… Correct Usage (VORP only):

local Inventory = CodexCore.RequestInventoryAPI()

❌ Wrong Usage:

local Inventory = exports['rsg-inventory']:GetInventory() -- Not supported

πŸ§β€β™‚οΈ CodexCore.GetPlayerFromId(source)

Returns the player object from source.

βœ… Correct Usage:

local player = CodexCore.GetPlayerFromId(source)

❌ Wrong Usage:

local player = source -- Just using source is not enough

πŸ†” CodexCore.GetCharacterIdentifier(source)

Gets the character's identifier from the source.

βœ… Correct Usage:

local charId = CodexCore.GetCharacterIdentifier(source)

❌ Wrong Usage:

local charId = player.cid -- Without checking framework

πŸ’Ό CodexCore.GetJob(source)

Gets the job of a player.

βœ… Correct Usage:

if CodexCore.GetJob(source) == 'sheriff' then
    -- Do something
end

❌ Wrong Usage:

local job = player.job -- Not universal

πŸ’° CodexCore.GetMoney(source)

Returns the player's cash money.

βœ… Correct Usage:

local money = CodexCore.GetMoney(source)

❌ Wrong Usage:

local money = User.Functions.GetMoney("bank") -- Only supports cash

🟑 CodexCore.GetGold(source)

Returns the player's gold.

βœ… Correct Usage:

local gold = CodexCore.GetGold(source)

❌ Wrong Usage:

local gold = 0 -- Hardcoded

πŸͺ™ CodexCore.GetCents(source)

Returns player's cents (VORP only).

βœ… Correct Usage (VORP):

local cents = CodexCore.GetCents(source)

❌ Wrong Usage (RSG):

-- There are no cents in RSG

βœ… CodexCore.IsLoaded(source)

Returns true if the character is loaded.

βœ… Correct Usage:

if CodexCore.IsLoaded(source) then
    -- Player is ready
end

❌ Wrong Usage:

if IsPlayerLoaded(source) then -- Not a valid native
end

πŸ’΅ CodexCore.GetAccountMoney(source, account)

Returns the player's money for a specific account.

βœ… Correct Usage:

local cash = CodexCore.GetAccountMoney(source, 0)

🧾 Accounts:

  • 0 = Money

  • 1 = Gold

  • 2 = Cents (only VORP)


βž• CodexCore.AddAccountMoney(source, account, amount)

Adds money to a specific account.

βœ… Correct Usage:

CodexCore.AddAccountMoney(source, 0, 100) -- Add 100 money

❌ Wrong Usage:

Character.money += 100 -- Won’t sync

βž– CodexCore.RemoveAccountMoney(source, account, amount)

Removes money from a specific account.

βœ… Correct Usage:

CodexCore.RemoveAccountMoney(source, 1, 2) -- Remove 2 gold

🧩 CodexCore.RegisterServerCallback(name, cb)

Register a server-side callback.

βœ… Correct Usage:

CodexCore.RegisterServerCallback("my_callback", function(source, cb)
    local money = CodexCore.GetMoney(source)
    cb(money)
end)

πŸ“¦ CodexCore.AddItem(source, item, amount)

Gives an item to the player.

βœ… Correct Usage:

CodexCore.AddItem(source, "bread", 2)

❌ CodexCore.RemoveItem(source, item, amount)

Removes an item from the player.

βœ… Correct Usage:

CodexCore.RemoveItem(source, "bread", 1)

πŸ”’ CodexCore.GetItemCount(source, item)

Returns how many of a specific item the player has.

βœ… Correct Usage:

local amount = CodexCore.GetItemCount(source, "bread")

πŸ“₯ CodexCore.CanCarryItem(source, item, amount)

Checks if the player can carry the item (VORP only).

βœ… Correct Usage:

if CodexCore.CanCarryItem(source, "apple", 5) then
    -- Add item
end

🍎 CodexCore.RegisterUsableItem(item, cb)

Registers a usable item callback.

βœ… Correct Usage:

CodexCore.RegisterUsableItem("bread", function(source)
    print("Used bread!")
end)

❌ CodexCore.CloseInventory(source)

Closes the player’s inventory UI (VORP only).

βœ… Correct Usage:

CodexCore.CloseInventory(source)

πŸ‘₯ CodexCore.GetJobPlayers(job)

Returns all players with a specific job or jobs.

βœ… Correct Usage:

local sheriffs = CodexCore.GetJobPlayers("sheriff")

βœ… Multiple Jobs:

local lawmen = CodexCore.GetJobPlayers({"sheriff", "deputy"})

πŸͺͺ CodexCore.GetUserIdentifier(source)

Returns the player's license identifier.

βœ… Correct Usage:

local license = CodexCore.GetUserIdentifier(source)

🧬 CodexCore.GetUsedCharacter(source)

Returns the player's current character object or citizenid.

βœ… Correct Usage:

local char = CodexCore.GetUsedCharacter(source)

Last updated

Was this helpful?