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
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
Example
local user = jo.framework.UserClass:get(source)
-- OR --
local user = jo.framework:getUser(source)UserClass Methods
Server UserClass:addMoney()
Adds money to the player
Syntax
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
Example
local source = 1
local amount = 100.0
local moneyType = 1
local user = jo.framework:getUser(source)
user:addMoney(amount, moneyType)Server UserClass:canBuy()
Checks if a player has sufficient funds of a specified currency type
Syntax
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
trueif the player has more money than the amount
Example
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
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
Example
local source = 1
local user = jo.framework:getUser(source)
local identifiers = user:getIdentifiers()
print(identifiers.identifier)
print(identifiers.charid)Server UserClass:getJob()
Returns the current job assigned to a player
Syntax
UserClass:getJob()Return Value
Type : string
Returns the job name of the player
Example
local source = 1
local user = jo.framework:getUser(source)
local job = user:getJob()
print(job)Server UserClass:getMoney()
Gets the amount of money a player has of the specified type
Syntax
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
Example
local source = 1
local user = jo.framework:getUser(source)
local dollar = user:getMoney(1)
local gold = user:getMoney(2)
print(dollar, gold)Server UserClass:getRPName()
Returns the roleplay name (first and last name) of the player
Syntax
UserClass:getRPName()Return Value
Type : string
Returns the formatted first and last name of the player
Example
local source = 1
local user = jo.framework:getUser(source)
local name = user:getRPName()
print(name)Server UserClass:giveGold()
Adds gold to the player's account
Syntax
UserClass:giveGold(amount)Parameters
amount : number
The amount of gold to add
Example
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
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
Example
local source = 1
local amount = 100.0
local moneyType = 1
local user = jo.framework:getUser(source)
user:removeMoney(amount, moneyType)