Caches data related to the player and handling some events or statebags.
An interval runs every 100ms to update data that cannot be checked via handlers.
States
- ped:
number
- player entity id
- playerId:
number
- player id
- serverId:
number
- player server id
- vehicle:
number
orfalse
- vehicle entity id
- seat:
number
orfalse
- vehicle seat index
- resource:
string
- invoking resource name
- weapon:
number
orfalse
- current ped weapon
- coords:
vec3
- current player coords
- only populated if using
zones
orpoints
- cannot be listened for with
onCache
- mount:
number
orfalse
(RedM only)- mount entity id
lib.onCache
Register an event handler that is triggered when the cached value is updated.
lib.onCache(key, function(value) end)
- key:
string
- value:
any
lib.onCache('vehicle', function(value)
print('old vehicle:', cache.vehicle)
print('new vehicle:', value)
end)