esx_datastore
https://github.com/esx-framework/esx_datastore
This script, is similar to esx_addoninventory
but stores overall data, rather than inventory specific data.
Usage
There is two
types of datastores: shared
and not shared
.
- Shared datastores doesn’t belong to a specific user. Example: police armory
- None-shared datastores are created for every user in the server. They are created in db when player is loaded, Example:
esx_property
outfits.
Database Information
A datastore must be configured in the database
before using it. you must run a server restart after this.
Table Structure
name
- type:
string
- description: name of the datastore
- type:
label
- type:
string
- description: label of the datastore (not used)
- type:
shared
- type:
boolean
- description: is the datastore shared with others? (boolean either
0
or1
)
- type:
API
getInventory
- Event:
esx_datastore:getDataStore
- Usage:
TriggerEvent('esx_datastore:getDataStore', name, owner, function)
- Example:
TriggerEvent('esx_datastore:getDataStore', 'property', 'steam:0123456789', function(store) local dressing = store.get('dressing') or {} end)
- Usage:
getSharedInventory
- Event:
esx_datastore:getSharedDataStore
- Usage:
TriggerEvent('esx_datastore:getSharedDataStore', name, function)
- Example:
TriggerEvent('esx_datastore:getSharedDataStore', 'police', function(store) local weapons = store.get('weapons') or {} table.insert(weapons, {name = 'WEAPON_PUMPSHOTGUN', ammo = 50}) store.set('weapons', weapons) end)
- Usage: