Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silo-libs

License: MIT RedM Frameworks Discord

Unified, framework-agnostic API for SiloTek RedM scripts. Supports VORP Core and RSG Core — write your script once, run it on both.

local SiloLibs = exports["silo-libs"]:GetSiloLibs()
SiloLibs.AddItem(source, "bread", 1)   -- same call on VORP and RSG

The goal: your scripts never call exports.vorp_inventory:... or exports.rsg_inventory:... directly. They call SiloLibs.FunctionName(...), and silo-libs decides at startup which framework is running and which adapter to use. If the framework changes (or VORP/RSG change their internal API), you only update the adapter in silo-libs — not every script.

Installation

  1. Put the silo-libs folder in your server's resources directory.
  2. Add it to server.cfg before the scripts that use it, but after vorp_core (or rsg-core):
    ensure vorp_core
    ensure vorp_inventory
    ensure silo-libs
    

Usage

-- client or server, identical
local SiloLibs = exports["silo-libs"]:GetSiloLibs()

-- server
local added = SiloLibs.AddItem(source, "bread", 1)
local count = SiloLibs.GetItemCount(source, "bread")
local cash  = SiloLibs.GetMoney(source)

-- client
local items = SiloLibs.GetInventory()

The API table is built once when silo-libs starts, based on the detected framework (vorp_core or rsg-core running). If neither is running the table stays empty and a warning is printed to the console.

Implementation status

Category VORP RSG
Inventory (items) YES stub (logs "not implemented yet")
Inventory (weapons) YES stub
Custom inventories YES stub
Core (charid/job/money) YES YES

Function mapping (vorp_core)

Server (SiloLibs.X -> exports.vorp_core:GetCore() / character API)

SiloLibs vorp_core source
GetCharid getUser(source).getUsedCharacter.charIdentifier
GetFirstname getUser(source).getUsedCharacter.firstname
GetLastname getUser(source).getUsedCharacter.lastname
GetJob getUser(source).getUsedCharacter.job
GetJobGrade getUser(source).getUsedCharacter.jobGrade
SetJob character.setJob(job) + character.setJobGrade(grade) (grade optional)
FindCharacterByName direct DB: characters table by firstname+lastname (case-insensitive, works offline) → result via callback: { charId, firstname, lastname } or nil. Callback-based because cross-resource refs must not yield.
GetMoney getUser(source).getUsedCharacter.money
GiveMoney character.addCurrency(0, amount)
RemoveMoney character.removeCurrency(0, amount) (checks sufficient funds first)
Notify CoreFunctions.NotifyObjective(source, text, duration)

Function mapping (vorp_inventory)

All VORP server functions respond synchronously (they return the value directly, no callback needed) — vorp_inventory internally uses a respond(cb, result) helper that returns result whether you pass a callback or not. That is why the silo-libs wrappers never send one.

Client (SiloLibs.Xexports.vorp_inventory:Y)

SiloLibs vorp_inventory export
GetInventory getInventoryItems
GetItem getInventoryItem
GetServerItem getServerItem
CloseInventory closeInventory
GetWeaponDefaultWeight getWeaponDefaultWeight
GetWeaponDefaultDesc getWeaponDefaultDesc
GetWeaponDefaultLabel getWeaponDefaultLabel
GetWeaponName getWeaponName
GetWeaponsDefaultData getWeaponsDefaultData
GetWeaponAmmoTypes getWeaponAmmoTypes
GetAmmoLabel getAmmoLabel

Server (SiloLibs.Xexports.vorp_inventory:Y)

Items

SiloLibs vorp_inventory export
GetInventory getUserInventoryItems
GetItem getItem
GetItemById getItemById
GetItemByName getItemByName
GetItemDB getItemDB
GetItemCount getItemCount
AddItem addItem
RemoveItem subItem
RemoveItemById subItemById
SetItemMetadata setItemMetadata
CanCarryItem canCarryItem
RegisterUsableItem registerUsableItem
UnregisterUsableItem unRegisterUsableItem

Weapons

SiloLibs vorp_inventory export
GetWeapon getUserWeapon
GetWeapons getUserInventoryWeapons
GetWeaponBullets getWeaponBullets
GetWeaponComponents getWeaponComponents
GetAmmo getUserAmmo
RemoveAllAmmo removeAllUserAmmo
AddBullets addBullets
RemoveBullets subBullets
CanCarryWeapons canCarryWeapons
SetWeaponLabel setWeaponCustomLabel
SetWeaponSerial setWeaponSerialNumber
SetWeaponDesc setWeaponCustomDesc
CreateWeapon createWeapon
GiveWeapon giveWeapon
RemoveWeapon subWeapon
DeleteWeapon deleteWeapon

Custom inventories

SiloLibs vorp_inventory export
RegisterInventory registerInventory
RemoveInventory removeInventory
DeleteInventory deleteCustomInventory
IsInventoryRegistered isCustomInventoryRegistered
GetInventoryData getCustomInventoryData
SetInventoryData updateCustomInventoryData
OpenInventory openInventory
CloseInventory closeInventory
OpenPlayerInventory openPlayerInventory
GetInventorySlots getCustomInventorySlots
SetInventorySlots updateCustomInventorySlots
SetInventoryItemLimit setCustomInventoryItemLimit
SetInventoryWeaponLimit setCustomInventoryWeaponLimit
BlacklistInventoryItem BlackListCustomAny
AddInventoryMovePermission AddPermissionMoveToCustom
AddInventoryTakePermission AddPermissionTakeFromCustom
AddInventoryCharMovePermission AddCharIdPermissionMoveToCustom
AddInventoryCharTakePermission AddCharIdPermissionTakeFromCustom
GetInventoryItems getCustomInventoryItems
GetInventoryItemCount getCustomInventoryItemCount
AddItemsToInventory addItemsToCustomInventory
RemoveItemFromInventory removeItemFromCustomInventory
UpdateInventoryItem updateCustomInventoryItem
GetInventoryWeapons getCustomInventoryWeapons
GetInventoryWeaponCount getCustomInventoryWeaponCount
AddWeaponsToInventory addWeaponsToCustomInventory
RemoveWeaponFromInventory removeWeaponFromCustomInventory
RemoveInventoryWeaponById removeCustomInventoryWeaponById

Roadmap

  • Real RSG inventory adapter (rsg-inventory export signatures need to be verified — possibly different from VORP).
  • New categories (banking, housing, ...) as new adapter files following the same pattern: client/adapters/cl_<framework>_<category>.lua + server/adapters/sv_<framework>_<category>.lua, registered in sh_framework.lua / cl_main.lua / sv_main.lua.

License

MIT — free to use in any project. See LICENSE.

Support

Discord: https://discord.gg/T5T5ZsGEsU

About

Unified framework-agnostic API (VORP / RSG) for RedM scripts — write once, run on both.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages