Client
Values and cache functionality available to the client, in addition to the shared values.
Default values
- ped:
number- player entity id
- playerId:
number- player id
- serverId:
number- player server id
- weapon:
numberorfalse- current weapon hash
- vehicle:
numberorfalse- vehicle entity id
- seat:
numberorfalse- vehicle seat index
- coords:
vector3- current player coords
- only populated if using
zonesorpoints - cannot be listened for with
lib.onCache
- mount:
numberorfalse(RedM only)- mount entity id
lib.onCache
Register an event handler that is triggered when the cached value is updated.
```lua
lib.onCache(key, function(value, oldValue) end)
```
- key: `string`
- `ped`
- `vehicle`
- `seat`
- `weapon`
- `mount` (RedM only)
- value: `any`
```lua
lib.onCache('vehicle', function(value, oldValue)
print('old vehicle:', cache.vehicle)
print('new vehicle:', value)
end)
```
```ts
import { onCache } from '@overextended/ox_lib/client';
onCache(key, (value) => {});
```
- key: `string`
- `ped`
- `vehicle`
- `seat`
- `weapon`
- `mount` (RedM only)
- value: `any`
```ts
import { cache, onCache } from '@overextended/ox_lib/client';
lib.onCache('vehicle', (value) => {
console.log('old vehicle:', cache.vehicle);
console.log('new vehicle:', value);
});
```