Merge pull request #75 from The-Order-Of-The-Sacred-Framework/dev

0.6.0
This commit is contained in:
MrNewb authored and GitHub committed 2025-05-01 12:10:13 -04:00
commit ac44b4b34d
86 files changed
+1708 -492

No files matched your search

+62 -31
View File
@@ -1,44 +1,75 @@
# community_bridge
# 🌉 Community Bridge
**By The Order of the Sacred Framework**
## By The Order of the Sacred Framework
Welcome to **Community Bridge**, a modular, beginner-friendly collection of tools and systems designed to simplify and unify development. Built with love and maintained by the community, this bridge aims to make scripting easier, cleaner, and more accessible for everyone.
The **Order of the Sacred Framework**, a fellowship born of noble intention and quiet passion, has crafted a bridge to simplify the journey of all who dare venture into the world of development. This bridge, much like a well-worn path through the woods, is modular in design, offering an array of systems and tools that serve the wanderer and the scholar alike:
---
- Clothing Systems
- Dispatch Systems
- Doorlock Systems
- Frameworks
- Fuel Systems
- Input Systems
- Inventory Systems
- Locale Systems
- Vehicle Key Systems
- Management Systems
- Math Library
- Menu Systems
- Notify Systems
- Phone Systems
- Progress Bars
- Target Systems
- Weather Systems
- A vast trove of helpful functions
- And many more...
## 🔧 Features
As with any grand creation, this bridge also includes utility functions, some of which may be of great use, while others may seem like hidden treasures, waiting to be discovered by those with keen eyes.
This bridge includes a wide range of plug-and-play systems, built with maximum compatibility in mind:
This bridge proudly incorporates snippets from the wide and varied community, some of which are crafted under the honorable **GPLv3** license. All contributions are duly credited in the **Attributions** file, ensuring we respect the deeds of those who came before us and maintain our adherence to the principles of the **GPLv3**.
- **Inventory Module** – Designed to work with `ox_inventory`, `codem-inventory`, `core_inventory`, `jpr-inventory`, `origin_inventory`, `ps-inventory`, `qb-inventory`, `qs-inventory`, and `tgiann-inventory`. Includes an **item output generator** supporting `ox_inventory`, `qb-new`, and `qb-old` formats.
- **Dispatch Module** – Compatible with `lb-tablet`, `ps-dispatch`, `qs-dispatch`, `redutzu-mdt`, `tk_dispatch`, `linden_outlawalert`, `cd_dispatch`, `bub_mdt`, and includes a built-in fallback to ensure notifications always get through.
- **Doorlock Module** – Supports `ox_doorlock`, `qb-doorlock`, `rcore_doorlock`, and `jacksams-doorlock`.
- **Framework Module** – Full support for `qb`, `qbox`, and `esx` with built-in fallbacks for maximum compatibility.
- **Fuel System Module** – Works seamlessly with all major fuel systems.
- **HelpText & Notify Modules** – Designed to support all popular systems with framework-level fallbacks.
- **Input Module** – Compatible with both `qb-input` and `ox_lib` input methods.
- **Management Module** – Works with most major management system variants.
- **Menu Module** – Accepts both `qb` and `ox_lib` formats interchangeably.
- **Phone Module** – Compatible with all major phone systems.
- **Progress Bar Module** – Supports most commonly used progress bar resources.
- **Shops Module** – An in-house shops system, simple to use and easy to expand.
- **Skills Module** – Supports most skills systems in the ecosystem.
- **Targeting Module** – Built to work with `qb-target`, `ox_target`, and `sleepless-interact`.
- **Vehicle Key Module** – Compatible with all major vehicle key systems.
- **Version Checker Module** – Built to handle version checks for both free and paid scripts across any setup.
- **Weather Module** – Fully compatible with most weather control resources.
A **labor of love** it has been, this bridge, forged with a deep **passion for scripts** and a desire to unite the scattered folk of the development world. In the spirit of cooperation, it seeks to bring together those with differing preferences and ideas, creating something that is **entry-level**, **versatile**, and filled with **compatibility wrappers** for all the major resources. It also lays the groundwork for future resources that wish to cross its sturdy spans.
Also includes:
- Locale support
- Math utilities
- A rich collection of helper functions
- And more...
This bridge, a curious blend of its own **library** and a tool of great utility, is full of **helper functions** that will guide you on your journey, making the most complex tasks simpler and more straightforward, like a trusty map in a foreign land.
Whether you're building a full framework or just need utility features, **Community Bridge** is designed to make your workflow easier and more efficient.
Crafted with care, the bridge is as **user-friendly** as a friendly hobbit’s home, catering to both beginners and seasoned travelers. It is a bridge of great adaptability, easily modified to suit the needs of those who walk across it.
---
This bridge will **not fall victim to the ego of any single individual**, for its foundation lies in the belief that any contribution of value to the community, if it adheres to the simple philosophy of **simplicity**, and ensures an easy path for all, is **welcome**.
## 🤝 Community-Driven
The aim, much like the hobbits' journey to Morridor, is to create a **free, open, community-driven bridge**, one that serves the needs of the many and welcomes all who wish to add their mark to the map.
This project includes contributions and snippets from across the development community. Some modules are under the **GPLv3 license**, with proper credit given in the `Attributions` file.
Our mission: to promote open collaboration, reduce friction between systems, and create a unified foundation for all developers—regardless of framework or experience.
**Docs available At** https://mrnewbs-scrips.gitbook.io/the-order-of-the-sacred-framework
---
**Join The Discord At** https://discord.gg/MukwBuJjP7
## 🧰 Why Use Community Bridge?
- ✅ Easy for beginners
- 🔄 Highly modular and extendable
- 🔌 Compatible with all major scripts and systems
- 🔧 Built-in compatibility wrappers
- 📦 Future-proof and easy to expand
- 🤝 Built with community-first values
---
## 📚 Documentation
Read the full documentation here:
👉 [Our Gitbook Here](https://mrnewbs-scrips.gitbook.io/the-order-of-the-sacred-framework)
---
## 💬 Join the Community
Have questions, suggestions, or want to contribute? Join us on Discord:
👉 [Our Discord Here](https://discord.gg/MukwBuJjP7)
---
> “A bridge built not for one, but for all — strong, simple, and open.”
---
+5 -1
View File
@@ -4,7 +4,7 @@ lua54 'yes'
use_experimental_fxv2_oal 'yes'
author 'The Order of the Sacred Framework'
description 'A bridge made for the community to use as a base for their own projects. This bridge will allow a single format to work with nearly all commonly used systems while still offering expandability.'
version '0.5.1'
version '0.6.0'
shared_scripts {
'@ox_lib/init.lua',
@@ -27,8 +27,10 @@ server_scripts {
'modules/dispatch/**/server.lua',
'modules/clothing/**/server.lua',
'modules/shops/**/server.lua',
'modules/helptext/**/server.lua',
'modules/notify/**/server.lua',
'modules/housing/**/server.lua',
'modules/skills/**/server.lua',
'init.lua',
}
@@ -48,11 +50,13 @@ client_scripts {
'modules/clothing/**/client.lua',
'modules/input/*.lua',
'modules/menu/*.lua',
'modules/helptext/**/client.lua',
'modules/notify/**/client.lua',
'modules/dialogue/**/client/*.lua',
'modules/shops/**/client.lua',
'modules/housing/**/client.lua',
'modules/accessibility/client.lua',
'modules/skills/**/client.lua',
'init.lua',
}
+6 -1
View File
@@ -47,6 +47,7 @@ end
Bridge.RegisterModule("Framework", Framework)
Bridge.RegisterModule("Inventory", Inventory)
Bridge.RegisterModule("Notify", Notify)
Bridge.RegisterModule("HelpText", HelpText)
Bridge.RegisterModule("Clothing", Clothing)
Bridge.RegisterModule("Language", Language)
Bridge.RegisterModule("Doorlock", Doorlock)
@@ -68,6 +69,8 @@ Bridge.RegisterModule("ReboundEntities", cLib.ReboundEntities)
Bridge.RegisterModule("LA", cLib.LA)
Bridge.RegisterModule("Perlin", cLib.Perlin)
Bridge.RegisterModule("Actions", cLib.Actions)
Bridge.RegisterModule("Cache", cLib.Cache)
Bridge.RegisterModule("Skills", Skills)
exports('Bridge', function()
@@ -83,6 +86,7 @@ Bridge.RegisterModule("Logs", cLib.Logs)
Bridge.RegisterModule("ItemsBuilder", cLib.ItemsBuilder)
Bridge.RegisterModule("LootTables", cLib.LootTables)
Bridge.RegisterModule("Version", Version)
Bridge.RegisterModule("ServerEntity", cLib.ServerEntity)
-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀
@@ -111,7 +115,8 @@ Bridge.RegisterModule("PlaceableObject", cLib.PlaceableObject)
Bridge.RegisterModule("Point", cLib.Point)
Bridge.RegisterModule("Object", cLib.Object)
Bridge.RegisterModule("Particle", cLib.Particle)
Bridge.RegisterModule("ClientEntity", cLib.ClientEntity)
Bridge.RegisterModule("ClientEntityActions", cLib.ClientEntityActions)
-- Fill the bridge tables with player data.
function FillBridgeTables()
+40
View File
@@ -0,0 +1,40 @@
Cache = Cache or Require("lib/cache/shared/cache.lua")
-- Comparison functions for client-side state
local function GetPed()
return PlayerPedId()
end
local function GetVehicle()
local ped = Cache.Get("Ped") -- Use cached ped for efficiency
if not ped then return end -- Or handle error/default case
return GetVehiclePedIsIn(ped, false)
end
local function GetVehicleSeat()
local vehicle = Cache.Get("Vehicle")
if not vehicle then return end
local ped = Cache.Get("Ped")
if not ped then return end
for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do
if ped == GetPedInVehicleSeat(vehicle, i) then
return i
end
end
end
local function GetWeapon()
local ped = Cache.Get("Ped")
if not ped then return end -- Return unarmed hash if no ped
return GetSelectedPedWeapon(ped)
end
AddEventHandler('onResourceStart', function(resource)
if resource ~= GetCurrentResourceName() then return end
Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed)
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms
end)
return Cache
View File
Whitespace-only changes.
+73
View File
@@ -0,0 +1,73 @@
Cache = {}
Cache.Caches = {}
Cache.LoopRunning = false
local max = 5000
local function StartLoop()
if Cache.LoopRunning then return end
Cache.LoopRunning = true
CreateThread(function()
while Cache.LoopRunning do
local now = GetGameTimer()
local minWait = nil
local caches = Cache.Caches
for name, cache in pairs(caches) do
if cache.Compare then
cache.LastChecked = cache.LastChecked or now
cache.WaitTime = cache.WaitTime or max
local elapsed = now - cache.LastChecked
local remaining = cache.WaitTime - elapsed
if remaining <= 0 then
local oldValue = cache.Value
cache.Value = cache.Compare()
if cache.Value ~= oldValue and cache.OnChange then
for _, onChange in pairs(cache.OnChange) do
onChange(cache.Value, oldValue)
end
end
cache.LastChecked = now
remaining = cache.WaitTime
end
if not minWait or remaining < minWait then
minWait = remaining
if minWait <= 0 then break end
end
end
end
if minWait then
Wait(math.max(0, minWait))
else
Wait(max)
end
end
end)
end
function Cache.Create(name, compare, waitTime)
Cache.Caches[name] = Cache.Caches[name] or {}
Cache.Caches[name].WaitTime = waitTime or max
Cache.Caches[name].Compare = compare
Cache.Caches[name].OnChange = Cache.Caches[name].OnChange or {}
Cache.Caches[name].Value = compare()
print("Cache created: " .. name .. " with initial value: " .. tostring(Cache.Caches[name].Value))
for _, onChange in pairs(Cache.Caches[name].OnChange) do
onChange(Cache.Caches[name].Value, nil)
end
return StartLoop()
end
function Cache.Get(name)
local cache = Cache.Caches[name]
return cache and cache.Value or nil
end
function Cache.OnChange(name, onChange)
local cache = Cache.Caches[name]
assert(cache, "Cache with name '" .. name .. "' does not exist.")
table.insert(cache.OnChange, onChange)
end
return Cache
+204
View File
@@ -0,0 +1,204 @@
Utility = Utility or Require("lib/utility/client/utility.lua")
Ids = Ids or Require("lib/utility/shared/ids.lua")
Point = Point or Require("lib/points/client/points.lua")
ClientEntityActions = ClientEntityActions or Require("lib/entities/client/client_entity_actions_ext.lua") -- Added
local Entities = {} -- Stores entity data received from server
ClientEntity = {} -- Renamed from BaseEntity
local function SpawnEntity(entityData)
entityData = entityData and entityData.args
if entityData.spawned and DoesEntityExist(entityData.spawned) then return end -- Already spawned
-- for k, v in pairs(entityData.args) do
-- print(string.format("SpawnEntity %s: %s", k, v))
-- end
local model = entityData.model and type(entityData.model) == 'string' and GetHashKey(entityData.model) or entityData.model
if not Utility.LoadModel(model) then
print(string.format("[ClientEntity] Failed to load model %s for entity %s", entityData.model, entityData.id))
return
end
local entity = nil
local coords = entityData.coords
local rotation = entityData.rotation
if entityData.entityType == 'object' then
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
SetEntityRotation(entity, rotation.x, rotation.y, rotation.z, 2, true)
elseif entityData.entityType == 'ped' then
entity = CreatePed(4, model, coords.x, coords.y, coords.z, type(rotation) == 'number' and rotation or rotation.z, false, false)
-- Apply ped specific settings from entityData.meta if needed
elseif entityData.entityType == 'vehicle' then
entity = CreateVehicle(model, coords.x, coords.y, coords.z, type(rotation) == 'number' and rotation or rotation.z, false, false)
-- Apply vehicle specific settings from entityData.meta if needed
else
print(string.format("[ClientEntity] Unknown entity type '%s' for entity %s", entityData.entityType, entityData.id))
end
if entity then
entityData.spawned = entity
SetModelAsNoLongerNeeded(model)
SetEntityAsMissionEntity(entity, true, true) -- Keep entity from being deleted by game engine
FreezeEntityPosition(entity, entityData.freeze or false) -- Optional freeze based on meta
if entityData.OnSpawn and type(entityData.OnSpawn) == 'function' then
entityData.OnSpawn(entityData)
end
-- print(string.format("[ClientEntity] Spawned %s entity %s (GameID: %s)", entityData.entityType, entityData.id, entity))
else
SetModelAsNoLongerNeeded(model)
end
end
local function RemoveEntity(entityData)
entityData = entityData and entityData.args
if not entityData then return end -- Added safety check
ClientEntityActions.StopAction(entityData.id) -- Stop any ongoing action AND clear queue before despawning
if entityData.spawned and DoesEntityExist(entityData.spawned) then
local entityHandle = entityData.spawned
entityData.spawned = nil -- Clear handle first
SetEntityAsMissionEntity(entityHandle, false, false) -- Allow game engine to delete if needed, though we delete manually
DeleteEntity(entityHandle)
-- print(string.format("[ClientEntity] Removed %s entity %s (GameID: %s)", entityData.entityType, entityData.id, entityHandle))
end
if entityData.OnRemove and type(entityData.OnRemove) == 'function' then
entityData.OnRemove(entityData)
end
end
--- Registers an entity received from the server and sets up proximity spawning.
-- @param entityData table Data received from the server via 'community_bridge:client:CreateEntity'
function ClientEntity.Register(entityData)
if Entities[entityData.id] then return end -- Already registered
Entities[entityData.id] = entityData
-- print(string.format("[ClientEntity] Registering %s entity %s", entityData.entityType, entityData.id))
-- Use Point system for proximity checks
print(string.format("[ClientEntity] Registering entity %s at %s", entityData.id, json.encode(entityData)))
Point.Register(entityData.id, entityData.coords, entityData.spawnDistance or 50.0, entityData, SpawnEntity, RemoveEntity, function() end)
end
--- Unregisters an entity and removes it from the world if spawned.
-- @param id string|number The ID of the entity to unregister.
function ClientEntity.Unregister(id)
local entityData = Entities[id]
if not entityData then return end
-- print(string.format("[ClientEntity] Unregistering entity %s", id))
Point.Remove(id) -- Remove from proximity checks (this will call RemoveEntity if currently in range)
RemoveEntity(entityData) -- Ensure it's removed even if Point.Remove didn't trigger it
Entities[id] = nil
end
--- Updates the data for a registered entity.
-- @param id string|number The ID of the entity to update.
-- @param data table The data fields to update.
function ClientEntity.Update(id, data)
local entityData = Entities[id]
print(string.format("[ClientEntity] Updating entity %s", id))
if not entityData then return end
local needsPointUpdate = false
for key, value in pairs(data) do
if key == 'coords' and #(entityData.coords - value) > 0.1 then
print(string.format("[ClientEntity] Updating coords for entity %s", id))
needsPointUpdate = true
end
if key == 'spawnDistance' and entityData.spawnDistance ~= value then
needsPointUpdate = true
end
entityData[key] = value
end
-- If entity is currently spawned, apply updates
if entityData.spawned and DoesEntityExist(entityData.spawned) then
if data.coords then
SetEntityCoords(entityData.spawned, entityData.coords.x, entityData.coords.y, entityData.coords.z, false, false, false, true)
end
if data.rotation then
if entityData.entityType == 'object' then
SetEntityRotation(entityData.spawned, entityData.rotation.x, entityData.rotation.y, entityData.rotation.z, 2, true)
else -- Ped/Vehicle heading
SetEntityHeading(entityData.spawned, type(entityData.rotation) == 'number' and entityData.rotation or entityData.rotation.z)
end
end
if data.freeze ~= nil then
FreezeEntityPosition(entityData.spawned, data.freeze)
end
-- Add other updatable properties as needed
end
-- Update Point registration if coords or distance changed
if needsPointUpdate then
Point.Remove(id)
Point.Register(
entityData.id,
entityData.coords,
entityData.spawnDistance or 50.0,
SpawnEntity,
RemoveEntity,
nil,
entityData
)
end
if entityData.OnUpdate and type(entityData.OnUpdate) == 'function' then
entityData.OnUpdate(entityData, data)
end
end
function ClientEntity.Get(id)
return Entities[id]
end
function ClientEntity.GetAll()
return Entities
end
-- Network Event Handlers
RegisterNetEvent("community_bridge:client:CreateEntity", function(entityData)
ClientEntity.Register(entityData)
end)
RegisterNetEvent("community_bridge:client:DeleteEntity", function(id)
ClientEntity.Unregister(id)
end)
RegisterNetEvent("community_bridge:client:UpdateEntity", function(id, data)
ClientEntity.Update(id, data)
end)
-- New handler for entity actions
RegisterNetEvent("community_bridge:client:TriggerEntityAction", function(entityId, actionName, ...)
local entityData = Entities[entityId]
print("here", json.encode(entityData))
-- Check if entity exists locally (it doesn't need to be spawned to queue actions)
if entityData then
if actionName == "Stop" then
ClientEntityActions.StopAction(entityId)
elseif actionName == "Skip" then
ClientEntityActions.SkipAction(entityId)
else
print(string.format("[ClientEntity] Triggering action '%s' for entity %s", actionName, entityId))
local currentAction = ClientEntityActions.ActionQueue[entityId] and ClientEntityActions.ActionQueue[entityId][1]
ClientEntityActions.QueueAction(entityData, actionName, ...)
end
-- else
-- Optional: Log if action received but entity doesn't exist locally at all
-- print(string.format("[ClientEntity] Received action '%s' for non-existent entity %s.", actionName, entityId))
end
end)
-- Resource Stop Cleanup
AddEventHandler('onResourceStop', function(resourceName)
if resourceName == GetCurrentResourceName() then
for id, entityData in pairs(Entities) do
Point.Remove(id) -- Clean up point registration
RemoveEntity(entityData) -- Clean up spawned game entity
end
Entities = {} -- Clear local cache
end
end)
return ClientEntity
@@ -0,0 +1,135 @@
ClientEntityActions = {}
ClientEntityActions.ActionThreads = {} -- Store running action threads { [entityId] = thread }
ClientEntityActions.ActionQueue = {} -- Stores pending actions { [entityId] = {{name="ActionName", args={...}}, ...} }
ClientEntityActions.IsActionRunning = {} -- Tracks if an action is currently running { [entityId] = boolean }
ClientEntityActions.RegisteredActions = {} -- New: Registry for action implementations { [actionName] = function(entityData, ...) }
-- Forward declaration
--- Processes the next action in the queue for a given entity.
-- @param entityId string|number The ID of the entity.
function ClientEntityActions.ProcessNextAction(entityId)
if ClientEntityActions.IsActionRunning [entityId] then return end -- Already running something
print(string.format("[ClientEntityActions] Processing next action for entity %s", entityId))
local queue = ClientEntityActions.ActionQueue[entityId]
if not queue or #queue == 0 then return end -- Queue is empty
local nextAction = table.remove(queue, 1) -- Dequeue (FIFO)
local entityData = ClientEntity.Get(entityId) -- Assumes ClientEntity is accessible
-- Check if entity is still valid and spawned before starting next action
if not entityData or not entityData.spawned or not DoesEntityExist(entityData.spawned) then
-- Entity despawned while idle, clear queue and do nothing
ClientEntityActions.ActionQueue[entityId] = nil
return
end
-- Look up the action in the registry
local actionFunc = ClientEntityActions.RegisteredActions [nextAction.name]
print(string.format("[ClientEntityActions] Action '%s' dequeued for entity %s", nextAction.name, entityId))
if actionFunc then
-- print(string.format("[ClientEntityActions] Starting action '%s' for entity %s", nextAction.name, entityId))
ClientEntityActions.IsActionRunning [entityId] = true
-- Call the registered function
actionFunc(entityData, table.unpack(nextAction.args))
else
print(string.format("[ClientEntityActions] Unknown action '%s' dequeued for entity %s", nextAction.name, entityId))
-- Skip unknown action and try the next one immediately
ClientEntityActions.ProcessNextAction(entityId)
end
end
--- Registers a custom action implementation.
-- The action function should handle its own logic, including threading if needed,
-- and MUST call ClientEntityActions.ProcessNextAction(entityData.id) when it completes or fails,
-- after setting ClientEntityActions.IsActionRunning [entityData.id] = false.
-- @param actionName string The name used to trigger this action.
-- @param actionFunc function The function to execute. Signature: function(entityData, ...)
function ClientEntityActions.RegisterAction(actionName, actionFunc)
if ClientEntityActions.RegisteredActions [actionName] then
print(string.format("[ClientEntityActions] WARNING: Overwriting registered action '%s'", actionName))
end
assert(type(actionName) == "string", "actionName must be a string")
assert(type(actionFunc) == "function", "actionFunc must be a function")
print(string.format("[ClientEntityActions] Registered action: %s", actionName))
ClientEntityActions.RegisteredActions [actionName] = actionFunc
-- print(string.format("[ClientEntityActions] Registered action: %s", actionName))
end
--- Queues an action for an entity. Starts processing if idle.
-- @param entityData table The entity data.
-- @param actionName string The name of the action.
-- @param ... any Arguments for the action.
function ClientEntityActions.QueueAction(entityData, actionName, ...)
local entityId = entityData.id
if not ClientEntityActions.ActionQueue[entityId] then
ClientEntityActions.ActionQueue[entityId] = {}
end
local actionArgs = {...}
table.insert(ClientEntityActions.ActionQueue[entityId], { name = actionName, args = actionArgs })
-- print(string.format("[ClientEntityActions] Queued action '%s' for entity %s. Queue size: %d", actionName, entityId, #ClientEntityActions.ActionQueue[entityId]))
-- If the entity isn't currently doing anything, start processing immediately
if not ClientEntityActions.IsActionRunning [entityId] then
ClientEntityActions.ProcessNextAction(entityId)
end
end
--- Stops the current action and clears the queue for a specific entity.
-- @param entityId string|number The ID of the entity.
function ClientEntityActions.StopAction(entityId)
-- print(string.format("[ClientEntityActions] Stopping all actions for entity %s", entityId))
ClientEntityActions.ActionQueue[entityId] = nil -- Clear the queue
ClientEntityActions.IsActionRunning [entityId] = false -- Mark as not running (this will stop loops in threads)
-- Stop current task/thread if applicable
if ClientEntityActions.ActionThreads[entityId] then
-- Lua threads stop themselves based on ClientEntityActions.IsActionRunning flag
ClientEntityActions.ActionThreads[entityId] = nil
end
-- Specific task clearing for peds
local entityData = ClientEntity.Get(entityId)
if entityData and entityData.spawned and DoesEntityExist(entityData.spawned) then
if IsEntityAPed(entityData.spawned) then
ClearPedTasksImmediately(entityData.spawned) -- Use Immediately for forceful stop
end
-- Other entity types might need different stop logic
end
end
--- Skips the current action and starts the next one in the queue, if any.
-- @param entityId string|number The ID of the entity.
function ClientEntityActions.SkipAction(entityId)
if not ClientEntityActions.IsActionRunning [entityId] then
-- print(string.format("[ClientEntityActions] SkipAction called for %s, but no action running.", entityId))
return -- Nothing to skip
end
-- print(string.format("[ClientEntityActions] Skipping current action for entity %s", entityId))
ClientEntityActions.IsActionRunning [entityId] = false -- Mark as not running (this will stop loops in threads)
-- Stop current task/thread if applicable
if ClientEntityActions.ActionThreads[entityId] then
ClientEntityActions.ActionThreads[entityId] = nil
end
local entityData = ClientEntity.Get(entityId)
if entityData and entityData.spawned and DoesEntityExist(entityData.spawned) then
if IsEntityAPed(entityData.spawned) then
ClearPedTasksImmediately(entityData.spawned)
end
end
-- Immediately try to process the next action
ClientEntityActions.ProcessNextAction(entityId)
end
-- Add server-callable functions for Stop and Skip
function ClientEntityActions.Stop(entityData)
ClientEntityActions.StopAction(entityData.id)
end
function ClientEntityActions.Skip(entityData)
ClientEntityActions.SkipAction(entityData.id)
end
return ClientEntityActions
@@ -0,0 +1,271 @@
DefaultActions = {}
ClientEntityActions = ClientEntityActions or Require("lib/entities/client/client_entity_actions.lua") -- Added
--- Internal implementation for walking. Registered via RegisterAction.
function DefaultActions.WalkTo(entityData, coords, speed, timeout)
print("[ClientEntityActions] WalkTo action called", coords, speed, timeout)
local entity = entityData.spawned
local entityId = entityData.id -- Store ID locally for safety in thread
if not entity or not DoesEntityExist(entity) or not IsEntityAPed(entity) then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId) -- Try next action if this one failed immediately
return
end
-- Clear previous tasks just in case
ClearPedTasks(entity)
local thread = CreateThread(function()
TaskGoToCoordAnyMeans(entity, coords.x, coords.y, coords.z, speed or 1.0, 0, false, 786603, timeout or -1)
-- Wait until task is completed/interrupted or entity is despawned/changed
local entityCoords = GetEntityCoords(entity)
while ClientEntityActions.IsActionRunning[entityId] and entityData.spawned == entity and DoesEntityExist(entity) and #(entityCoords - coords) > 2.0 do
entityCoords = GetEntityCoords(entity)
Wait(0) -- Yield to avoid freezing the game
end
ClientEntityActions.ActionThreads[entityId] = nil -- Clear thread reference
-- Only process next action if this thread was the one running the action
if ClientEntityActions.IsActionRunning[entityId] then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
end
end)
ClientEntityActions.ActionThreads[entityId] = thread
end
--- Internal implementation for playing an animation. Registered via RegisterAction.
-- @param entityData table
-- @param animDict string
-- @param animName string
-- @param blendIn number (Optional, default 8.0)
-- @param blendOut number (Optional, default -8.0)
-- @param duration number (Optional, default -1 for loop/until stopped)
-- @param flag number (Optional, default 0)
-- @param playbackRate number (Optional, default 0.0)
function DefaultActions.PlayAnim(entityData, animDict, animName, blendIn, blendOut, duration, flag, playbackRate)
local entity = entityData.spawned
local entityId = entityData.id
if not entity or not DoesEntityExist(entity) or not IsEntityAPed(entity) then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
return
end
blendIn = blendIn or 8.0
blendOut = blendOut or -8.0
duration = duration or -1
flag = flag or 0
playbackRate = playbackRate or 0.0
local thread = CreateThread(function()
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)
local timeout = 100
while not HasAnimDictLoaded(animDict) and timeout > 0 do
Wait(10)
timeout = timeout - 1
end
end
if HasAnimDictLoaded(animDict) then
TaskPlayAnim(entity, animDict, animName, blendIn, blendOut, duration, flag, playbackRate, false, false, false)
-- Wait for completion or interruption
local startTime = GetGameTimer()
local animTime = duration > 0 and (startTime + duration) or -1
while ClientEntityActions.IsActionRunning[entityId] and entityData.spawned == entity and DoesEntityExist(entity) do
local isPlaying = IsEntityPlayingAnim(entity, animDict, animName, 3)
-- Break conditions:
-- 1. Action was stopped/skipped externally
-- 2. Entity changed/despawned
-- 3. Animation finished naturally (if not looping based on flags/duration)
-- 4. Duration expired (if duration > 0)
if not ClientEntityActions.IsActionRunning[entityId] or entityData.spawned ~= entity or not DoesEntityExist(entity) then break end
if duration == -1 and not isPlaying and GetEntityAnimCurrentTime(entity, animDict, animName) > 0.1 then break end -- Check if non-looping anim finished
if animTime ~= -1 and GetGameTimer() >= animTime then break end
Wait(100) -- Check periodically
end
-- Don't remove dict here if other actions might use it immediately after
-- Consider a separate cleanup mechanism if needed
else
print(string.format("[ClientEntityActions] Failed to load anim dict '%s' for entity %s", animDict, entityId))
end
-- Crucial: Mark as finished and process next
if ClientEntityActions.IsActionRunning[entityId] then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
end
end)
ClientEntityActions.ActionThreads[entityId] = thread
end
--- Internal implementation for lerping. Registered via RegisterAction.
function DefaultActions.LerpTo(entityData, targetCoords, duration, easingType, easingDirection)
local entity = entityData.spawned
local entityId = entityData.id -- Store ID locally
if not entity or not DoesEntityExist(entity) then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId) -- Try next action if this one failed immediately
return
end
local startCoords = GetEntityCoords(entity)
local startTime = GetGameTimer()
easingType = easingType or "linear"
easingDirection = easingDirection or "inout"
local thread = CreateThread(function()
while GetGameTimer() < startTime + duration do
-- Check if action should continue
if not ClientEntityActions.IsActionRunning[entityId] or not entityData.spawned or entityData.spawned ~= entity or not DoesEntityExist(entity) then
break -- Stop if entity despawned, changed, or action was stopped/skipped
end
local elapsed = GetGameTimer() - startTime
local t = LA.Clamp(elapsed / duration, 0.0, 1.0)
local easedT = LA.EaseInOut(t, easingType) -- Default
if easingDirection == "in" then
easedT = LA.EaseIn(t, easingType)
elseif easingDirection == "out" then
easedT = LA.EaseOut(t, easingType)
end
local currentPos = LA.LerpVector(startCoords, targetCoords, easedT)
SetEntityCoordsNoOffset(entity, currentPos.x, currentPos.y, currentPos.z, false, false, false)
Wait(0)
end
-- Ensure final position if completed fully and action wasn't stopped/skipped
if ClientEntityActions.IsActionRunning[entityId] and entityData.spawned == entity and DoesEntityExist(entity) then
SetEntityCoordsNoOffset(entity, targetCoords.x, targetCoords.y, targetCoords.z, false, false, false)
end
ClientEntityActions.ActionThreads[entityId] = nil -- Clear thread reference
-- Only process next action if this thread was the one running the action
if ClientEntityActions.IsActionRunning[entityId] then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
end
end)
ClientEntityActions.ActionThreads[entityId] = thread
end
--- Internal implementation for attaching a prop. Registered via RegisterAction.
-- This action completes immediately after attaching. Use DetachProp to remove.
-- @param entityData table
-- @param propModel string|number
-- @param boneIndex number (Optional, default -1 for root)
-- @param offsetPos vector3 (Optional, default vector3(0,0,0))
-- @param offsetRot vector3 (Optional, default vector3(0,0,0))
-- @param useSoftPinning boolean (Optional, default false)
-- @param collision boolean (Optional, default false)
-- @param isPed boolean (Optional, default false) - Seems unused in native?
-- @param vertexIndex number (Optional, default 2) - Seems unused in native?
-- @param fixedRot boolean (Optional, default true)
function DefaultActions.AttachProp(entityData, propModel, boneName, offsetPos, offsetRot, useSoftPinning, collision, isPed, vertexIndex, fixedRot)
local entity = entityData.spawned
local entityId = entityData.id
if not entity or not DoesEntityExist(entity) then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
return
end
local modelHash = Utility.GetEntityHashFromModel(propModel)
print(modelHash, propModel)
if not Utility.LoadModel(modelHash) then
print(string.format("[ClientEntityActions] Failed to load prop model '%s' for entity %s", propModel, entityId))
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
return
end
local boneIndex = GetEntityBoneIndexByName(entity, boneName)
local coords = GetEntityCoords(entity)
local prop = CreateObject(modelHash, coords.x, coords.y, coords.z, false, false, false)
SetModelAsNoLongerNeeded(modelHash)
boneIndex = boneIndex or GetPedBoneIndex(entity, 60309) -- SKEL_R_Hand if not specified and is ped
if boneIndex == -1 then boneIndex = 0 end -- Default to root if bone not found or not ped
offsetPos = offsetPos or vector3(0.0, 0.0, 0.0)
offsetRot = offsetRot or vector3(0.0, 0.0, 0.0)
print(string.format("[ClientEntityActions] Attaching prop '%s' to entity %s at bone %d", propModel, entityId, boneIndex))
AttachEntityToEntity(prop, entity, boneIndex, offsetPos.x, offsetPos.y, offsetPos.z, offsetRot.x, offsetRot.y, offsetRot.z, false, useSoftPinning or false, collision or false, isPed or false, vertexIndex or 2, fixedRot == nil and true or fixedRot)
-- Store the attached prop handle for later removal
if not entityData.attachedProps then entityData.attachedProps = {} end
entityData.attachedProps[propModel] = prop -- Store by model name/hash for easy lookup
-- This action finishes immediately
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
end
--- Internal implementation for detaching a prop. Registered via RegisterAction.
-- @param entityData table
-- @param propModel string|number The model name/hash of the prop to detach.
function DefaultActions.DetachProp(entityData, propModel)
local entityId = entityData.id
if entityData.attachedProps and propModel then
local propHandle = entityData.attachedProps[propModel]
if propHandle and DoesEntityExist(propHandle) then
DetachEntity(propHandle, true, true) -- Detach
DeleteEntity(propHandle) -- Delete
entityData.attachedProps[propModel] = nil -- Remove from tracking
-- print(string.format("[ClientEntityActions] Detached prop '%s' from entity %s", propModel, entityId))
else
-- print(string.format("[ClientEntityActions] Prop '%s' not found attached to entity %s for detachment.", propModel, entityId))
end
else
-- print(string.format("[ClientEntityActions] No props tracked or propModel not specified for detachment on entity %s.", entityId))
end
-- This action finishes immediately
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
end
function DefaultActions.GetInCar(entityData, vehicleData, seatIndex, timeout)
local entity = entityData.spawned
local vehicle = vehicleData.spawned
local entityId = entityData.id
if not entity or not DoesEntityExist(entity) or not IsEntityAPed(entity) then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId) -- Try next action if this one failed immediately
return
end
if not vehicle or not DoesEntityExist(vehicle) or not IsEntityAVehicle(vehicle) then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId) -- Try next action if this one failed immediately
return
end
-- Clear previous tasks just in case
ClearPedTasks(entity)
local thread = CreateThread(function()
TaskEnterVehicle(entity, vehicle, timeout or 1000, seatIndex or -1, 1.0, 1, 0) -- Enter vehicle
Wait(timeout or 1000) -- Wait for a bit to ensure the task is completed
ClientEntityActions.ActionThreads[entityId] = nil -- Clear thread reference
-- Only process next action if this thread was the one running the action
if ClientEntityActions.IsActionRunning[entityId] then
ClientEntityActions.IsActionRunning[entityId] = false
ClientEntityActions.ProcessNextAction(entityId)
end
end)
ClientEntityActions.ActionThreads[entityId] = thread
end
for name, func in pairs(DefaultActions) do
ClientEntityActions.RegisterAction(name, func)
end
return ClientEntityActions
-51
View File
@@ -1,51 +0,0 @@
-- Objects
Utility = Utility or Require("lib/utility/client/utility.lua")
Ids = Ids or Require("lib/utility/shared/ids.lua")
Point = Point or Require("lib/points/client/points.lua")
local Entities = {}
BaseEntity = {}
function BaseEntity.Create(id, model, coords, rotation, meta)
local self = meta or {}
if id and type(id) == "table" then
self = id
self.id = id.id or Ids.CreateUniqueId(Entities)
self.rotation = id.rotation or vector3(0.0, 0.0, 0.0)
else
self.id = id or Ids.CreateUniqueId(Entities)
self.model = model
self.coords = coords
self.rotation = rotation or vector3(0.0, 0.0, 0.0)
end
assert(self.id, "ID Failed to generate")
assert(self.model, "Model is required for entity creation")
assert(self.coords, "Coords are required for entity creation")
self.Spawn = self.Spawn or function() end
self.Remove = self.Remove or function() end
return Point.Register(self.id, self.coords, 50.0, self.Spawn, self.Remove, nil, self)
end
function BaseEntity.GetAll()
return Entities
end
function BaseEntity.Get(id)
return Entities[id]
end
function BaseEntity.Add(self)
Entities[self.id] = self
end
function BaseEntity.Remove(id)
Entities[id] = nil
end
function BaseEntity.LoadModel(model)
return Utility.LoadModel(model)
end
return BaseEntity
-71
View File
@@ -1,71 +0,0 @@
BaseEntity = BaseEntity or Require("lib/entities/client/entity_base.lua")
local Objects = {}
Object = {}
function Object.Create(id, model, coords, rotation, meta)
local base = meta or {}
if id and type(id) == "table" then
base = id
base.id = id.id or Ids.CreateUniqueId(Objects)
base.rotation = id.rotation or vector3(0.0, 0.0, 0.0)
else
base.id = id or Ids.CreateUniqueId(Objects)
base.model = model
base.coords = coords
base.rotation = rotation or vector3(0.0, 0.0, 0.0)
end
assert(base.id, "ID Failed to generate")
assert(base.model, "Model is required for entity creation")
assert(base.coords, "Coords are required for entity creation")
base.Spawn = function(self)
print("Spawning object", self)
if not BaseEntity.LoadModel(self.model) then return end
self.entity = CreateObject(self.model, self.coords.x, self.coords.y, self.coords.z, false, false, false)
SetEntityRotation(self.entity, self.rotation.x, self.rotation.y, self.rotation.z, 2, false)
SetEntityAsMissionEntity(self.entity, true, true)
SetModelAsNoLongerNeeded(self.model)
if self.OnSpawn then self.OnSpawn(self, self.entity, self.coords, self.rotation) end
return self.entity
end
base.Remove = function(self)
DeleteEntity(self.entity)
if self.OnRemove then self.OnRemove(self, self.entity) end
self.entity = nil
end
Object.Add(base)
return BaseEntity.Create(base)
end
function Object.GetAll()
return Objects
end
function Object.Get(id)
return Objects[id]
end
function Object.Add(self)
Objects[self.id] = self
end
function Object.Remove(id)
Objects[id] = nil
end
function Object.SetOnSpawn(id, callback)
local obj = Object.Get(id)
if not obj then return end
obj.OnSpawn = callback
return true
end
function Object.SetOnRemove(id, callback)
local obj = Object.Get(id)
if not obj then return end
obj.OnRemove = callback
return true
end
return Object
-46
View File
@@ -1,46 +0,0 @@
-- Objects
Ids = Ids or Require("lib/utility/shared/ids.lua")
local Entities = {}
EntityRelay = {}
function EntityRelay.Create(id, model, coords, rotation, meta)
local self = meta or {}
if id and type(id) == "table" then
self = id
self.id = id.id or Ids.CreateUniqueId(Entities)
self.rotation = id.rotation or vector3(0.0, 0.0, 0.0)
else
self.id = id or Ids.CreateUniqueId(Entities)
self.model = model
self.coords = coords
self.rotation = rotation or vector3(0.0, 0.0, 0.0)
end
assert(self.id, "ID Failed to generate")
assert(self.model, "Model is required for entity creation")
assert(self.coords, "Coords are required for entity creation")
EntityRelay.Add(self)
TriggerClientEvent(GetCurrentResourceName() .. "client:CreateEntity", -1, self)
end
function EntityRelay.GetAll()
return Entities
end
function EntityRelay.Get(id)
return Entities[id]
end
function EntityRelay.Add(self)
Entities[self.id] = self
end
function EntityRelay.Remove(id)
Entities[id] = nil
end
function EntityRelay.LoadModel(model)
return Utility.LoadModel(model)
end
return EntityRelay
+102
View File
@@ -0,0 +1,102 @@
Ids = Ids or Require("lib/utility/shared/ids.lua")
local Entities = {}
ServerEntity = {} -- Renamed from EntityRelay
--- Creates a server-side representation of an entity and notifies clients.
-- @param entityType string 'object', 'ped', or 'vehicle'
-- @param model string|number
-- @param coords vector3
-- @param rotation vector3|number Heading for peds/vehicles, rotation for objects
-- @param meta table Optional additional data
-- @return table The created entity data
function ServerEntity.Create(id, entityType, model, coords, rotation, meta)
local self = meta or {}
self.id = id or Ids.CreateUniqueId(Entities)
self.entityType = entityType
self.model = model
self.coords = coords
self.rotation = rotation or (entityType == 'object' and vector3(0.0, 0.0, 0.0) or 0.0) -- Default rotation or heading
self.resource = GetInvokingResource()
assert(self.id, "ID Failed to generate")
assert(self.entityType, "EntityType is required")
assert(self.model, "Model is required for entity creation")
assert(self.coords, "Coords are required for entity creation")
ServerEntity.Add(self)
TriggerClientEvent("community_bridge:client:CreateEntity", -1, self)
return self
end
--- Deletes a server-side entity representation and notifies clients.
-- @param id string|number The ID of the entity to delete.
function ServerEntity.Delete(id)
if Entities[id] then
ServerEntity.Remove(id)
TriggerClientEvent("community_bridge:client:DeleteEntity", -1, id)
end
end
--- Updates data for a server-side entity and notifies clients.
-- @param id string|number The ID of the entity to update.
-- @param data table The data fields to update.
function ServerEntity.Update(id, data)
local entity = Entities[id]
print("Updating entity: ", id, entity)
if not entity then return false end
for key, value in pairs(data) do
entity[key] = value
end
TriggerClientEvent("community_bridge:client:UpdateEntity", -1, id, data)
return true
end
--- Triggers a specific action on the client-side entity.
-- Clients will only execute the action if the entity is currently spawned for them.
-- @param entityId string|number The ID of the entity.
-- @param actionName string The name of the action to trigger (must match a function in ClientEntityActions).
-- @param ... any Additional arguments for the action function.
function ServerEntity.TriggerAction(entityId, actionName, endPosition, ...)
print("Triggering action: ", entityId, actionName, ...)
local entity = Entities[entityId]
if not entity then
print(string.format("[ServerEntity] Attempted to trigger action '%s' on non-existent entity %s", actionName, entityId))
return
end
print(string.format("[ServerEntity] Triggering action '%s' for entity %s", actionName, entityId))
TriggerClientEvent("community_bridge:client:TriggerEntityAction", -1, entityId, actionName, endPosition, ...)
end
function ServerEntity.GetAll()
return Entities
end
function ServerEntity.Get(id)
return Entities[id]
end
function ServerEntity.Add(self)
Entities[self.id] = self
end
function ServerEntity.Remove(id)
Entities[id] = nil
end
-- Clean up entities associated with a stopped resource
AddEventHandler('onResourceStop', function(resourceName)
local toDelete = {}
for id, entity in pairs(Entities) do
if entity.resource == resourceName then
table.insert(toDelete, id)
end
end
for _, id in pairs(toDelete) do
ServerEntity.Delete(id)
end
end)
return ServerEntity
+88 -71
View File
@@ -5,65 +5,99 @@ ItemsBuilder = {}
---This will generate the items in the formats of qb_core, qb_core_old and ox_inventory. It will then build a lua file in the generateditems folder of the community_bridge.
---@param invoking string
---@param itemsTable table
ItemsBuilder.Generate = function(invoking, itemsTable)
if not invoking or not itemsTable then return end
ItemsBuilder.Generate = function(invoking, outputPrefix, itemsTable, useQB)
if not itemsTable then return end
invoking = invoking or GetInvokingResource() or GetCurrentResourceName() or "community_bridge"
local resourcePath = GetResourcePath(GetCurrentResourceName()) .. "/generateditems/"
local resourcePath = string.format("%s/%s/", GetResourcePath(invoking), outputPrefix or "generated_items")
local function fileExists(path)
local file = io.open(path, "r")
if file then
file:close()
return true
else
return false
-- remove any doubles slashes after initial double slash
-- resourcePath = resourcePath:gsub("//", "/")
-- check if directory exists
local folder = io.open(resourcePath, "r")
if not folder then
local createDirectoryCMD = string.format("if not exist \"%s\" mkdir \"%s\"", resourcePath, resourcePath)
local returned, err = io.popen(createDirectoryCMD)
if not returned then
print("🌮 Failed to create directory: ", err)
return
end
returned:close()
print("🌮 Created Directory: ", resourcePath)
else
folder:close()
end
local qbOld = {}
local qbNew = {}
local oxInventory = {}
if useQB then
for key, item in pairs(itemsTable) do
qbOld[key] = string.format(
"['%s'] = {name = '%s', label = '%s', weight = %s, type = 'item', image = '%s', unique = %s, useable = %s, shouldClose = %s, description = '%s'},",
key, key, item.label, item.weight, item.image or key .. 'png', item.unique, item.useable, item.shouldClose, item.description
)
qbNew[key] = string.format(
"['%s'] = {['name'] = '%s', ['label'] = '%s', ['weight'] = %s, ['type'] = 'item',['image'] = '%s', ['unique'] = %s, ['useable'] = %s, ['shouldClose'] = %s, ['description'] = '%s'},",
key, key, item.label, item.weight, item.image or key .. 'png', item.unique, item.useable, item.shouldClose, item.description
)
imagewithoutpng = item?.image and item.image:gsub(".png", "")
shouldRenderImage = imagewithoutpng and imagewithoutpng ~= key
oxInventory[key] = string.format(
[[
["%s"] = {
label = "%s",
description = "%s",
weight = %s,
stack = %s,
close = %s,
%s
}, ]],
key, item.label, item.description, item.weight, not item.unique, item.shouldClose,
shouldRenderImage and item.image and string.format([[client = {
image = '%s'
}]], item.image) or ""
)
end
else
for key, item in pairs(itemsTable) do
-- ['peanut_butter'] = {['name'] = 'peanut_butter',['label'] = 'Peanut Butter',['weight'] = 1000,['type'] = 'item',['image'] = 'peanut_butter.png',['unique'] = false,['useable'] = false,['shouldClose'] = true,['combinable'] = nil,['description'] = 'A cooking ingredient'},
qbOld[key] = string.format(
"['%s'] = {name = '%s', label = '%s', weight = %s, type = 'item', image = '%s', unique = %s, useable = %s, shouldClose = %s, description = '%s'},",
key, key, item.label, item.weight, item?.client?.image or key .. 'png', not item.stack, true, item.close, item.description
)
qbNew[key] = string.format(
"['%s'] = {['name'] = '%s', ['label'] = '%s', ['weight'] = %s, ['type'] = 'item', ['image'] = '%s', ['unique'] = %s, ['useable'] = %s, ['shouldClose'] = %s, ['description'] = '%s'},",
key, key, item.label, item.weight, item?.client?.image or key .. 'png', not item.stack, true, item.close, item.description
)
imagewithoutpng = item?.client?.image and item.client.image:gsub(".png", "")
shouldRenderImage = imagewithoutpng and imagewithoutpng ~= key
oxInventory[key] = string.format(
[[
["%s"] = {
label = "%s",
description = "%s",
weight = %s,
stack = %s,
close = %s,
%s
}, ]],
key, item.label, item.description, item.weight, item.stack, item.close,
shouldRenderImage and item?.client?.image and string.format( [[client = {
image = '%s'
}]], item.client.image) or ""
)
end
end
local qbOldFilePath = resourcePath .. invoking .. "_qb_core_old.lua"
local qbNewFilePath = resourcePath .. invoking .. "_qb_core_new.lua"
local oxInventoryFilePath = resourcePath .. invoking .. "_ox_inventory.lua"
if fileExists(qbOldFilePath) or fileExists(qbNewFilePath) or fileExists(oxInventoryFilePath) then return end
local qbOld = {}
for key, item in pairs(itemsTable) do
qbOld[key] = string.format(
"['%s'] = {label = '%s', weight = %d, stack = %s, close = %s, description = '%s'}",
key, item.label, item.weight, tostring(item.stack), tostring(item.close), item.description
)
end
local qbNew = {}
for key, item in pairs(itemsTable) do
qbNew[key] = string.format(
"%s = {label = '%s', weight = %d, stack = %s, close = %s, description = '%s'}",
key, item.label, item.weight, tostring(item.stack), tostring(item.close), item.description
)
end
local oxInventory = {}
for key, item in pairs(itemsTable) do
oxInventory[key] = {
label = item.label,
weight = item.weight,
stack = item.stack,
close = item.close
}
end
local function writeInlineFile(fileName, content, useBrackets)
local function write(fileName, content)
local filePath = resourcePath .. fileName
local file = io.open(filePath, "w")
if file then
for key, value in pairs(content) do
if useBrackets then
-- For qb_core_old with brackets
file:write(string.format("['%s'] = %s,\n", key, value))
else
-- For qb_core_new without brackets
file:write(string.format("%s = %s,\n", key, value))
end
file:write(string.format("%s\n", value))
end
file:close()
print("🌮 Items File Created: " .. filePath)
@@ -72,28 +106,11 @@ ItemsBuilder.Generate = function(invoking, itemsTable)
end
end
local function writeSimplifiedFile(fileName, content)
local filePath = resourcePath .. fileName
local file = io.open(filePath, "w")
if file then
for key, item in pairs(content) do
file:write(string.format('["%s"] = {\n', key))
for k, v in pairs(item) do
local formattedValue = type(v) == "string" and string.format('"%s"', v) or tostring(v)
file:write(string.format(" %s = %s,\n", k, formattedValue))
end
file:write("},\n")
end
file:close()
print("🌮 Items File Created: " .. filePath)
else
print("🌮 Something Broke for: " .. filePath)
end
end
writeInlineFile(invoking.."_".."qb_core_old.lua", qbOld, true)
writeInlineFile(invoking.."_".."qb_core_new.lua", qbNew, false)
writeSimplifiedFile(invoking.."_".."ox_inventory.lua", oxInventory)
write(invoking.."(".."qb_core_old).lua", qbOld)
write(invoking.."(".."qb_core_new).lua", qbNew)
write(invoking.."(".."ox_inventory).lua", oxInventory)
end
exports('ItemsBuilder', ItemsBuilder)
+6 -2
View File
@@ -45,7 +45,7 @@ cLib = {
Math = Math or Require("lib/utility/shared/math.lua"),
LA = LA or Require("lib/utility/shared/la.lua"),
Perlin = Perlin or Require("lib/utility/shared/perlin.lua"),
-- Actions = Actions or Require("lib/shared/actions.lua"),
-- Action = Action or Require("lib/entities/shared/actions.lua"),
}
exports('cLib', cLib)
@@ -56,6 +56,8 @@ cLib.SQL = SQL or Require("lib/sql/server/sqlHandler.lua")
cLib.Logs = Logs or Require("lib/logs/server/logs.lua")
cLib.ItemsBuilder = ItemsBuilder or Require("lib/generators/server/ItemsBuilder.lua")
cLib.LootTables = LootTables or Require("lib/generators/server/lootTables.lua")
cLib.Cache = Cache or Require("lib/cache/shared/cache.lua")
cLib.ServerEntity = ServerEntity or Require("lib/entities/server/server_entity.lua")
if IsDuplicityVersion() then return cLib end
::client::
@@ -68,6 +70,8 @@ cLib.PlaceableObject = PlaceableObject or Require("lib/placers/client/placeable_
cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua")
cLib.Point = Point or Require("lib/points/client/points.lua")
cLib.Particle = Particle or Require("lib/particles/client/particles.lua")
cLib.Object = Object or Require("lib/entities/client/entity_object.lua")
cLib.Cache = Cache or Require("lib/cache/client/cache.lua")
cLib.ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua")
cLib.ClientEntityActions = ClientEntityActions or Require("lib/entities/client/client_entity_actions.lua")
return cLib
+4 -4
View File
@@ -1,7 +1,7 @@
Logs = Logs or {}
local WebhookURL = ""
local LogoForEmbed = ""
local WebhookURL = "" -- Add webhook URL here if using built-in logging system
local LogoForEmbed = "" -- optional logo for the embed
---This will send a log to the configured webhook or log system.
---@param src number
@@ -9,7 +9,7 @@ local LogoForEmbed = ""
---@return nil
Logs.Send = function(src, message)
if not src or not message then return end
if BridgeServerConfig.LogSystem == "builtin" then
if BridgeServerConfig.LogSystem == "built-in" then
PerformHttpRequest(WebhookURL, function(err, text, headers) end, 'POST', json.encode(
{
username = "Community_Bridge's Logger",
@@ -48,7 +48,7 @@ Logs.Send = function(src, message)
}), { ['Content-Type']= 'application/json' })
elseif BridgeServerConfig.LogSystem == "qb" then
return TriggerEvent('qb-log:server:CreateLog', GetCurrentResourceName(), GetCurrentResourceName(), 'green', message)
elseif BridgeServerConfig.LogSystem == "ox" then
elseif BridgeServerConfig.LogSystem == "ox_lib" then
return lib.logger(src, GetCurrentResourceName(), message)
end
end
+21 -11
View File
@@ -27,20 +27,30 @@ end
--- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create.
function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength)
LoadPtfxAsset(dict)
CreateThread(function()
UseParticleFxAssetNextCall(dict)
SetParticleFxNonLoopedColour(color.x, color.y, color.z)
if looped then
StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
UseParticleFxAssetNextCall(dict)
SetParticleFxNonLoopedColour(color.x, color.y, color.z)
local particle = nil
if looped then
particle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
CreateThread(function()
if loopLength then
Wait(loopLength)
RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01)
Particle.Remove(particle)
end
else
StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
end
RemoveNamedPtfxAsset(ptfx)
end)
end)
else
particle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
end
return particle
end
function Particle.Remove(particle)
if not particle then return end
StopParticleFxLooped(particle, false)
RemoveParticleFx(particle, false)
RemoveNamedPtfxAsset(particle)
end
function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength)
+10
View File
@@ -236,6 +236,16 @@ function Point.Get(id)
return ActivePoints[id]
end
function Point.UpdateCoords(id, coords)
local point = ActivePoints[id]
if point then
point.coords = coords
local oldCellKey = point.cellKey
point.cellKey = Point.GetCellKey(coords)
Point.UpdateInGrid(point, oldCellKey)
end
end
---Returns all points
---@return table
function Point.GetAll()
+10 -11
View File
@@ -125,7 +125,7 @@ end
---@param model string | number
---@return boolean
Utility.LoadModel = function(model)
if type(model) ~= 'number' then model = joaat(model) end
if type(model) ~= 'number' then model = joaat(model) end -- Use GetHashKey instead of joaat for client
if not IsModelValid(model) and not IsModelInCdimage(model) then return false end
RequestModel(model)
local count = 0
@@ -301,7 +301,7 @@ end
---@param model string | number
---@return number
Utility.GetEntityHashFromModel = function(model)
if type(model) ~= 'number' then model = joaat(model) end
if type(model) ~= 'number' then model = joaat(model) end -- Use GetHashKey instead of joaat for client
return model
end
@@ -365,16 +365,15 @@ Utility.RemovePoint = function(pointID)
end
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for _, blip in pairs(blipIDs) do
if blip and DoesBlipExist(blip) then
RemoveBlip(blip)
end
if resource ~= GetCurrentResourceName() then return end
for _, blip in pairs(blipIDs) do
if blip and DoesBlipExist(blip) then
RemoveBlip(blip)
end
for _, ped in pairs(spawnedPeds) do
if ped and DoesEntityExist(ped) then
DeleteEntity(ped)
end
end
for _, ped in pairs(spawnedPeds) do
if ped and DoesEntityExist(ped) then
DeleteEntity(ped)
end
end
end)
+6 -6
View File
@@ -258,7 +258,7 @@ LA.EaseVector = function(inout, a, b, t, easingType)
elseif inout == "inout" then
return LA.EaseInOutVector(a, b, t, easingType)
end
Assert(false, "Invalid type")
assert(false, "Invalid type")
end
LA.EaseOnAxis = function(inout, a, b, t, easingType, axis)
@@ -293,15 +293,15 @@ LA.DistanceCheck = function(pointA, pointB)
end
LA.Chance = function(chance)
Assert(chance, "Chance must be passed")
Assert(type(chance) == "number", "Chance must be a number")
Assert(chance >= 0 and chance <= 100, "Chance must be between 0 and 100")
assert(chance, "Chance must be passed")
assert(type(chance) == "number", "Chance must be a number")
assert(chance >= 0 and chance <= 100, "Chance must be between 0 and 100")
return math.random(1, 100) <= chance
end
LA.Vector4To3 = function(vector4)
Assert(vector4, "Vector4 must be passed")
Assert(type(vector4) == "vector4", "Vector4 must be a vector4")
assert(vector4, "Vector4 must be passed")
assert(type(vector4) == "vector4", "Vector4 must be a vector4")
return vector3(vector4.x, vector4.y, vector4.z), vector4.w
end
+13 -16
View File
@@ -162,11 +162,10 @@ RegisterNetEvent("playerJoining", function()
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Wait(1000)
for _, src in pairs(GetPlayers()) do
ReboundEntities.Refresh(src)
end
if resource ~= GetCurrentResourceName() then return end
Wait(1000)
for _, src in pairs(GetPlayers()) do
ReboundEntities.Refresh(src)
end
end)
@@ -175,7 +174,7 @@ if isServer then return ReboundEntities end
function ReboundEntities.LoadModel(model)
assert(model, "Model is nil")
model = type(model) == "number" and model or GetHashKey(model)
model = type(model) == "number" and model or GetHashKey(model) -- Corrected to GetHashKey
RequestModel(model)
for i = 1, 100 do
if HasModelLoaded(model) then return model end
@@ -307,20 +306,18 @@ end)
RegisterNetEvent(GetCurrentResourceName() .. ":client:SetReboundSyncData", function(id, key, value)
local entityData = ReboundEntities.GetById(id)
if entityData then
entityData[key] = value
if entityData.onSyncKeyChange then
entityData.onSyncKeyChange(entityData, key, value)
end
if not entityData then return end
entityData[key] = value
if entityData.onSyncKeyChange then
entityData.onSyncKeyChange(entityData, key, value)
end
end)
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
spawnLoopRunning = false
for _, entity in pairs(Entities) do
if entity.entity then DeleteEntity(tonumber(entity.entity)) end
end
if resource ~= GetCurrentResourceName() then return end
spawnLoopRunning = false
for _, entity in pairs(Entities) do
if entity.entity then DeleteEntity(tonumber(entity.entity)) end
end
end)
+37 -27
View File
@@ -1,35 +1,45 @@
-- local ReboundEntities = ReboundEntities or Require("shared/rebound_entities.lua")
-- local Actions = Actions or Require("shared/actions.lua")
-- local LA = LA or Require("shared/la.lua")
local ReboundEntities = ReboundEntities or Require("lib/utility/shared/rebound_entities.lua") -- Fixed path
local Action = Action or Require("lib/entities/shared/actions.lua") -- Fixed path and name
local LA = LA or Require("lib/utility/shared/la.lua") -- Fixed path
-- REA = {}
REA = {}
-- if not IsDuplicityVersion() then goto client end
if not IsDuplicityVersion() then goto client end
-- if IsDuplicityVersion() then return end
-- ::client::
if IsDuplicityVersion() then return end
::client::
-- local ActionsInProgress = {}
local ActionsInProgress = {}
-- Action.Create("LerpToPosition", function(reboundId, start, position, duration, shouldRepeat, overrideStartTime)
-- local re = ReboundEntities.Get(reboundId)
-- assert(re, "Rebound entity not found")
-- local entity = re and re.entity
-- if not entity then return end
-- local startTime = GetGameTimer()
-- local endTime = overrideStartTime or startTime + duration
-- ActionsInProgress[reboundId] = {reboundId, start, position, duration, shouldRepeat, startTime}
-- local t = 0
-- CreateThread(function()
-- while shouldRepeat or t < 1 do
-- t = (GetGameTimer() - startTime) / duration
-- local lerpPosition = LA.LerpVector(start, position, t)
-- SetEntityCoords(entity, lerpPosition)
-- Wait(0)
-- end
-- end)
-- end)
Action.Create("LerpToPosition", function(reboundId, start, position, duration, shouldRepeat, overrideStartTime)
local re = ReboundEntities.GetById(reboundId) -- Use GetById
assert(re, "Rebound entity not found")
local entity = re and re.entity
if not entity or not DoesEntityExist(entity) then return end -- Check existence
local startTime = GetGameTimer()
local endTime = overrideStartTime or startTime + duration
ActionsInProgress[reboundId] = {reboundId, start, position, duration, shouldRepeat, startTime}
local t = 0
CreateThread(function()
while shouldRepeat or t < 1 do
-- Check if entity still exists
if not re.entity or not DoesEntityExist(re.entity) then
ActionsInProgress[reboundId] = nil
break
end
entity = re.entity -- Update entity handle in case it changed (unlikely but safe)
t = (GetGameTimer() - startTime) / duration
local lerpPosition = LA.LerpVector(start, position, t)
SetEntityCoordsNoOffset(entity, lerpPosition.x, lerpPosition.y, lerpPosition.z, false, false, false) -- Use NoOffset
Wait(0)
end
-- Set final position if not repeating
if not shouldRepeat and re.entity and DoesEntityExist(re.entity) then
SetEntityCoordsNoOffset(re.entity, position.x, position.y, position.z, false, false, false)
end
ActionsInProgress[reboundId] = nil -- Clear when done
end)
end)
+30 -11
View File
@@ -9,18 +9,20 @@ Framework.GetFrameworkName = function()
return 'es_extended'
end
---comment
---This will return a table of the players data, this is an internal table and should not be used.
---@return table
Framework.GetPlayerData = function()
return ESX.PlayerData
end
---This will return a table of all the jobs in the framework.
---@return table
Framework.GetFrameworkJobs = function()
local jobs = lib.callback.await('community_bridge:Callback:GetFrameworkJobs', false)
return jobs
end
---comment
---This will return the players birth date
---@return string
Framework.GetPlayerDob = function()
local playerData = ESX.GetPlayerData()
@@ -28,11 +30,14 @@ Framework.GetPlayerDob = function()
return dob
end
---This will return the players metadata for the specified metadata key.
---@param metadata string
---@return table | nil
Framework.GetPlayerMetaData = function(metadata)
return ESX.GetPlayerData().metadata[metadata]
end
---comment
---This will prompt the user with a notification message
---@param message string
---@param type string
---@param time number
@@ -41,14 +46,28 @@ Framework.Notify = function(message, type, time)
return ESX.ShowNotification(message, type, time)
end
---comment
---Will Display the help text message on the screen
---@param message string
---@param _ unknown
---@return nil
Framework.ShowHelpText = function(message, _)
return exports['esx_textui']:TextUI(message, "info")
end
---This will hide the help text message on the screen
---@return nil
Framework.HideHelpText = function()
return exports['esx_textui']:HideUI()
end
---This will return the players identifier
---@return string
Framework.GetPlayerIdentifier = function()
local playerData = ESX.GetPlayerData()
return playerData.identifier
end
---comment
---This will return the players first name, and the last name
---@return string
---@return string
Framework.GetPlayerName = function()
@@ -56,7 +75,7 @@ Framework.GetPlayerName = function()
return playerData.firstName, playerData.lastName
end
---comment
---This will return the players job name, job label, job grade label and job grade level
---@return string
---@return string
---@return string
@@ -66,7 +85,7 @@ Framework.GetPlayerJob = function()
return playerData.job.name, playerData.job.label, playerData.job.grade_label, playerData.job.grade
end
---comment
---This will return a boolean if the player has the item in their inventory
---@param item string
---@return boolean
Framework.HasItem = function(item)
@@ -74,14 +93,14 @@ Framework.HasItem = function(item)
return hasItem > 0 and true or false
end
---comment
---This will return a table of the players inventory
---@return table
Framework.GetPlayerInventory = function()
local playerData = ESX.GetPlayerData()
return playerData.inventory
end
---comment
---This will return a number of the item in the players inventory
---@param item string
---@return number
Framework.GetItemCount = function(item)
@@ -90,7 +109,7 @@ Framework.GetItemCount = function(item)
return inventory[item].count or 0
end
---comment
---This will return a boolean if the player is dead
---@return boolean
Framework.GetIsPlayerDead = function()
local playerData = ESX.GetPlayerData()
@@ -114,4 +133,4 @@ RegisterNetEvent('esx:setJob', function(data)
PlayerJobGradeName = data.grade_label
PlayerJobGradeLevel = data.grade
TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel)
end)
end)
+2 -1
View File
@@ -245,7 +245,8 @@ end
Framework.RemoveAccountBalance = function(src, _type, amount)
local xPlayer = ESX.GetPlayerFromId(src)
if not xPlayer then return end
return xPlayer.removeAccountMoney(_type, amount)
xPlayer.removeAccountMoney(_type, amount)
return true
end
-- Framework.GetAccountBalance(src, _type)
+6
View File
@@ -49,10 +49,16 @@ Framework.Notify = function(message, type, time)
TriggerEvent('QBCore:Notify', message, 'primary', time)
end
---Will Display the help text message on the screen
---@param message string
---@param _position unknown
---@return nil
Framework.ShowHelpText = function(message, _position)
return exports['qb-core']:DrawText(message, _position)
end
---This will hide the help text message on the screen
---@return nil
Framework.HideHelpText = function()
return exports['qb-core']:HideText()
end
+14
View File
@@ -22,6 +22,20 @@ Framework.GetPlayerDob = function()
return playerData.charinfo.birthdate
end
---Will Display the help text message on the screen
---@param message string
---@param _ unknown
---@return nil
Framework.ShowHelpText = function(message, _)
return print("Community_bridge:WARN: ShowHelpText is not implemented for this framework, please set the helptext module to hide the help text.")
end
---This will hide the help text message on the screen
---@return nil
Framework.HideHelpText = function()
return print("Community_bridge:WARN: HideHelpText is not implemented for this framework, please set the helptext module to hide the help text.")
end
Framework.GetPlayerMetaData = function(metadata)
local playerData = QBox.GetPlayerData()
return playerData.metadata[metadata]
@@ -3,7 +3,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return 'default'
end
---This will get the fuel level of the vehicle.
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+4 -1
View File
@@ -6,13 +6,15 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
---@diagnostic disable-next-line: duplicate-set-field
Fuel.GetResourceName = function()
return resourceName
end
---This will get the fuel level of the vehicle.
---@param vehicle number The vehicle entity ID.
---@return number fuel The fuel level of the vehicle.
---@diagnostic disable-next-line: duplicate-set-field
Fuel.GetFuel = function(vehicle)
if not DoesEntityExist(vehicle) then return 0.0 end
return exports["lc_fuel"]:GetFuel(vehicle)
@@ -22,6 +24,7 @@ end
---@param vehicle number The vehicle entity ID.
---@param fuel number The fuel level to set.
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Fuel.SetFuel = function(vehicle, fuel, type)
if not DoesEntityExist(vehicle) then return end
return exports["lc_fuel"]:SetFuel(vehicle, fuel)
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+1 -1
View File
@@ -6,7 +6,7 @@ Fuel = Fuel or {}
---This will get the name of the Fuel being used (if a supported Fuel).
---@return string
Fuel.GetFuelName = function()
Fuel.GetResourceName = function()
return resourceName
end
+25
View File
@@ -0,0 +1,25 @@
HelpText = HelpText or {}
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(message, _position)
return Framework.ShowHelpText(message, _position)
end
---This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function()
return Framework.HideHelpText()
end
RegisterNetEvent('community_bridge:Client:ShowHelpText', function(message, position)
HelpText.ShowHelpText(message, position)
end)
RegisterNetEvent('community_bridge:Client:HideHelpText', function()
HelpText.HideHelpText()
end)
+17
View File
@@ -0,0 +1,17 @@
HelpText = HelpText or {}
---This will show a help text message to the specified player at the screen position passed
---@param src number
---@param message string
---@param position string
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(src, message, position)
TriggerClientEvent('community_bridge:Client:ShowHelpText', src, message, position)
end
---This will hide the help text message on the screen for the specified player
---@param src number
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function(src)
TriggerClientEvent('community_bridge:Client:HideHelpText', src)
end
+21
View File
@@ -0,0 +1,21 @@
HelpText = HelpText or {}
local resourceName = "cd_drawtextui"
local configValue = BridgeSharedConfig.HelpText
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(message, _position)
return TriggerEvent('cd_drawtextui:ShowUI', 'show', message)
end
---This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function()
return TriggerEvent('cd_drawtextui:HideUI')
end
+20
View File
@@ -0,0 +1,20 @@
HelpText = HelpText or {}
local resourceName = "jg-textui"
local configValue = BridgeSharedConfig.HelpText
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(message, _position)
return exports['jg-textui']:DrawText(message)
end
---This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function()
return exports['jg-textui']:HideText()
end
+20
View File
@@ -0,0 +1,20 @@
HelpText = HelpText or {}
local resourceName = "lab-HintUI"
local configValue = BridgeSharedConfig.HelpText
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(message, _position)
return exports['lab-HintUI']:Show(message, "Hint Text")
end
---This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function()
return exports['lab-HintUI']:Hide()
end
+20
View File
@@ -0,0 +1,20 @@
HelpText = HelpText or {}
local resourceName = "okokTextUI"
local configValue = BridgeSharedConfig.HelpText
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(message, _position)
return exports['okokTextUI']:Open(message, 'darkblue', _position, false)
end
---This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function()
return exports['okokTextUI']:Close()
end
+21
View File
@@ -0,0 +1,21 @@
HelpText = HelpText or {}
local resourceName = "ox_lib"
local configValue = BridgeSharedConfig.HelpText
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.ShowHelpText = function(message, _position)
if _position == nil then _position = 'left-center' end
return exports.ox_lib:showTextUI(message, { position = _position })
end
---This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
HelpText.HideHelpText = function()
return exports.ox_lib:hideTextUI()
end
File renamed without changes.
File renamed without changes.
+8 -4
View File
@@ -36,7 +36,7 @@ function OxToQBInput(data)
name = i,
type = OxTypeToQBType(v.type),
isRequired = v.required,
placeholder = v.default,
default = v.default or "",
}
if v.type == "select" then
input.text = ""
@@ -47,8 +47,12 @@ function OxToQBInput(data)
elseif v.type == "checkbox" then
input.text = ""
input.options = {}
for k, j in pairs(v.options) do
table.insert(input.options, {value = j.value, text = j.label})
if v.options then -- Checks if options varible is valid so checkboxes are bundled together (not used by ox for each checkpoint)
for k, j in pairs(v.options) do
table.insert(input.options, {value = j.value, text = j.label, checked = j.checked}) -- added checked option (used to show box as ticked or not)
end
else -- If options is not valid or people pass a single checkbox then it will be a single checkbox per entry
table.insert(input.options, {value = v.value, text = v.label, checked = v.checked}) -- Kept value just incase it's used for other stuffs
end
end
table.insert(returnData, input)
@@ -85,4 +89,4 @@ function OpenInput(title, data, isQBFormat, submitText)
convertedData[tonumber(i)] = v
end
return convertedData
end
end
+1 -17
View File
@@ -124,23 +124,6 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo
TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id)
end
---This will get the data about an item such as name, label, stack, weight, description and image.
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.stack or "true",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.client and itemData.client.image or Inventory.GetImagePath(item),
}
return repackedTable
end
---This will set the metadata of an item in the inventory.
---@param src number
---@param item string
@@ -167,6 +150,7 @@ end
---@return string
Inventory.GetImagePath = function(item)
item = Inventory.StripPNG(item)
print(item)
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
+22 -80
View File
@@ -1,96 +1,38 @@
Notify = Notify or {}
local notifyType = BridgeClientConfig.NotifySystem
local helptextType = BridgeClientConfig.ShowHelpText
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return "none"
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
if notifyType == 'qb' then
return Framework.Notify(message, nil, time)
elseif notifyType == 'mythic' then
return exports['mythic_notify']:SendAlert('inform', message, time)
elseif notifyType == 'pNotify' then
return exports['pNotify']:SendNotification({ text = message, type = _type, timeout = time, layout = 'centerRight' })
elseif notifyType == 'esx' then
return Framework.Notify(message, _type, time)
elseif notifyType == 'ox' then
return exports.ox_lib:notify({ description = message, type = _type, position = 'center-left' })
elseif notifyType == 'okok' then
return exports['okokNotify']:Alert('Notification', message, time, _type, false)
elseif notifyType == 't-notify' then
return exports['t-notify']:Alert({ style = 'info', message = message, duration = time, })
elseif notifyType == 'wasabi' then
return exports.wasabi_notify:notify(_type, message, time, _type)
elseif notifyType == 'r_notify' then
return exports.r_notify:notify({title = 'Notification', content = message, type = _type, icon = "fas fa-check", duration = time, position = 'top-right', sound = false})
elseif notifyType == 'custom' then
return Prints.Error("You have not set up a custom notify in community_bridge")
else
return Prints.Error("You have not configured a notify in community_bridge")
end
end
---This will show a help text message at the screen position passed
---@param message string
---@param _position string
---@return nil
Notify.ShowHelpText = function(message, _position)
if helptextType == 'ox' then
if _position == nil then _position = 'left-center' end
return exports.ox_lib:showTextUI(message, { position = _position })
elseif helptextType == 'jg' then
return exports['jg-textui']:DrawText(message)
elseif helptextType == 'qb' then
if _position == nil then _position = 'left' end
return Framework.ShowHelpText(message, _position)
elseif helptextType == 'okok' then
if _position == nil then _position = 'left' end
return exports['okokTextUI']:Open(message, 'darkblue', _position, false)
elseif helptextType == 'cd' then
return TriggerEvent('cd_drawtextui:ShowUI', 'show', message)
elseif helptextType == 'lab' then
return exports['lab-HintUI']:Show(message, "Hint Text")
elseif helptextType == 'custom' then
return Prints.Error("You have not set up a custom ShowHelpText in community_bridge")
else
return Prints.Error("You have not configured a ShowHelpText in community_bridge")
end
end
---This will hide the help text message on the screen
---@return nil
Notify.HideHelpText = function()
if helptextType == 'ox' then
return exports.ox_lib:hideTextUI()
elseif helptextType == 'jg' then
return exports['jg-textui']:HideText()
elseif helptextType == 'qb' then
return Framework.HideHelpText()
elseif helptextType == 'okok' then
return exports['okokTextUI']:Close()
elseif helptextType == 'cd' then
return TriggerEvent('cd_drawtextui:HideUI')
elseif helptextType == 'lab' then
return exports['lab-HintUI']:Hide()
elseif helptextType == 'custom' then
return Prints.Error("You have not set up a custom HideHelpText in community_bridge")
else
return Prints.Error("You have not configured a HideHelpText in community_bridge")
end
return Framework.Notify(message, nil, time)
end
RegisterNetEvent('community_bridge:Client:Notify', function(message, _type, time)
Notify.SendNotify(message, _type, time)
end)
RegisterNetEvent('community_bridge:Client:ShowHelpText', function(message, position)
Notify.ShowHelpText(message, position)
end)
---------[[Depricated Stuff Below, please adjust to the HelpText module instead]]--------
RegisterNetEvent('community_bridge:Client:HideHelpText', function()
Notify.HideHelpText()
end)
---Depricated: This will hide the help text message on the screen
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.HideHelpText = function()
return HelpText.HideHelpText()
end
---Depricated: This will show a help text message at the screen position passed
---@param message string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.ShowHelpText = function(message, position)
return HelpText.ShowHelpText(message, position)
end
+13 -4
View File
@@ -5,20 +5,29 @@ Notify = Notify or {}
---@param message string
---@param _type string
---@param time number
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(src, message, _type, time)
TriggerClientEvent('community_bridge:Client:Notify', src, message, _type, time)
end
---This will show a help text message to the specified player at the screen position passed
---------[[Depricated Stuff Below, please adjust to the HelpText module instead]]--------
---
---
---
---Depricated -- This will show a help text message to the specified player at the screen position passed
---@param src number
---@param message string
---@param position string
---@diagnostic disable-next-line: duplicate-set-field
Notify.ShowHelpText = function(src, message, position)
TriggerClientEvent('community_bridge:Client:ShowHelpText', src, message, position)
return HelpText.ShowHelpText(src, message, position)
end
---This will hide the help text message on the screen for the specified player
---Depricated -- This will hide the help text message on the screen for the specified player
---@param src number
---@diagnostic disable-next-line: duplicate-set-field
Notify.HideHelpText = function(src)
TriggerClientEvent('community_bridge:Client:HideHelpText', src)
return HelpText.HideHelpText(src)
end
+20
View File
@@ -0,0 +1,20 @@
Notify = Notify or {}
local resourceName = "mythic_notify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['mythic_notify']:SendAlert('inform', message, time)
end
+20
View File
@@ -0,0 +1,20 @@
Notify = Notify or {}
local resourceName = "okokNotify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['okokNotify']:Alert('Notification', message, time, _type, false)
end
+21
View File
@@ -0,0 +1,21 @@
Notify = Notify or {}
local resourceName = "ox_lib"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports.ox_lib:notify({ description = message, type = _type, position = 'center-left' })
end
+20
View File
@@ -0,0 +1,20 @@
Notify = Notify or {}
local resourceName = "pNotify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['pNotify']:SendNotification({ text = message, type = _type, timeout = time, layout = 'centerRight' })
end
+20
View File
@@ -0,0 +1,20 @@
Notify = Notify or {}
local resourceName = "r_notify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports.r_notify:notify({title = 'Notification', content = message, type = _type, icon = "fas fa-check", duration = time, position = 'top-right', sound = false})
end
+20
View File
@@ -0,0 +1,20 @@
Notify = Notify or {}
local resourceName = "t-notify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['t-notify']:Alert({ style = 'info', message = message, duration = time, })
end
+20
View File
@@ -0,0 +1,20 @@
Notify = Notify or {}
local resourceName = "wasabi_notify"
local configValue = BridgeSharedConfig.Notify
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Notify.GetResourceName = function()
return resourceName
end
---This will send a notify message of the type and time passed
---@param message string
---@param _type string
---@param time number
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports.wasabi_notify:notify(_type, message, time, _type)
end
@@ -1,5 +1,6 @@
Phone = Phone or {}
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(email, title, message)
return false, Print.Error('There Is No Phone Bridged.')
end
@@ -1,9 +1,11 @@
Phone = Phone or {}
---@diagnostic disable-next-line: duplicate-set-field
Phone.GetPlayerPhone = function(src)
return false, Print.Error('There Is No Phone Bridged.')
end
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(src, email, title, message)
return false, Print.Error('There Is No Phone Bridged.')
end
+1
View File
@@ -9,6 +9,7 @@ Phone = Phone or {}
---@param title string
---@param message string
---@return boolean
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(email, title, message)
return exports["gksphone"]:SendNewMail({ sender = email, image = '/html/static/img/icons/mail.png', subject = title, message = message })
end
+3 -1
View File
@@ -5,7 +5,8 @@ Phone = Phone or {}
---comment
---@param src number
---@return number||boolean
---@return number| boolean
---@diagnostic disable-next-line: duplicate-set-field
Phone.GetPlayerPhone = function(src)
return exports["gksphone"]:GetPhoneBySource(src) or false
end
@@ -16,6 +17,7 @@ end
---@param title string
---@param message string
---@return boolean
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(src, email, title, message)
local data = {}
data.sender = email
+1
View File
@@ -8,6 +8,7 @@ Phone = Phone or {}
---@param title string
---@param message string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(email, title, message)
TriggerServerEvent('community_bridge:Server:genericEmail', {email = email, title = title, message = message})
end
+2
View File
@@ -3,6 +3,7 @@ local configValue = BridgeSharedConfig.Phone
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Phone = Phone or {}
---@diagnostic disable-next-line: duplicate-set-field
Phone.GetPlayerPhone = function(src)
return exports["lb-phone"]:GetEquippedPhoneNumber(src) or false
end
@@ -13,6 +14,7 @@ end
---@param title string
---@param message string
---@return boolean
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(src, email, title, message)
local numberNumber = exports["lb-phone"]:GetEquippedPhoneNumber(src)
if not numberNumber then return false, Prints.Error("Could not Find Phone number") end
+2 -2
View File
@@ -8,11 +8,11 @@ Phone = Phone or {}
---@param title string
---@param message string
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
Phone.SendEmail = function(email, title, message)
return TriggerServerEvent('qs-smartphone:server:sendNewMail', { sender = email, subject = title, message = message, button = {} })
return true, TriggerServerEvent('qs-smartphone:server:sendNewMail', { sender = email, subject = title, message = message, button = {} })
end
RegisterNetEvent('community_bridge:Server:genericEmail', function(data)
TriggerServerEvent('qs-smartphone:server:sendNewMail', { sender = data.email, subject = data.title, message = data.message, button = {} })
return true
end)
+2
View File
@@ -2,9 +2,11 @@ local resourceName = "qs-smartphone"
local configValue = BridgeSharedConfig.Phone
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Phone = Phone or {}
---comment
---@param src number
---@return number||boolean
---@diagnostic disable-next-line: duplicate-set-field
Phone.GetPlayerPhone = function(src)
return exports['qs-base']:GetPlayerPhone(src) or false
end
+1
View File
@@ -49,6 +49,7 @@ end
---@param cb any
---@param isQBInput boolean
---@return nil
---@diagnostic disable-next-line: duplicate-set-field
function ProgressBar.Open(options, cb, isQBInput)
if isQBInput then
options = convertFromQB(options)
@@ -45,6 +45,7 @@ end
---@param cb any
---@param qbFormat boolean
---@return success boolean
---@diagnostic disable-next-line: duplicate-set-field
function ProgressBar.Open(options, cb, qbFormat)
if not exports['progressbar'] then return false end
+15
View File
@@ -0,0 +1,15 @@
Skills = Skills or {}
local resourceName = "OT_skills"
local configValue = BridgeSharedConfig.Skills
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return resourceName
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(skillName)
local skillData = exports.OT_skills:getSkill(skillName)
return skillData.level or 0
end
+29
View File
@@ -0,0 +1,29 @@
Skills = Skills or {}
local resourceName = "OT_skills"
local configValue = BridgeSharedConfig.Skills
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return resourceName
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(src, skillName)
local skillData = exports.OT_skills:getSkill(src, skillName)
return skillData.level or 0
end
Skills.AddXp = function(src, skillName, amount)
local skillData = exports.OT_skills:getSkill(src, skillName)
if not skillData then return false, print("Skill not found") end
exports.OT_skills:addXP(src, skillName, amount)
return true
end
Skills.RemoveXp = function(src, skillName, amount)
local skillData = exports.OT_skills:getSkill(src, skillName)
if not skillData then return false, print("Skill not found") end
exports.OT_skills:removeXP(src, skillName, amount)
return true
end
+15
View File
@@ -0,0 +1,15 @@
Skills = Skills or {}
local function warnUser()
print("Currently only a few skill systems are supported by Community Bridge, you are using a resource that requires the skills module to be used.")
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return "none"
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(skillName)
return 0, warnUser()
end
+25
View File
@@ -0,0 +1,25 @@
Skills = Skills or {}
local function warnUser()
print("Currently only a few skill systems are supported by Community Bridge, you are using a resource that requires the skills module to be used.")
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return "none"
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(src, skillName)
return 0, warnUser()
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.AddXp = function(src, skillName, amount)
return false, warnUser()
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.RemoveXp = function(src, skillName, amount)
return false, warnUser()
end
+15
View File
@@ -0,0 +1,15 @@
Skills = Skills or {}
local resourceName = "evolent_skills"
local configValue = BridgeSharedConfig.Skills
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return resourceName
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(skillName)
local skillData = exports.evolent_skills:getSkillLevel(skillName)
return skillData or 0
end
+31
View File
@@ -0,0 +1,31 @@
Skills = Skills or {}
local resourceName = "evolent_skills"
local configValue = BridgeSharedConfig.Skills
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return resourceName
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(src, skillName)
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
return skillData or 0
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.AddXp = function(src, skillName, amount)
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
if not skillData then return false, print("Skill not found") end
exports.evolent_skills:addXp(src, skillName, amount)
return true
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.RemoveXp = function(src, skillName, amount)
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
if not skillData then return false, print("Skill not found") end
exports.evolent_skills:removeXp(src, skillName, amount)
return true
end
+15
View File
@@ -0,0 +1,15 @@
Skills = Skills or {}
local resourceName = "pickle_xp"
local configValue = BridgeSharedConfig.Skills
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return resourceName
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(skillName)
local skillData = exports.OT_skills:GetLevel(skillName)
return skillData or 0
end
+29
View File
@@ -0,0 +1,29 @@
Skills = Skills or {}
local resourceName = "pickle_xp"
local configValue = BridgeSharedConfig.Skills
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetResourceName = function()
return resourceName
end
---@diagnostic disable-next-line: duplicate-set-field
Skills.GetSkillLevel = function(src, skillName)
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
return skillData or 0
end
Skills.AddXp = function(src, skillName, amount)
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
if not skillData then return false, print("Skill not found") end
exports.pickle_xp:AddPlayerXP(src, skillName, amount)
return true
end
Skills.RemoveXp = function(src, skillName, amount)
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
if not skillData then return false, print("Skill not found") end
exports.pickle_xp:RemovePlayerXP(src, skillName, amount)
return true
end
File renamed without changes.
+1 -1
View File
@@ -5,7 +5,7 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
local targetDebug = false
local function detectDebugEnabled()
if BridgeClientConfig.DebugLevel == 2 then
if BridgeSharedConfig.DebugLevel == 2 then
targetDebug = true
end
end
+1 -1
View File
@@ -5,7 +5,7 @@ if GetResourceState('ox_target') == 'started' then return end -- this is for old
local targetDebug = false
local function detectDebugEnabled()
if BridgeClientConfig.DebugLevel == 2 then
if BridgeSharedConfig.DebugLevel == 2 then
targetDebug = true
end
end
+1 -1
View File
@@ -5,7 +5,7 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
local targetDebug = false
local function detectDebugEnabled()
if BridgeClientConfig.DebugLevel == 2 then
if BridgeSharedConfig.DebugLevel == 2 then
targetDebug = true
end
end
+1 -5
View File
@@ -1,11 +1,7 @@
BridgeClientConfig = {}
BridgeClientConfig.DebugLevel = 0 -- Debug level, 0 for none, 1 for some, 2 for all data
BridgeClientConfig.NotifySystem = "ox" -- [ ox | qb | esx | mythic | pNotify | t-notify | wasabi | lab | custom ]
BridgeClientConfig.ShowHelpText = "ox" -- [ ox | qb | jg | okok | cd | lab | custom ]
BridgeClientConfig.InputSystem = "auto" -- [ auto | ox | qb ]
BridgeClientConfig.InputSystem = "auto" -- [ auto | ox_lib | qb-input ]
BridgeClientConfig.MenuSystem = "auto" -- [ auto | ox_lib | qb-menu ]
BridgeClientConfig.ProgressBarSystem = "auto" -- [ auto | ox_lib | progressbar ]
BridgeClientConfig.ZoneSystem = "ox" -- [ ox | poly ]
BridgeClientConfig.VehicleKey = "auto" -- [ auto | qb-vehiclekeys | MrNewbVehicleKeys | jaksams_VehiclesKeys | wasabi_carlock | mk_vehiclekeys | qbx_vehiclekeys | qs-vehiclekeys | t1ger_keys | Renewed-Vehiclekeys | mono_carkeys| cd_garage | okokGarage | F_RealCarKeysSystem
BridgeClientConfig.Fuel = "auto" -- [ auto | LegacyFuel | ox_fuel | ps-fuel | qs-fuelstations | Renewed-Fuel | ti_fuel | lc_fuel | x-fuel | cdn-fuel | esx-sna-fuel | BigDaddy-Fuel | okokGasStation ]
BridgeClientConfig.TargetSystem = "auto" -- [ auto | ox_target | qb-target | sleepless_interact ] -- sleepless is only partially supported and would need another system in place
+2 -2
View File
@@ -1,6 +1,6 @@
BridgeServerConfig = {}
BridgeServerConfig.LogSystem = "ox" -- [ builtin | qb | ox ]
BridgeServerConfig.WebhookURL = "PUT_WEBHOOK_URL_HERE" -- only if using builtin
BridgeServerConfig.LogSystem = "built-in" -- [ built-in | qb | ox_lib ]
BridgeServerConfig.WebhookURL = "PUT_WEBHOOK_URL_HERE" -- only if using builtin
BridgeServerConfig.WebhookImage = "https://cdn.discordapp.com/avatars/299410129982455808/31ce635662206e8bd0132c34ce9ce683?size=1024"
BridgeServerConfig.MaxInventorySlots = 50
+3
View File
@@ -1,6 +1,9 @@
BridgeSharedConfig = {}
BridgeSharedConfig.Lang = "auto" -- Change this to your preferred language (must match the locale file name ex. en or fr etc)
BridgeSharedConfig.DebugLevel = 0 -- Change this to your Debug level, 0 for none, 1 for some, 2 for all data
BridgeSharedConfig.Notify = "auto" -- [ auto | ox_lib | r_notify | okokNotify | mythic_notify | pNotify | t-notify | wasabi_notify]
BridgeSharedConfig.HelpText = "auto" -- [ auto | ox_lib | jg-textui | cd_drawtextui | lab-HintUI | okokTextUI]
BridgeSharedConfig.Phone = "auto" -- [ auto | qs-smartphone | lb-phone | gksphone]
BridgeSharedConfig.Skills = "auto" -- [ auto | OT_skills | evolent_skills | pickle_xp]
return BridgeSharedConfig
+19
View File
@@ -0,0 +1,19 @@
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Bridge.Cache.OnChange("Ped", function(newValue, oldValue)
print("Ped changed from " .. tostring(oldValue) .. " to " .. tostring(newValue))
end)
end
end)
RegisterCommand("testcache", function(source, args, rawCommand)
-- local cache = Bridge.Cache.Get("Ped")
Bridge.Cache.Create("TestCache", function()
return math.random(1, 100)
end, 1000)
Bridge.Cache.OnChange("TestCache", function(newValue, oldValue)
print("TestCache changed from " .. tostring(oldValue) .. " to " .. tostring(newValue))
end)
end)