DirkScripts Documentation
  • 👋Welcome
  • The Basics
    • ⬇️Installing Resources
  • Resources
    • 📚Dirk Lib
      • Getting Started
      • Cache
      • Modules
        • Await
        • Blip
        • Callback
        • Camera
        • File
        • Interact
        • Objects
        • Player
          • Client
          • Server
        • Groups
          • Client
          • Server
        • Print
        • Request
        • Table
        • Target
        • Zones
        • UI
          • Context
          • Untitled
    • 🔧Project Cars
      • Installation
      • Tools
      • Parts
      • Commands
    • 🤼Multicharacter
      • Installation
      • Configuration
      • Exports
      • F.A.Q
      • Commands
    • 💊Drug Labs v2
      • Installation
      • Tebex Integration
      • Creating Labs
  • 🛒Store
  • 🗣️Discord
  • 🖥️GitHub
Powered by GitBook
On this page
  • Usage
  • Cache Types
  • Accessing
  • lib.onCache
Export as PDF
  1. Resources
  2. Dirk Lib

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

Name
Description

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.

  -- We can replace 'cuffed' with any of the values from above.
  lib.onCache('cuffed', function(isCuffed, oldValue)
    print(('Player is now cuffed: %s\nPlayer was cuffed before: %s'):format(isCuffed, oldValue))
  end)
  -- OR IF YOU REALLY WANTED--
  AddEventHandler("dirk_lib:cache:cuffed", function(isCuffed, oldValue)
    print(('Player is now cuffed: %s\nPlayer was cuffed before: %s'):format(isCuffed, oldValue))
  end)
PreviousGetting StartedNextModules

Last updated 1 day ago

📚