# Player `[Client]`

A library to save in the client cache the value of PlayerPedId(), his location and other useful values.  
All values are updated only if necessary.  
Very helpfull to optimize the resource and not call natives everytime.  

Alias of the module: `jo.pl`

## JO Variables

### jo.player.coords
Returns the current player coordinates.

#### Example
```lua
print(jo.player.coords)
-- OR --
print(jo.pl.coords)
-- Expected output: vec3(x,y,z)
```

### jo.player.isMale
Returns if the current player is a male or not.

#### Example
```lua
print(jo.player.isMale)
-- OR --
print(jo.pl.isMale)
-- Expected output: same value than IsPedMale(PlayerPedId())
```

### jo.player.ped
Returns the current player ped.  
This variable has a function shortcut: `jo.player()`
#### Example
```lua
print(jo.player.ped)
-- OR --
print(jo.player())
-- OR --
print(jo.pl())
-- Expected output: same value than PlayerPedId()
```

### jo.player.playerId
Returns the current player ID.

#### Example
```lua
print(jo.player.playerId)
-- OR --
print(jo.pl.playerId)
-- Expected output: same value than PlayerId()
```

### jo.player.serverId
Returns the server ID of the player.

#### Example
```lua
print(jo.player.serverId)
-- OR --
print(jo.pl.serverId)
-- Expected output: same value than GetPlayerServerId(PlayerId())

```

## JO Functions

### jo.player.didMoveSinceLastCall()

A function to know if the player moved since the last called of the function <br>

#### Syntax

```lua
jo.player.didMoveSinceLastCall(id)
```

#### Parameters

`id` : _string_
> Unique ID of call
>

#### Return Value

Type : _boolean_

> `true` if the player moved since the last call

---

### jo.player.forceUpdate()

A function to force the update of module value <br>

#### Syntax

```lua
jo.player.forceUpdate()
```

---

### jo.player.instanceChanged()

A function fired when the local player's routing bucket (instance) changes. <br>
Also fires immediately if the current instance is already known, or requests it <br>
from the server if not — guaranteeing exactly one initial call per registration. <br>

#### Syntax

```lua
jo.player.instanceChanged(cb)
```

#### Parameters

`cb` : _function_
> function called with `(newInstance, oldInstance)`
>

---

### jo.player.move()

A function fired when the player move every 100ms <br>

#### Syntax

```lua
jo.player.move(cb, interval)
```

#### Parameters

`cb` : _function_
> function to fired when the player moves
>

`interval` : _integer_ `[Optional]`
> minimal duration in ms between two executions. Can't be lower than 100ms
>
