Cache
The cache is used to store frequent information that scripts will use, this reduces the load of scripts overall as the core library is the only resource gathering these variables.
Usage
The cache is simple to access, once you've followed the Getting Started steps, you will be able to access the following values:
Cache Types
ped
The players ped id
vehicle
Current vehicle entityId if there is one or false
driver
true or false for if the player is driving
seat
The seat the player is in if any
weapon
The weapon the player is holding if any
dead
Is the player dead, this is based off of framework specific death metadata and IsEntityDead()
cuffed
Again this is framework specific.
job
This is in the format of dirk_lib/types/job
playerId
The players PlayerId()
citizenId
The players unique character identifier if they have one
serverId
The players serverId
playerLoaded
Whether or not the player has loaded and selected a character
Accessing
You can simple called cache.x with whichever type you wish anywhere in your code, so long as dirk_lib is imported.
lib.onCache
All of the above cache types can be used with lib.onCache, this is essentially a listener that will trigger upon change of the value and at initial set.
Last updated