# 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 <br>

#### Syntax

```lua
jo.framework.UserClass:get(source)
```

#### Parameters

`source` : _integer_
> The source ID of the player
>

#### Return Value

Type : _[UserClass](#userclass-methods)_

> Return a User class object containing player data and methods

## UserClass Methods

### `[Server]` UserClass:addMoney()

Adds money to the player <br>

#### 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 <br>

#### Syntax

```lua
UserClass:canBuy(price, moneyType, removeIfCan)
```

#### Parameters

`price` : _number|table_
> The amount of money the player needs to have <br> if table: {money = 1, gold = 1, rol = 1}
>

`moneyType` : _integer_ `[Optional]`
> `0`: dollar, `1`: gold, `2`: rol <br> default:`1`
>

`removeIfCan` : _boolean_ `[Optional]`
> Remove the money if the player has enough <br> default:`false`
>

#### Return Value

Type : _boolean_

> Return `true` if the player has more money than the amount

---

### `[Server]` UserClass:getIdentifiers()

Retrieves all identifiers associated with the player <br>

#### Syntax

```lua
UserClass:getIdentifiers()
```

#### Return Value

Type : _table_

> Return the player's identifiers <br> `identifiers.identifier` - Unique identifier of the player <br> `identifiers.charid` - Unique id of the player

---

### `[Server]` UserClass:getJob()

Returns the current job assigned to a player <br>

#### 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 <br>

#### 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 <br>

#### 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 <br>

#### 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 <br>

#### Syntax

```lua
UserClass:giveGold(amount)
```

#### Parameters

`amount` : _number_
> The amount of gold to add
>

---

### `[Server]` UserClass:removeMoney()

Removes money from the player <br>

#### 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 <br>

#### 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
