Skip to content

User class ​

A class to get all the user information.

TIP

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

Constructor ​

Server jo.framework.UserClass:get() ​

Creates and returns a new User instance for the specified player

Syntax ​

lua
jo.framework.UserClass:get(source)

Parameters ​

source : integer

The source ID of the player

Return Value ​

Type : UserClass

Return a User class object containing player data and methods

UserClass Methods ​

Server UserClass:addMoney() ​

Adds money to the player

Syntax ​

lua
UserClass:addMoney(amount, moneyType)

Parameters ​

amount : number

The amount of money to add

moneyType : integer

The type of currency: 0: dollar, 1: gold, 2: rol


Server UserClass:canBuy() ​

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

Syntax ​

lua
UserClass:canBuy(price, moneyType, removeIfCan)

Parameters ​

price : number|table

The amount of money the player needs to have
if table:

moneyType : integer 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

Return true if the player has more money than the amount

Example ​

lua
local source = 1
local price = 20.4
local moneyType = 2
local user = jo.framework:getUser(source)
local hasEnoughGold = user:canBuy(price, moneyType)
print(hasEnoughGold)

Server UserClass:getIdentifiers() ​

Retrieves all identifiers associated with the player

Syntax ​

lua
UserClass:getIdentifiers()

Return Value ​

Type : table

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


Server UserClass:getJob() ​

Returns the current job assigned to a player

Syntax ​

lua
UserClass:getJob()

Return Value ​

Type : string

Returns the job name of the player


Server UserClass:getJobGrade() ​

Returns the current job grade assigned to a player

Syntax ​

lua
UserClass:getJobGrade()

Return Value ​

Type : number

Returns the job grade of the player


Server UserClass:getMoney() ​

Gets the amount of money a player has of the specified type

Syntax ​

lua
UserClass:getMoney(moneyType)

Parameters ​

moneyType : integer

The type of currency: 0: dollar, 1: gold, 2: rol

Return Value ​

Type : number

Return the amount for this kind of money


Server UserClass:getRPName() ​

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

Syntax ​

lua
UserClass:getRPName()

Return Value ​

Type : string

Returns the formatted first and last name of the player


Server UserClass:giveGold() ​

Adds gold to the player's account

Syntax ​

lua
UserClass:giveGold(amount)

Parameters ​

amount : number

The amount of gold to add

Example ​

lua
local source = 1
local goldAmount = 20.0
local user = jo.framework:getUser(source)
user:giveGold(goldAmount)

Server UserClass:removeMoney() ​

Removes money from the player

Syntax ​

lua
UserClass:removeMoney(amount, moneyType)

Parameters ​

amount : number

The amount of money to remove

moneyType : integer

The type of currency: 0: dollar, 1: gold, 2: rol


Server UserClass:setJob() ​

Sets the current job assigned to a player

Syntax ​

lua
UserClass:setJob(job, grade)

Parameters ​

job : string

The name of the job

grade : number

The grade of the job

Return Value ​

Type : boolean

Returns the combined result of the job and grade assignment

Last updated: