Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simple KVP database wrapper for FiveM

License

NotificationsYou must be signed in to change notification settings

0xwal/0xludb-fivem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0xludb-fivem is a lightweight key-value pair (KVP) database library designed for use within your scripts. It allows you to store and retrieve data using keys, and it supports retrieving data with wildcards for nesting data.

Features

  • Efficient Data Storage: Streamlined key-value pair management.
  • Works Client and Server: Streamlined key-value pair management.
  • Local and Global Data: Store data locally or globally.
  • Wildcard Retrieval: Retrieve data matching patterns.
  • Simple Integration: Easy module import and use.
  • Backup and Export: Export data to JSON for backup or analysis.
  • Resource-Based Keys: Ensure key uniqueness within resources.
  • Self-Contained: No need for external databases.

Public Functions and Commands

save(key, value)

Saves a value using a key. The key can be a string or a table. Data saved with this function is accessible only within the invoking resource.

saveGlobal(key, value)

Saves a value globally using a key. The key can be a string or a table. Globally saved data is accessible from all resources.

retrieve(key)

Retrieves a value using a key. The key can be a string or a table. Data retrieved with this function is specific to the invoking resource.

retrieveGlobal(key)

Retrieves a globally saved value using a key. The key can be a string or a table. Globally retrieved data is accessible from all resources.

delete(key)

Deletes a value using a key. The key can be a string or a table. Data deleted with this function is specific to the invoking resource.

deleteGlobal(key)

Deletes a globally saved value using a key. The key can be a string or a table. Globally deleted data is removed from all resources.

Command:0xludb-export

Exports data to a JSON file when invoked from the server console (serverId 0). This command is typically used to export data for backup or analysis.

Command:0xludb-import

Experimental⚠️

Import the exported data.0xludb-import <filename>

Logging

You can enable logging by executing this command in fx console.

setr log true

Usage Example

You can import the module using:

Local

-- Import the 0xludb-fivem modulelocalludb=exports['0xludb-fivem']-- Save player tokensludb:save("players/license:123/tokens",1000)-- Save player coordinatesludb:save("players/license:123/coords", {x=50,y=-30,z=10 })-- Confirmation messageprint("Player tokens and coordinates saved.")-- Retrieve player tokenslocaltokens=ludb:retrieve("players/license:123/tokens")-- Display retrieved tokensprint("Player Tokens:",tokens)-- Retrieve all player information using wildcard (*)localplayer=ludb:retrieve("players/license:123/*")print(json.encode(player.tokens.value))print(json.encode(player.coords.value))-- Delete tokensludb:delete("players/license:123/tokens")localtokens=ludb:retrieve("players/license:123/tokens")print(tokens)-- nil

Globally (data accessible from all resources)

-- Import the 0xludb-fivem modulelocalludb=exports['0xludb-fivem']-- Save global player tokensludb:saveGlobal("players/license:123/tokens",1000)-- Save global player coordinatesludb:saveGlobal("players/license:123/coords", {x=50,y=-30,z=10 })-- Confirmation messageprint("Global Player tokens and coordinates saved.")-- In another resource (assuming you have access to ludb)-- Retrieve global player tokenslocalglobalTokens=ludb:retrieveGlobal("players/license:123/tokens")-- Display retrieved global tokensprint("Global Player Tokens:",globalTokens)-- Retrieve all global player information using wildcard (*)localglobalPlayer=ludb:retrieveGlobal("players/license:123/*")print(json.encode(globalPlayer.tokens.value))print(json.encode(globalPlayer.coords.value))-- Delete global tokensludb:deleteGlobal("players/license:123/tokens")localglobalTokens=ludb:retrieveGlobal("players/license:123/tokens")print(globalTokens)-- nil

About

Simple KVP database wrapper for FiveM

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp