diff --git a/README.md b/README.md index 6b6e518..9f4e33d 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +## ๐Ÿงฐ 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.โ€ + +--- diff --git a/fxmanifest.lua b/fxmanifest.lua index 82f0d80..2d5e89f 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -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', } diff --git a/init.lua b/init.lua index a13bd78..533efb5 100644 --- a/init.lua +++ b/init.lua @@ -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() diff --git a/lib/cache/client/cache.lua b/lib/cache/client/cache.lua new file mode 100644 index 0000000..add0124 --- /dev/null +++ b/lib/cache/client/cache.lua @@ -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 \ No newline at end of file diff --git a/lib/cache/server/cache.lua b/lib/cache/server/cache.lua new file mode 100644 index 0000000..e69de29 diff --git a/lib/cache/shared/cache.lua b/lib/cache/shared/cache.lua new file mode 100644 index 0000000..df2ee0e --- /dev/null +++ b/lib/cache/shared/cache.lua @@ -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 + + diff --git a/lib/entities/client/client_entity.lua b/lib/entities/client/client_entity.lua new file mode 100644 index 0000000..751f6e0 --- /dev/null +++ b/lib/entities/client/client_entity.lua @@ -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 diff --git a/lib/entities/client/client_entity_actions.lua b/lib/entities/client/client_entity_actions.lua new file mode 100644 index 0000000..9cf9f1e --- /dev/null +++ b/lib/entities/client/client_entity_actions.lua @@ -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 diff --git a/lib/entities/client/client_entity_actions_ext.lua b/lib/entities/client/client_entity_actions_ext.lua new file mode 100644 index 0000000..99622f2 --- /dev/null +++ b/lib/entities/client/client_entity_actions_ext.lua @@ -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 diff --git a/lib/entities/client/entity_base.lua b/lib/entities/client/entity_base.lua deleted file mode 100644 index 1ac6022..0000000 --- a/lib/entities/client/entity_base.lua +++ /dev/null @@ -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 \ No newline at end of file diff --git a/lib/entities/client/entity_object.lua b/lib/entities/client/entity_object.lua deleted file mode 100644 index ab6ee2d..0000000 --- a/lib/entities/client/entity_object.lua +++ /dev/null @@ -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 \ No newline at end of file diff --git a/lib/entities/server/entity_relay.lua b/lib/entities/server/entity_relay.lua deleted file mode 100644 index 5c75eb4..0000000 --- a/lib/entities/server/entity_relay.lua +++ /dev/null @@ -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 \ No newline at end of file diff --git a/lib/entities/server/server_entity.lua b/lib/entities/server/server_entity.lua new file mode 100644 index 0000000..b040332 --- /dev/null +++ b/lib/entities/server/server_entity.lua @@ -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 diff --git a/lib/generators/server/ItemsBuilder.lua b/lib/generators/server/ItemsBuilder.lua index c2c6b1c..48bb998 100644 --- a/lib/generators/server/ItemsBuilder.lua +++ b/lib/generators/server/ItemsBuilder.lua @@ -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) diff --git a/lib/init.lua b/lib/init.lua index 408f616..7d8cc5a 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -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 \ No newline at end of file diff --git a/lib/logs/server/logs.lua b/lib/logs/server/logs.lua index 29706e3..188cc53 100644 --- a/lib/logs/server/logs.lua +++ b/lib/logs/server/logs.lua @@ -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 diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index f0cc83a..28da84b 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -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) diff --git a/lib/points/client/points.lua b/lib/points/client/points.lua index 9acf9d5..06f9769 100644 --- a/lib/points/client/points.lua +++ b/lib/points/client/points.lua @@ -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() diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index 2b7f62f..5363e30 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -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) diff --git a/lib/utility/shared/la.lua b/lib/utility/shared/la.lua index 2539807..ff71cff 100644 --- a/lib/utility/shared/la.lua +++ b/lib/utility/shared/la.lua @@ -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 diff --git a/lib/utility/shared/rebound_entities.lua b/lib/utility/shared/rebound_entities.lua index c1f3c26..2ab3ee7 100644 --- a/lib/utility/shared/rebound_entities.lua +++ b/lib/utility/shared/rebound_entities.lua @@ -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) diff --git a/lib/utility/shared/rebound_entitiy_actions.lua b/lib/utility/shared/rebound_entitiy_actions.lua index 552bd8f..78bee35 100644 --- a/lib/utility/shared/rebound_entitiy_actions.lua +++ b/lib/utility/shared/rebound_entitiy_actions.lua @@ -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) diff --git a/modules/dialogue/default/client/client.lua b/modules/dialogue/_default/client/client.lua similarity index 100% rename from modules/dialogue/default/client/client.lua rename to modules/dialogue/_default/client/client.lua diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index 9f0145c..ea14754 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -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) \ No newline at end of file diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index fabaf0e..fc65ceb 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -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) diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index a3ed050..f1ab2e9 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -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 diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index a0da4bb..da1b25c 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -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] diff --git a/modules/fuel/_defualts/client.lua b/modules/fuel/_default/client.lua similarity index 95% rename from modules/fuel/_defualts/client.lua rename to modules/fuel/_default/client.lua index 9663fd4..681b2e4 100644 --- a/modules/fuel/_defualts/client.lua +++ b/modules/fuel/_default/client.lua @@ -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. diff --git a/modules/fuel/bigDaddy-Fuel/client.lua b/modules/fuel/bigDaddy-Fuel/client.lua index d2e7a92..daa86a6 100644 --- a/modules/fuel/bigDaddy-Fuel/client.lua +++ b/modules/fuel/bigDaddy-Fuel/client.lua @@ -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 diff --git a/modules/fuel/cdn-fuel/client.lua b/modules/fuel/cdn-fuel/client.lua index c9ae93a..093987f 100644 --- a/modules/fuel/cdn-fuel/client.lua +++ b/modules/fuel/cdn-fuel/client.lua @@ -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 diff --git a/modules/fuel/esx-sna-fuel/client.lua b/modules/fuel/esx-sna-fuel/client.lua index 6c4588c..3309621 100644 --- a/modules/fuel/esx-sna-fuel/client.lua +++ b/modules/fuel/esx-sna-fuel/client.lua @@ -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 diff --git a/modules/fuel/lc_fuel/client.lua b/modules/fuel/lc_fuel/client.lua index 5df01b9..ee85467 100644 --- a/modules/fuel/lc_fuel/client.lua +++ b/modules/fuel/lc_fuel/client.lua @@ -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) diff --git a/modules/fuel/legacyfuel/client.lua b/modules/fuel/legacyfuel/client.lua index 1eb4e92..6c64d4f 100644 --- a/modules/fuel/legacyfuel/client.lua +++ b/modules/fuel/legacyfuel/client.lua @@ -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 diff --git a/modules/fuel/okokGasStation/client.lua b/modules/fuel/okokGasStation/client.lua index 8c5741b..02c5ed0 100644 --- a/modules/fuel/okokGasStation/client.lua +++ b/modules/fuel/okokGasStation/client.lua @@ -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 diff --git a/modules/fuel/ox_fuel/client.lua b/modules/fuel/ox_fuel/client.lua index 75da8d7..16d7772 100644 --- a/modules/fuel/ox_fuel/client.lua +++ b/modules/fuel/ox_fuel/client.lua @@ -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 diff --git a/modules/fuel/ps-fuel/client.lua b/modules/fuel/ps-fuel/client.lua index 310f484..8f28f7e 100644 --- a/modules/fuel/ps-fuel/client.lua +++ b/modules/fuel/ps-fuel/client.lua @@ -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 diff --git a/modules/fuel/qs-fuelstations/client.lua b/modules/fuel/qs-fuelstations/client.lua index 9a4f5d7..8b3827f 100644 --- a/modules/fuel/qs-fuelstations/client.lua +++ b/modules/fuel/qs-fuelstations/client.lua @@ -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 diff --git a/modules/fuel/renewed-Fuel/client.lua b/modules/fuel/renewed-Fuel/client.lua index ca6e225..262740e 100644 --- a/modules/fuel/renewed-Fuel/client.lua +++ b/modules/fuel/renewed-Fuel/client.lua @@ -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 diff --git a/modules/fuel/ti_fuel/client.lua b/modules/fuel/ti_fuel/client.lua index 253081c..d0fdcef 100644 --- a/modules/fuel/ti_fuel/client.lua +++ b/modules/fuel/ti_fuel/client.lua @@ -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 diff --git a/modules/fuel/x-fuel/client.lua b/modules/fuel/x-fuel/client.lua index 6eeaba5..1011e3b 100644 --- a/modules/fuel/x-fuel/client.lua +++ b/modules/fuel/x-fuel/client.lua @@ -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 diff --git a/modules/helptext/_default/client.lua b/modules/helptext/_default/client.lua new file mode 100644 index 0000000..c1e4ea1 --- /dev/null +++ b/modules/helptext/_default/client.lua @@ -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) \ No newline at end of file diff --git a/modules/helptext/_default/server.lua b/modules/helptext/_default/server.lua new file mode 100644 index 0000000..448e815 --- /dev/null +++ b/modules/helptext/_default/server.lua @@ -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 \ No newline at end of file diff --git a/modules/helptext/cd_drawtextui/client.lua b/modules/helptext/cd_drawtextui/client.lua new file mode 100644 index 0000000..4ae1271 --- /dev/null +++ b/modules/helptext/cd_drawtextui/client.lua @@ -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 \ No newline at end of file diff --git a/modules/helptext/jg-textui/client.lua b/modules/helptext/jg-textui/client.lua new file mode 100644 index 0000000..bd2d9d6 --- /dev/null +++ b/modules/helptext/jg-textui/client.lua @@ -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 \ No newline at end of file diff --git a/modules/helptext/lab-HintUI/client.lua b/modules/helptext/lab-HintUI/client.lua new file mode 100644 index 0000000..c6e42bc --- /dev/null +++ b/modules/helptext/lab-HintUI/client.lua @@ -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 \ No newline at end of file diff --git a/modules/helptext/okokTextUI/client.lua b/modules/helptext/okokTextUI/client.lua new file mode 100644 index 0000000..f2614d2 --- /dev/null +++ b/modules/helptext/okokTextUI/client.lua @@ -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 \ No newline at end of file diff --git a/modules/helptext/ox_lib/client.lua b/modules/helptext/ox_lib/client.lua new file mode 100644 index 0000000..171fe98 --- /dev/null +++ b/modules/helptext/ox_lib/client.lua @@ -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 \ No newline at end of file diff --git a/modules/housing/_defualts/client.lua b/modules/housing/_default/client.lua similarity index 100% rename from modules/housing/_defualts/client.lua rename to modules/housing/_default/client.lua diff --git a/modules/housing/_defualts/server.lua b/modules/housing/_default/server.lua similarity index 100% rename from modules/housing/_defualts/server.lua rename to modules/housing/_default/server.lua diff --git a/modules/input/_qb-input.lua b/modules/input/_qb-input.lua index 4371b81..375c052 100644 --- a/modules/input/_qb-input.lua +++ b/modules/input/_qb-input.lua @@ -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 \ No newline at end of file +end diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index a195b31..f277fa0 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -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" diff --git a/modules/notify/_default/client.lua b/modules/notify/_default/client.lua index a857aeb..c016d61 100644 --- a/modules/notify/_default/client.lua +++ b/modules/notify/_default/client.lua @@ -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) \ No newline at end of file +---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 \ No newline at end of file diff --git a/modules/notify/_default/server.lua b/modules/notify/_default/server.lua index 9f7cb47..a299eae 100644 --- a/modules/notify/_default/server.lua +++ b/modules/notify/_default/server.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/mythic_notify/client.lua b/modules/notify/mythic_notify/client.lua new file mode 100644 index 0000000..378ce39 --- /dev/null +++ b/modules/notify/mythic_notify/client.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/okokNotify/client.lua b/modules/notify/okokNotify/client.lua new file mode 100644 index 0000000..78c28a5 --- /dev/null +++ b/modules/notify/okokNotify/client.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/ox_lib/client.lua b/modules/notify/ox_lib/client.lua new file mode 100644 index 0000000..fe28910 --- /dev/null +++ b/modules/notify/ox_lib/client.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/pNotify/client.lua b/modules/notify/pNotify/client.lua new file mode 100644 index 0000000..e5ee328 --- /dev/null +++ b/modules/notify/pNotify/client.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/r_notify/client.lua b/modules/notify/r_notify/client.lua new file mode 100644 index 0000000..a3dc5b6 --- /dev/null +++ b/modules/notify/r_notify/client.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/t-notify/client.lua b/modules/notify/t-notify/client.lua new file mode 100644 index 0000000..f11e863 --- /dev/null +++ b/modules/notify/t-notify/client.lua @@ -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 \ No newline at end of file diff --git a/modules/notify/wasabi_notify/client.lua b/modules/notify/wasabi_notify/client.lua new file mode 100644 index 0000000..52998c8 --- /dev/null +++ b/modules/notify/wasabi_notify/client.lua @@ -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 \ No newline at end of file diff --git a/modules/phone/_defualts/client.lua b/modules/phone/_default/client.lua similarity index 71% rename from modules/phone/_defualts/client.lua rename to modules/phone/_default/client.lua index 8b33ca9..3337b0c 100644 --- a/modules/phone/_defualts/client.lua +++ b/modules/phone/_default/client.lua @@ -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 \ No newline at end of file diff --git a/modules/phone/_defualts/server.lua b/modules/phone/_default/server.lua similarity index 69% rename from modules/phone/_defualts/server.lua rename to modules/phone/_default/server.lua index a367380..51b2402 100644 --- a/modules/phone/_defualts/server.lua +++ b/modules/phone/_default/server.lua @@ -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 \ No newline at end of file diff --git a/modules/phone/gksphone/client.lua b/modules/phone/gksphone/client.lua index 45bfa53..7bae1cb 100644 --- a/modules/phone/gksphone/client.lua +++ b/modules/phone/gksphone/client.lua @@ -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 \ No newline at end of file diff --git a/modules/phone/gksphone/server.lua b/modules/phone/gksphone/server.lua index 1796a95..828696b 100644 --- a/modules/phone/gksphone/server.lua +++ b/modules/phone/gksphone/server.lua @@ -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 diff --git a/modules/phone/lb-phone/client.lua b/modules/phone/lb-phone/client.lua index 97e556c..2964856 100644 --- a/modules/phone/lb-phone/client.lua +++ b/modules/phone/lb-phone/client.lua @@ -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 \ No newline at end of file diff --git a/modules/phone/lb-phone/server.lua b/modules/phone/lb-phone/server.lua index c6ddad1..748741f 100644 --- a/modules/phone/lb-phone/server.lua +++ b/modules/phone/lb-phone/server.lua @@ -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 diff --git a/modules/phone/qs-smartphone/client.lua b/modules/phone/qs-smartphone/client.lua index b482589..2f797e6 100644 --- a/modules/phone/qs-smartphone/client.lua +++ b/modules/phone/qs-smartphone/client.lua @@ -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) \ No newline at end of file diff --git a/modules/phone/qs-smartphone/server.lua b/modules/phone/qs-smartphone/server.lua index b5e3f96..167bacc 100644 --- a/modules/phone/qs-smartphone/server.lua +++ b/modules/phone/qs-smartphone/server.lua @@ -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 diff --git a/modules/progressbar/ox_lib/client.lua b/modules/progressbar/ox_lib/client.lua index 99448d7..080e067 100644 --- a/modules/progressbar/ox_lib/client.lua +++ b/modules/progressbar/ox_lib/client.lua @@ -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) diff --git a/modules/progressbar/qb-progressbar/client.lua b/modules/progressbar/qb-progressbar/client.lua index 5540dce..73dd034 100644 --- a/modules/progressbar/qb-progressbar/client.lua +++ b/modules/progressbar/qb-progressbar/client.lua @@ -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 diff --git a/modules/skills/OT_skills/client.lua b/modules/skills/OT_skills/client.lua new file mode 100644 index 0000000..cac7757 --- /dev/null +++ b/modules/skills/OT_skills/client.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/OT_skills/server.lua b/modules/skills/OT_skills/server.lua new file mode 100644 index 0000000..c5be3f1 --- /dev/null +++ b/modules/skills/OT_skills/server.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/_default/client.lua b/modules/skills/_default/client.lua new file mode 100644 index 0000000..9b26b0a --- /dev/null +++ b/modules/skills/_default/client.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/_default/server.lua b/modules/skills/_default/server.lua new file mode 100644 index 0000000..a5ae846 --- /dev/null +++ b/modules/skills/_default/server.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/evolent_skills/client.lua b/modules/skills/evolent_skills/client.lua new file mode 100644 index 0000000..7ee1e0f --- /dev/null +++ b/modules/skills/evolent_skills/client.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/evolent_skills/server.lua b/modules/skills/evolent_skills/server.lua new file mode 100644 index 0000000..05f960a --- /dev/null +++ b/modules/skills/evolent_skills/server.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/pickle_xp/client.lua b/modules/skills/pickle_xp/client.lua new file mode 100644 index 0000000..c21f010 --- /dev/null +++ b/modules/skills/pickle_xp/client.lua @@ -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 \ No newline at end of file diff --git a/modules/skills/pickle_xp/server.lua b/modules/skills/pickle_xp/server.lua new file mode 100644 index 0000000..b7234f3 --- /dev/null +++ b/modules/skills/pickle_xp/server.lua @@ -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 \ No newline at end of file diff --git a/modules/target/_defualt/client.lua b/modules/target/_default/client.lua similarity index 100% rename from modules/target/_defualt/client.lua rename to modules/target/_default/client.lua diff --git a/modules/target/ox_target/client.lua b/modules/target/ox_target/client.lua index 10b7026..fb06fd0 100644 --- a/modules/target/ox_target/client.lua +++ b/modules/target/ox_target/client.lua @@ -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 diff --git a/modules/target/qb-target/client.lua b/modules/target/qb-target/client.lua index 00cc6ee..dccdb64 100644 --- a/modules/target/qb-target/client.lua +++ b/modules/target/qb-target/client.lua @@ -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 diff --git a/modules/target/sleepless_interact/client.lua b/modules/target/sleepless_interact/client.lua index 9ae72a3..c3cc9f0 100644 --- a/modules/target/sleepless_interact/client.lua +++ b/modules/target/sleepless_interact/client.lua @@ -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 diff --git a/settings/clientConfig.lua b/settings/clientConfig.lua index f89f5a4..9fb6add 100644 --- a/settings/clientConfig.lua +++ b/settings/clientConfig.lua @@ -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 diff --git a/settings/serverConfig.lua b/settings/serverConfig.lua index abfdd4d..69ac8e9 100644 --- a/settings/serverConfig.lua +++ b/settings/serverConfig.lua @@ -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 diff --git a/settings/sharedConfig.lua b/settings/sharedConfig.lua index 7fe6461..d0a3c06 100644 --- a/settings/sharedConfig.lua +++ b/settings/sharedConfig.lua @@ -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 \ No newline at end of file diff --git a/unit_tests/cache_test.lua b/unit_tests/cache_test.lua new file mode 100644 index 0000000..c144bca --- /dev/null +++ b/unit_tests/cache_test.lua @@ -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) \ No newline at end of file