Skip to content

Framework Class ​

A powerfull library to build a script compatible with all Frameworks. The module architecture is based on a folder structure, with one folder per framework. With this structure, the data from one framework can't intefere with date from another one.

INFO

The framework is automatically detected once the module is started based on resource in the server.

TIP

If you have a custom framework, you can overwrite methods by added the one you want edit inside _custom/FrameworkClass.lua file.

List of compatible frameworks
  • VORP
  • RedEM:RP old
  • RedEM:RP 2023 (reboot)
  • QBR
  • QR
  • RSG
  • RPX
  • TPZ

Configuration Variables (Convars) ​

ConvarSideTypeDefaultDescription
jo_libs:frameworkSharedStringfalseForce the framework

jo.framework Methods ​

Client jo.framework:getMyIdentifiers() ​

A function to get the user identifiers

Syntax ​

lua
jo.framework:getMyIdentifiers()

Server jo.framework:addItemInInventory() ​

Adds a specific item to a custom inventory with optional metadata and wait parameter

Syntax ​

lua
jo.framework:addItemInInventory(source, invId, item, quantity, metadata, needWait)

Parameters ​

source : integer

The source ID of the player

invId : string

The unique ID of the inventory

item : string

The name of the item

quantity : integer

The quantity of the item

metadata : table Optional

The metadata of the item

needWait : boolean Optional

If need to wait after the SQL insertion
default:false

Example ​

lua
local source = 1
local id = "locker:sheriff"
local item = "mdt_report"
local quantity = 1
local metadata = { id = 321 }
jo.framework:addItemInInventory(source, id, item, quantity, metadata)

Server jo.framework:addMoney() ​

A function to give money to a player

Syntax ​

lua
jo.framework:addMoney(source, amount, moneyType)

Parameters ​

source : integer

The source ID of the player

amount : number

The amount of money to add

moneyType : integer Optional

0: dollar, 1: gold, 2: rol
default:0

Return Value ​

Type : boolean

Return true if the money is successfully added

Example ​

lua
local source = 1
local amount = 10.5
local moneyType = 0
local isAdded = jo.framework:addMoney(source,amount,moneyType)
print(isAdded)

Server jo.framework:canUseItem() ​

Checks if a player has the required quantity of a specific item in their inventory and optionally removes it

Syntax ​

lua
jo.framework:canUseItem(source, item, amount, meta, remove)

Parameters ​

source : integer

The source ID of the player

item : string

The name of the item need to use

amount : integer

The quantity of the item

meta : table Optional

The metadata of the item

remove : boolean Optional

If the item has to be removed
default:false

Return Value ​

Type : boolean

Return true if the player has enough quantity of the item

Example ​

lua
local source = 1
local item = "water"
local amount = 1
local canUseWater = jo.framework:canUseItem(source, item, amount, nil, nil)
print(canUseWater)

Server jo.framework:canUserBuy() ​

Checks if a player has sufficient funds of a specified currency type

Syntax ​

lua
jo.framework:canUserBuy(source, amount, moneyType, removeIfCan)

Parameters ​

source : integer

The source ID of the player

amount : number

The amount of money the player needs to have

moneyType : integer|string Optional

0: dollar, 1: gold, 2: rol
default:1

removeIfCan : boolean Optional

Remove the money if the player has enough
default:false

Return Value ​

Type : boolean

Returns true if the player has more money than the amount

Example ​

lua
local price = 103
local source = 1
print(jo.framework:canUserBuy(source, 103))
-- Expected output : true if the player has more than $103

Server jo.framework:canUserPayWith() ​

A function that checks if a player can pay multiple prices

Syntax ​

lua
jo.framework:canUserPayWith(source, prices, removeIfCan)

Parameters ​

source : integer

The source ID of the player

prices : table

The prices to check

removeIfCan : boolean Optional

Remove the prices if the player can pay

Return Value ​

Type : boolean,


Server jo.framework:createInventory() ​

Creates a custom inventory with configurable slots, weight limits, and item restrictions

Syntax ​

lua
jo.framework:createInventory(invName, name, invConfig)

Parameters ​

invName : string

Unique id of the inventory

name : string

Label of the inventory

invConfig : table

Configuration of the inventory

invConfig.maxSlots : integer - Max slot of the inventory

invConfig.maxWeight : float - Max weight of the inventory

invConfig.acceptWeapons : boolean - Whether the inventory accepts weapons Optional

invConfig.shared : boolean - If the inventory is shared between players Optional

invConfig.ignoreStackLimit : boolean - If the inventory can overcoming stack limits Optional

invConfig.whitelist : table - Restrict the list of items that can be put in the inventory Optional

invConfig.whitelistˌ_x_ˌitem : string - Name of the whitelisted item

invConfig.whitelistˌ_x_ˌlimit : integer - Stack limit of this item

Example ​

lua
local id = "locker:sheriff"
local label = "Sheriff's locker"
local definition = {
  maxSlots = 100,
  maxWeight = 1000.0,
  acceptWeapons = false,
  shared = true,
  whitelist = {
    { item = "mdt_report", limit = 1000 }
  }
}
jo.framework:createInventory(id, label, definition)

Server jo.framework:get() ​

Returns the name of the current active framework being used

Syntax ​

lua
jo.framework:get()

Return Value ​

Type : string

Return the name of the current framework :
"VORP" or "RedEM" or "RedEM2023" or "qbr" or "rsg" or "qr" or "rpx"

Example ​

lua
local frameworkName = jo.framework:get()
print(frameworkName)

Server jo.framework:getItemCount() ​

Gets the quantity of a specific item in a player's inventory

Syntax ​

lua
jo.framework:getItemCount(source, item, meta)

Parameters ​

source : integer

The source ID of the player

item : string

The name of the item

meta : table Optional

The metadata of the item

Return Value ​

Type : integer

Return the total quantity of the item in the player's inventory


Server jo.framework:getItemsFromInventory() ​

Retrieves all items from a specific inventory with their quantities and metadata

Syntax ​

lua
jo.framework:getItemsFromInventory(invId)

Parameters ​

invId : string

The unique ID of the inventory

Return Value ​

Type : table

Return the list of items with structure :
item.amount : integer - The amount of the item
item.id : integer - The id of the item
item.item : string - The name of the item
item.metadata : table - The metadata of the item

Example ​

lua
local source = 1
local id = "locker:sheriff"
local items = jo.framework:getItemsFromInventory(source, id)
for key, item in pairs(items) do
  print(item.item)
end

Server jo.framework:getJob() ​

Returns the current job assigned to a player

Syntax ​

lua
jo.framework:getJob(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : string

Return the job name of the player

Example ​

lua
local source = 1
print(jo.framework:getJob(source))

Server jo.framework:getRPName() ​

Returns the roleplay name (first and last name) of the player

Syntax ​

lua
jo.framework:getRPName(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : string

Return the formatted first and last name of the player

Example ​

lua
local source = 1
print(jo.framework:getRPName(source))

Server jo.framework:getSourceFromIdentifiers() ​

Retrieves the source ID from identifiers

Syntax ​

lua
jo.framework:getSourceFromIdentifiers(identifier, charid)

Parameters ​

identifier : string

The identifier to search for

charid : string

The character ID to search for

Return Value ​

Type : integer|boolean

Return the source ID if found, otherwise return false


Server jo.framework:getUser() ​

Retrieves a player's full UserClass object containing all player data and methods

Syntax ​

lua
jo.framework:getUser(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : UserClass

Return a User class object containing player data and methods

Example ​

lua
local source = 1
local user = jo.framework:getUser(source)
print(user:getRPName())

Server jo.framework:getUserClothes() ​

Retrieves a player's clothing data with standardized category names

Syntax ​

lua
jo.framework:getUserClothes(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : table

Return the list of clothes with standardized categories and properties

Example ​

lua
local source = 1
local clothes = jo.framework:getUserClothes(source)
log(clothes)

Server jo.framework:getUserIdentifiers() ​

Retrieves all identifiers associated with a player
Shortcut for jo.framework.UserClass:getIdentifiers() method

Syntax ​

lua
jo.framework:getUserIdentifiers(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : table

Return the player's identifiers
identifiers.identifier - Unique identifier of the player
identifiers.charid - Unique id of the player

Example ​

lua
local source = 1
local identifiers = jo.framework:getUserIdentifiers(source)
print(identifiers.charid)

Server jo.framework:getUserSkin() ​

Retrieves a player's skin data with standardized properties and formatting

Syntax ​

lua
jo.framework:getUserSkin(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : table

Return the skin data

Example ​

lua
local source = 1
local skin = jo.framework:getUserSkin(source)
log(skin)

Server jo.framework:giveItem() ​

Adds an item to a player's inventory with optional metadata

Syntax ​

lua
jo.framework:giveItem(source, item, quantity, meta)

Parameters ​

source : integer

The source ID of the player

item : string

The name of the item

quantity : integer

The amount of the item to give

meta : table Optional

The metadata of the item

Return Value ​

Type : boolean

Return true if the item is successfully given

Example ​

lua
local source = 1
local item = "water"
local amount = 1
local itemGave = jo.framework:giveItem(source, item, amount)
print(itemGave)

Server jo.framework:is() ​

Compares the current framework with a specified framework name

Syntax ​

lua
jo.framework:is(name)

Parameters ​

name : string

The name of the framework to check against
Supported frameworks :
"VORP" or "RedEM" or "RedEM2023" or "qbr" or "rsg" or "qr" or "rpx"

Return Value ​

Type : boolean

Return true if the current framework matches the name

Example ​

lua
local isVORP = jo.framework:is('VORP')
print(isVORP)

Server jo.framework:listenItemRemoved() ​

Listen when an item is removed of the player inventory

Syntax ​

lua
jo.framework:listenItemRemoved(...)

Parameters ​

item : string|function

The name of the item

callback : function

The function fired after remove the item
1st argument: source
2nd argument: the quantity removed
3rd argument: metadata of the item
4th argument: reason of the removal


Server jo.framework:mergeInventoriesConfiguration() ​

Merge inventory configuration

Syntax ​

lua
jo.framework:mergeInventoriesConfiguration(...)

Parameters ​

... : table

The inventory configurations to merge

Return Value ​

Type : table

The merged inventory configuration


Server jo.framework:onCharacterSelected() ​

Callback when a character is selected

Syntax ​

lua
jo.framework:onCharacterSelected(cb)

Parameters ​

cb : function

The callback function triggered when the character is selected, contains (source:integer, isNew:boolean)

Example ​

lua
jo.framework:onCharacterSelected(function(source)
  print('A new player select his character', source)
end)

Server jo.framework:openInventory() ​

Opens a specific inventory

Syntax ​

lua
jo.framework:openInventory(source, invName)

Parameters ​

source : integer

The source ID of the player

invName : string

The unique ID of the inventory

Example ​

lua
local source = 1
local id = "locker:sheriff"
jo.framework:openInventory(source, id)

Server jo.framework:refundUserWith() ​

A function to refund a player with multiple prices

Syntax ​

lua
jo.framework:refundUserWith(source, prices)

Parameters ​

source : integer

The source ID of the player

prices : table

The prices to refund

Return Value ​

Type : nil


Server jo.framework:registerUseItem() ​

Registers an item as usable and attaches a callback function that executes when the item is used

Syntax ​

lua
jo.framework:registerUseItem(item, closeAfterUsed, callback)

Parameters ​

item : string

The name of the item

closeAfterUsed : boolean Optional

If the inventory needs to be closed after using the item
default:true

callback : function

The function fired after use the item
1st argument: source
2nd argument: metadata of the item

Example ​

lua
jo.framework:registerUseItem('water', true, function(source, metadata)
  TriggerServerEvent('drinkWater', source)
  jo.framework:removeItem(source, 'water', 1, metadata)
end)

Server jo.framework:removeInventory() ​

Removes an inventory from the server cache, useful for reloading inventory data from the database

Syntax ​

lua
jo.framework:removeInventory(invName)

Parameters ​

invName : string

Unique id of the inventory

Example ​

lua
local id = "locker:sheriff"
jo.framework:removeInventory(id)

Server jo.framework:removeItem() ​

A function to remove an item from a player's inventory if they have enough quantity

Syntax ​

lua
jo.framework:removeItem(source, item, quantity, meta)

Parameters ​

source : integer

The source ID of the player

item : string

The name of the item to remove

quantity : integer

The quantity of the item to remove

meta : table Optional

The metadata of the item

Return Value ​

Type : boolean

Return true if the item is successfully removed

Example ​

lua
local source = 1
local item = "water"
local quantity = 2
local meta = {}
local isRemoved = jo.framework:removeItem(source, item, quantity, meta)
print(isRemoved)

Server jo.framework:removeMoney() ​

A function to remove money from a player's account

Syntax ​

lua
jo.framework:removeMoney(source, amount, moneyType)

Parameters ​

source : integer

The source ID of the player

amount : number

The amount of money to remove

moneyType : integer Optional

0: dollar, 1: gold, 2: rol
default:0

Return Value ​

Type : boolean

Return true if the money is successfully removed

Example ​

lua
local source = 1
local amount = 10.5
local moneyType = 0
local isRemoved = jo.framework:removeMoney(source, amount, moneyType)
print(isRemoved)

Server jo.framework:revertClothes() ​

Converts standardized clothing data back to framework-specific format

Syntax ​

lua
jo.framework:revertClothes(standard)

Parameters ​

standard : table

The standardized clothes data

Return Value ​

Type : table

Return clothes data with framework-specific keys

Example ​

lua
local clothes = {hats = {hash = 0x123455}}
local frameworkData = jo.framework:revertClothes(clothes)
log(frameworkData)

Server jo.framework:revertSkin() ​

Converts standardized skin data back to framework-specific format

Syntax ​

lua
jo.framework:revertSkin(standard)

Parameters ​

standard : table

The standardized skin data

Return Value ​

Type : table

Return skin data with framework-specific keys

Example ​

lua
local skin = {headIndex = 1, skinTone = 2}
local frameworkSkin = jo.framework:revertSkin(skin)
log(frameworkSkin)

Server jo.framework:sendSkinAndClothes() ​

Standardize a skin & clothes couple and send them to the client to be applied

Syntax ​

lua
jo.framework:sendSkinAndClothes(source, ped, skin, clothes)

Parameters ​

source : integer

The source ID of the player

ped : integer Optional

The entity to dress. Defaults to the player ped, client-side

skin : table

The skin data, in framework format

clothes : table

The clothes data, in framework format


Server jo.framework:standardizeClothes() ​

Converts framework-specific clothing data to a standardized format

Syntax ​

lua
jo.framework:standardizeClothes(clothes)

Parameters ​

clothes : table

The framework-specific clothes data

Return Value ​

Type : table

Return clothes data with standardized keys and structure

Example ​

lua
local clothes = { Hat = 0x12345}
local standard = jo.framework:standardizeClothes(clothes)
log(standard)
-- Expected output: `{hat = {hash = 0x12345}}`

Server jo.framework:standardizeSkin() ​

Converts framework-specific skin data to a standardized format

Syntax ​

lua
jo.framework:standardizeSkin(skin)

Parameters ​

skin : table

The framework-specific skin data

Return Value ​

Type : table

Return skin data with standardized keys for components, overlays, and expressions

Example ​

lua
local skin = { eyes = 0x1234}
local standard = jo.framework:standardizeSkin(skin)
log(standard)
-- Expected output: `{eyesIndex: 2}`

Server jo.framework:updateUserClothes() ​

Save new clothes.
The function has two ways to work:

  • With 2 arguments to save multiple clothes
  • With 3 arguments to save one piece of clothing

Syntax ​

lua
jo.framework:updateUserClothes(...)

Parameters ​

source : integer

The source ID of the player

clothes : table

The list of clothes to apply or the category name

value : table Optional

The clothing data if updating a single category

overwrite : boolean Optional

If true, the new value overwrites the previous clothes. Else, it's merged

Example ​

lua
local source = 1
local clothes = {
  pants = { hash = 2450348132 },
  boots = { hash = 3596743543 }
}
jo.framework:updateUserClothes(source, clothes)
-- OR  --
local source = 1
local category = pants
local clothes = { hash = 2450348132 }
jo.framework:updateUserClothes(source, category, clothes)

Server jo.framework:updateUserSkin() ​

Save new skin values.
The function has two ways to work:

  • With 3 arguments to save multiple skin data
  • With 4 arguments to save only one skin data

Syntax ​

lua
jo.framework:updateUserSkin(...)

Parameters ​

source : integer

The source ID of the player

skinData : table

The list of skin data with category for key and skin data for value

category : string

The category of the skin data

data : table

The skin data

overwrite : boolean Optional

If true, the new value overwrites the previous skin. Else, it's merged

Example ​

lua
local source = 1
local skin = {
  head = 394785690,
  torso = 345823423
}
local overwrite = false
jo.framework:updateUserSkin(source, skin, overwrite)
-- OR --
local source = 1
local category = "head"
local data = 394785690
local overwrite = false
jo.framework:updateUserSkin(source, category, data, overwrite)

Shared jo.framework:addItemDataToPrice() ​

A function to add inventory item data to every item cost inside a price

Syntax ​

lua
jo.framework:addItemDataToPrice(price)

Parameters ​

price : table

The price to augment

Return Value ​

Type : table

The mutated price


Shared jo.framework:getItemData() ​

A function to get an item data

Syntax ​

lua
jo.framework:getItemData(item)

Parameters ​

item : string

The name of the item

Return Value ​

Type : table|false

The item data or false if not found


Shared jo.framework:getItems() ​

A function to get the list of items

Syntax ​

lua
jo.framework:getItems()

Return Value ​

Type : table

The list of items


Shared jo.framework:loadInventoryFiles() ​

Syntax ​

lua
jo.framework:loadInventoryFiles(file)

UserClass Methods ​

Documentation for the User

Last updated: