From 48f8122197de48cd7cc17d3b4ef2b910b59125ee Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 23 Dec 2025 19:27:27 -0500 Subject: [PATCH] Remove cache and batch event libraries, update locales Deleted the cache and batch event libraries from the codebase, including all related client, server, and shared files. Removed server-side particle library and associated client event handlers. Updated utility and clothing modules to remove cache dependencies. Improved utility logging and deprecated point functions with notices. Updated all locales to use a consistent 'PurchasedItem' message format and added Bulgarian (bg) translation. Bumped version to 0.13.1 in fxmanifest. --- fxmanifest.lua | 2 +- lib/batch/shared/events.lua | 65 ----- lib/cache/client/cache.lua | 43 --- lib/cache/server/cache.lua | 0 lib/cache/shared/cache.lua | 276 ------------------- lib/init.lua | 3 - lib/particles/client/particles.lua | 26 -- lib/particles/server/particles.lua | 72 ----- lib/utility/client/utility.lua | 16 +- locales/af.json | 2 +- locales/ar.json | 2 +- locales/bg.json | 49 ++++ locales/cs.json | 2 +- locales/da.json | 2 +- locales/de.json | 2 +- locales/el.json | 2 +- locales/en-pirate.json | 2 +- locales/en.json | 2 +- locales/es.json | 2 +- locales/fi.json | 2 +- locales/fr.json | 2 +- locales/hi.json | 2 +- locales/hr.json | 2 +- locales/hu.json | 2 +- locales/it.json | 2 +- locales/ja.json | 2 +- locales/ko.json | 2 +- locales/lt.json | 2 +- locales/nl.json | 2 +- locales/no.json | 2 +- locales/pl.json | 2 +- locales/pt.json | 2 +- locales/ro.json | 2 +- locales/ru.json | 2 +- locales/sv.json | 2 +- locales/th.json | 2 +- locales/tr.json | 2 +- locales/zh-cn.json | 2 +- locales/zh-hk.json | 2 +- locales/zh-tw.json | 2 +- locales/zh.json | 2 +- modules/clothing/_default/client.lua | 122 ++------ modules/clothing/_default/server.lua | 50 ++-- modules/clothing/esx_skin/server.lua | 15 +- modules/dialogue/_default/client/client.lua | 20 +- modules/framework/es_extended/client.lua | 4 +- modules/framework/es_extended/server.lua | 2 +- modules/framework/qb-core/client.lua | 2 +- modules/framework/qb-core/server.lua | 2 +- modules/framework/qbx_core/client.lua | 2 +- modules/framework/qbx_core/server.lua | 2 +- modules/notify/_default/client.lua | 5 +- modules/notify/_default/server.lua | 6 +- modules/notify/brutal_notify/client.lua | 11 +- modules/notify/fl-notify/client.lua | 21 +- modules/notify/lation_ui/client.lua | 12 +- modules/notify/mythic_notify/client.lua | 13 +- modules/notify/okokNotify/client.lua | 12 +- modules/notify/ox_lib/client.lua | 12 +- modules/notify/pNotify/client.lua | 12 +- modules/notify/r_notify/client.lua | 11 +- modules/notify/t-notify/client.lua | 12 +- modules/notify/wasabi_notify/client.lua | 12 +- modules/shops/_default/server.lua | 12 +- modules/skills/_default/client.lua | 51 ++-- modules/skills/_default/server.lua | 100 ++++--- modules/skills/evolent_skills/client.lua | 2 +- modules/skills/evolent_skills/server.lua | 8 +- modules/skills/ot_skills/client.lua | 4 +- modules/skills/ot_skills/server.lua | 8 +- modules/skills/pickle_xp/client.lua | 4 +- modules/skills/pickle_xp/server.lua | 18 +- modules/target/_default/client.lua | 39 +-- modules/target/ox_target/client.lua | 37 ++- modules/target/qb-target/client.lua | 56 ++-- modules/target/sleepless_interact/client.lua | 50 ++-- 76 files changed, 488 insertions(+), 875 deletions(-) delete mode 100644 lib/batch/shared/events.lua delete mode 100644 lib/cache/client/cache.lua delete mode 100644 lib/cache/server/cache.lua delete mode 100644 lib/cache/shared/cache.lua delete mode 100644 lib/particles/server/particles.lua create mode 100644 locales/bg.json diff --git a/fxmanifest.lua b/fxmanifest.lua index 3780ee8..974c23c 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -5,7 +5,7 @@ use_experimental_fxv2_oal 'yes' author 'The Order of the Sacred Framework' name 'community_bridge' description 'A Universal Bridge for Our Community, created by a group of contributors with a shared vision to enhance both user and developer experiences. This bridge connects various frameworks, inventories, target systems, notification systems, and more, fostering compatibility and seamless integration.' -version '0.13.0' +version '0.13.1' shared_scripts { '@ox_lib/init.lua', diff --git a/lib/batch/shared/events.lua b/lib/batch/shared/events.lua deleted file mode 100644 index f88fb86..0000000 --- a/lib/batch/shared/events.lua +++ /dev/null @@ -1,65 +0,0 @@ -Batch = Batch or {} -Batch.Event = Batch.Event or {} -Batch.Event.Queued = Batch.Event.Queued or {} -Batch.Event.IsQueued = Batch.Event.IsQueued or false - -local SERVER = IsDuplicityVersion() - --- could do a callback from client to server back to client with a time stamp. Use that timestamp to generate some random string/number and use that fo --- this event name. Would help by masking from exploits. Thinking about making a module out of it - ---- This is used to batch single events together to reduce network strain ---- -if SERVER then - function Batch.Event.Queue(src, event, ...) - if src == -1 then - src = GetPlayers() - for k, v in pairs(src) do - local strSrc = tostring(v) - Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {} - table.insert(Batch.Event.Queued[strSrc], { - src = v, - event = event, - args = {...} - }) - end - else - local strSrc = tostring(src) - Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {} - table.insert(Batch.Event.Queued[strSrc], { - src = src, - event = event, - args = {...} - }) - end - - if Batch.Event.IsQueued then return end - Batch.Event.IsQueued = true - SetTimeout(100, function() - for k, v in pairs(Batch.Event.Queued) do - TriggerClientEvent('community_bridge:client:BatchEvents', v.src, v) - end - Batch.Event.IsQueued = false - Batch.Event.Queued = {} - end) - end - return Batch -else - - Batch.Event.Fire = function(array) - local playerSrc = PlayerId() - for k, v in pairs(array) do - if v.src == playerSrc then - local event = v.event - local args = v.args - TriggerEvent(event, table.unpack(args)) - end - end - end - - RegisterNetEvent('community_bridge:client:BatchEvents', function(array) - Batch.Event.Fire(array) - end) - - return Batch -end \ No newline at end of file diff --git a/lib/cache/client/cache.lua b/lib/cache/client/cache.lua deleted file mode 100644 index 44a0235..0000000 --- a/lib/cache/client/cache.lua +++ /dev/null @@ -1,43 +0,0 @@ -Cache = Require("lib/cache/shared/cache.lua") -local PlayerPedId = PlayerPedId -local GetVehiclePedIsIn = GetVehiclePedIsIn -local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers -local GetPedInVehicleSeat = GetPedInVehicleSeat -local GetSelectedPedWeapon = GetSelectedPedWeapon - ---- Get the vehicle the player is in, if any ----@return integer | nil -function GetVehicle() - local ped = PlayerPedId() - if not ped then return end - return GetVehiclePedIsIn(ped, false) -end - ---- Get the seat of the player in the vehicle if the vehicle is occupied ----@return integer | nil -function GetVehicleSeat() - local vehicle = GetVehicle() - if not vehicle then return end - local ped = PlayerPedId() - if not ped then return end - for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do - if ped == GetPedInVehicleSeat(vehicle, i) then - return i - end - end -end - ---- Get the current weapon of the player ---- @return integer | nil -function GetWeapon() - local ped = PlayerPedId() - if not ped then return end -- Return unarmed hash if no ped - return GetSelectedPedWeapon(ped) -end - -Cache.Create("Ped", PlayerPedId, 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 - -return Cache diff --git a/lib/cache/server/cache.lua b/lib/cache/server/cache.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lib/cache/shared/cache.lua b/lib/cache/shared/cache.lua deleted file mode 100644 index 3fd9abd..0000000 --- a/lib/cache/shared/cache.lua +++ /dev/null @@ -1,276 +0,0 @@ ----@class CacheEntry ----@field Name string ----@field Compare fun(): any ----@field WaitTime integer | nil ----@field LastChecked integer|nil ----@field OnChange fun(new:any, old:any)[] ----@field Value any - ----@class CacheModule ----@field Caches table ----@field LoopRunning boolean ----@field Create fun(name:string, compare:fun():any, waitTime:integer | nil): CacheEntry ----@field Get fun(name:string): any ----@field OnChange fun(name:string, onChange:fun(new:any, old:any)) ----@field Remove fun(name:string) -Cache = Cache or {} ---@type CacheModule -- <-- we use Cache as a global variable so that if we dont required it more than once - -Table = Table or Require('lib/utility/shared/tables.lua') -Id = Id or Require('lib/utility/shared/ids.lua') - -local Config = Require("settings/sharedConfig.lua") -local max = 5000 -local CreateThread = CreateThread -local Wait = Wait -local GetGameTimer = GetGameTimer - -local resourceCallbacks = {} -- Add callbacks from resources -local resourceTracker = { - caches = {}, - callbacks = {}, - initialized = {} -} - -Cache.Caches = Cache.Caches or {} -Cache.LoopRunning = Cache.LoopRunning or false - ----@param ... any -local function debugPrint(...) - if Config.DebugLevel == 0 then return end - print("^2[Cache]^0", ...) -end - -local function HasActiveCaches() - for _, cache in pairs(Cache.Caches) do - if cache.WaitTime ~= nil then - return true - end - end - return false -end - -local function processCacheEntry(now, cache) - cache.LastChecked = cache.LastChecked or now - cache.WaitTime = tonumber(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 not Table.Compare(cache.Value, oldValue) and cache.OnChange then - for i, onChange in pairs(cache.OnChange) do - onChange(cache.Value, oldValue) - end - end - cache.LastChecked = now - remaining = cache.WaitTime - end - - return remaining -end - -local function getNextWait(now) - local minWait = nil - for name, cache in pairs(Cache.Caches) do - if cache.Compare and cache.WaitTime ~= nil then - local remaining = processCacheEntry(now, cache) - if not minWait or remaining < minWait then - minWait = remaining - if minWait <= 0 then break end - end - end - end - return minWait -end - -local function StartLoop() - if Cache.LoopRunning then return end - if not HasActiveCaches() then return end - Cache.LoopRunning = true - CreateThread(function() - while Cache.LoopRunning do - local now = GetGameTimer() - local minWait = getNextWait(now) - if minWait then - Wait(math.max(0, minWait)) - else - Wait(max) - end - if not HasActiveCaches() then - Cache.LoopRunning = false - end - end - end) -end - -local function trackResource(resourceName, type, data) - if not resourceName then return end - - -- Initialize resource tracking if needed - if not resourceTracker.initialized[resourceName] then - resourceTracker.initialized[resourceName] = true - resourceTracker.caches[resourceName] = resourceTracker.caches[resourceName] or {} - resourceTracker.callbacks[resourceName] = resourceTracker.callbacks[resourceName] or {} - - AddEventHandler('onResourceStop', function(stoppingResource) - if stoppingResource ~= resourceName then return end - - -- Clean up caches - for _, cacheName in ipairs(resourceTracker.caches[resourceName] or {}) do - if Cache.Caches[cacheName] then - Cache.Caches[cacheName] = nil - debugPrint(("Removed cache '%s' - resource '%s' stopped"):format(cacheName, resourceName)) - end - end - - -- Clean up callbacks - for _, cb in ipairs(resourceTracker.callbacks[resourceName] or {}) do - local targetCache = Cache.Caches[cb.cacheName] - if targetCache then - targetCache.OnChange[cb.index] = nil - debugPrint(("Removed callback '%s' from cache '%s' - resource '%s' stopped"):format(cb.index, cb.cacheName, resourceName)) - end - end - - -- Clear tracking data - resourceTracker.caches[resourceName] = nil - resourceTracker.callbacks[resourceName] = nil - resourceTracker.initialized[resourceName] = nil - end) - end - - -- Track the new item - if type == "cache" then - table.insert(resourceTracker.caches[resourceName], data) - elseif type == "callback" then - table.insert(resourceTracker.callbacks[resourceName], data) - end -end - ----@param name string ----@param compare fun():any ----@param waitTime integer | nil ----@return CacheEntry | nil -function Cache.Create(name, compare, waitTime) - assert(name, "Cache name is required.") - assert(compare, "Comparison function is required.") - if type(waitTime) ~= "number" then - waitTime = nil - end - local _name = tostring(name) - local cache = Cache.Caches[_name] - if cache and cache.Compare == compare then - debugPrint(_name .. " already exists with the same comparison function.") - return cache - end - local ok, result = pcall(compare) - if not ok then - debugPrint("Error creating cache '" .. _name .. "': " .. tostring(result)) - return nil - end - ---@type CacheEntry - local newCache = { - Name = _name, - Compare = compare, - WaitTime = waitTime, -- can be nil - LastChecked = nil, - OnChange = {}, - Value = result - } - - -- Track the cache with its resource - trackResource(GetInvokingResource(), "cache", _name) - - Cache.Caches[_name] = newCache - - debugPrint(_name .. " created with initial value: " .. tostring(result)) - for _, onChange in pairs(newCache.OnChange) do - onChange(newCache.Value, 0) - end - StartLoop() - return newCache -end - ----@param name string ----@return any -function Cache.Get(name) - assert(name, "Cache name is required.") - local _name = tostring(name) - local cache = Cache.Caches[_name] - return cache and cache.Value or nil -end - ---- This add a callback to the cache entry that will be called when the value changes. ---- The callback will be called with the new value and the old value. ---- you can call the value again to delete the callback. ----@param name string ----@param onChange fun(new:any, old:any) -function Cache.OnChange(name, onChange) - assert(name, "Cache name is required.") - local _name = tostring(name) - local cache = Cache.Caches[_name] - assert(cache, "Cache with name '" .. _name .. "' does not exist.") - - local id = Id.CreateUniqueId(Cache.Caches[_name]?.OnChange) - -- Figure out which resource is trying to register this callback - local invokingResource = GetInvokingResource() - if not invokingResource then return end - -- Add the new callback to our list - local callbackIndex = id - cache.OnChange[callbackIndex] = onChange - - -- Track the callback with its resource - trackResource(GetInvokingResource(), "callback", { - cacheName = _name, - index = callbackIndex - }) - - debugPrint(("Added new OnChange callback to cache '%s' from resource '%s'"):format(_name, invokingResource)) - return callbackIndex -end - -function Cache.RemoveOnChange(name, id) - assert(name, "Cache name is required.") - local _name = tostring(name) - local cache = Cache.Caches[_name] - assert(cache, "Cache with name '" .. _name .. "' does not exist.") - if cache.OnChange[id] then - cache.OnChange[id] = nil - debugPrint("Removed OnChange callback from cache '" .. _name .. "' with ID: " .. id) - else - debugPrint("No OnChange callback found with ID: " .. id .. " in cache '" .. _name .. "'") - end -end - ----@param name string -function Cache.Remove(name) - assert(name, "Cache name is required.") - local _name = tostring(name) - local cache = Cache.Caches[_name] - if cache then - Cache.Caches[_name] = nil - debugPrint(_name .. " removed from cache.") - if next(Cache.Caches) == nil then - Cache.LoopRunning = false - end - end -end - ----@param name string ----@param newValue any -function Cache.Update(name, newValue) - assert(name, "Cache name is required.") - local _name = tostring(name) - local cache = Cache.Caches[_name] - assert(cache, "Cache with name '" .. _name .. "' does not exist.") - local oldValue = cache.Value - if oldValue ~= newValue then - cache.Value = newValue - for _, onChange in pairs(cache.OnChange) do - onChange(newValue, oldValue) - end - end -end - -return Cache \ No newline at end of file diff --git a/lib/init.lua b/lib/init.lua index e728054..2ce2d3d 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -50,9 +50,7 @@ if not IsDuplicityVersion() then goto client end cLib.SQL = SQL or Require("lib/sql/server/sqlHandler.lua") cLib.Logs = Logs or Require("lib/logs/server/logs.lua") -cLib.Cache = Cache or Require("lib/cache/shared/cache.lua") cLib.Marker = Marker or Require("lib/markers/server/server.lua") -cLib.Particle = Particle or Require("lib/particles/server/particles.lua") cLib.Shell = Shells or Require("lib/shells/server/shells.lua") cLib.Entity = ServerEntity or Require("lib/entities/server/server_entity.lua") @@ -69,7 +67,6 @@ cLib.PlaceableObject = ObjectPlacer or Require("lib/placers/client/placeable_obj 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.Cache = Cache or Require("lib/cache/client/cache.lua") cLib.Marker = Marker or Require("lib/markers/client/markers.lua") cLib.Anim = Anim or Require("lib/anim/client/client.lua") cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua") diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index 230415a..d113810 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -92,32 +92,6 @@ function Particle.Stop(particle) Particles[tostring(particle)] = nil end -RegisterNetEvent("community_bridge:Client:Particle", function(data) - if not data then return end - Particle.Create(data) -end) - -RegisterNetEvent("community_bridge:Client:ParticleBulk", function(datas) - if not datas then return end - for _, data in pairs(datas) do - Particle.Create(data) - end -end) - -RegisterNetEvent("community_bridge:Client:ParticleRemove", function(id) - local particle = Particles[id] - if not particle then return end - Particle.Stop(id) -end) - -RegisterNetEvent("community_bridge:Client:ParticleRemoveBulk", function(ids) - for _, id in pairs(ids) do - Particle.Stop(id) - end -end) - - - function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength) LoadPtfxAsset(dict) UseParticleFxAssetNextCall(dict) diff --git a/lib/particles/server/particles.lua b/lib/particles/server/particles.lua deleted file mode 100644 index 71fa9ce..0000000 --- a/lib/particles/server/particles.lua +++ /dev/null @@ -1,72 +0,0 @@ ----@diagnostic disable: duplicate-set-field - -Particles = {} -Particle = Particles or {} - -function Particle.New(data) - assert(data, "Particle data is nil") - assert(data.dict, "Invalid particle data. Must contain string dict.") - assert(data.ptfx, "Invalid particle data. Must contain string ptfx.") - - local _id = data.id or Bridge.Ids.CreateUniqueId(Particles) - data = { - id = _id, - dict = data.dict, - ptfx = data.ptfx, - position = data.position or vector3(0.0, 0.0, 0.0), - rotation = data.rotation or vector3(0, 0, 0), - size = data.size or 1.0, - color = data.color or vector3(255, 255, 255), - looped = data.looped or false, - loopLength = data.loopLength or nil, - } - Particles[_id] = data - return data -end - -function Particle.Destroy(id) - if not id or not Particles[id] then return end - Particles[id] = nil - return true -end - -function Particle.Create(data) - local particleData = Particle.New(data) - if not particleData then return end - TriggerClientEvent("community_bridge:Client:Particle", -1, particleData) - return -end - - -function Particle.Remove(id) - if not Particle.Destroy(id) then return end - TriggerClientEvent("community_bridge:Client:ParticleRemove", -1, id) -end - -function Particle.CreateBulk(datas) - if not datas then return end - local toClient = {} - for k, v in pairs(datas) do - local data = Particle.New(v) - table.insert(toClient, data) - end - TriggerClientEvent("community_bridge:Client:ParticleBulk", -1, toClient) - return toClient -end - -function Particle.RemoveBulk(ids) - if not ids then return end - local toClient = {} - for k, v in pairs(ids) do - local id = v - if type(v) == "table" then - id = v.id - end - Particle.Destroy(id) - table.insert(toClient, id) - end - TriggerClientEvent("community_bridge:Client:ParticleRemoveBulk", -1, toClient) - return ids -end - -return Particle \ No newline at end of file diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index d8432de..f20efcf 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -40,7 +40,7 @@ end ---@return number|nil function Utility.CreateProp(model, coords, heading, networked) local loaded, hash = ensureModelLoaded(model) - if not loaded then return nil, print("^6 Model was unable to load "..tostring(model).." ^0") end + if not loaded then return nil, print("^6 community_bridge model was unable to load "..tostring(model).." ^0") end local propEntity = CreateObject(hash, coords.x, coords.y, coords.z, networked, false, false) SetEntityHeading(propEntity, heading) SetModelAsNoLongerNeeded(hash) @@ -64,7 +64,7 @@ end ---@return number|nil, table function Utility.CreateVehicle(model, coords, heading, networked) local loaded, hash = ensureModelLoaded(model) - if not loaded then return nil, {}, print("^6 Model was unable to load "..tostring(model).." ^0") end + if not loaded then return nil, {}, print("^6 community_bridge model was unable to load "..tostring(model).." ^0") end local vehicle = CreateVehicle(hash, coords.x, coords.y, coords.z, heading, networked, false) SetVehicleHasBeenOwnedByPlayer(vehicle, true) SetVehicleNeedsToBeHotwired(vehicle, false) @@ -82,7 +82,7 @@ end ---@return number|nil function Utility.CreatePed(model, coords, heading, networked, settings) local loaded, hash = ensureModelLoaded(model) - if not loaded then return nil, print("^6 Model was unable to load "..tostring(model).." ^0") end + if not loaded then return nil, print("^6 community_bridge model was unable to load "..tostring(model).." ^0") end local spawnedEntity = CreatePed(0, hash, coords.x, coords.y, coords.z, heading, networked, false) SetModelAsNoLongerNeeded(hash) spawnedPeds[tostring(spawnedEntity)] = true @@ -174,7 +174,7 @@ end ---@param blip number ---@return boolean function Utility.RemoveBlip(blip) - if not blipIDs[tostring(blip)] then return false, print("^6 No blip to remove with matching ID ^0") end + if not blipIDs[tostring(blip)] then return false end RemoveBlip(blipIDs[tostring(blip)]) blipIDs[tostring(blip)] = nil return true @@ -298,8 +298,6 @@ function Utility.HelpText(text, duration) EndTextCommandDisplayHelp(0, false, true, duration or 5000) end -local doingstuff = false - ---Show a floating help text in the world ---@param text string The text to show ---@param coords table The coords to show the message at @@ -452,20 +450,24 @@ function Utility.GetClosestVehicle(coords, distanceScope, includePlayerVeh) return vehicleEntity, vehicleCoords, vehicleNetID end --- Deprecated point functions (no changes) +-- Deprecated point functions (no changes) 12/14/25 function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit) + print("^6 community_bridge ^: ^3Utility.RegisterPoint is deprecated. Please use Point.Register instead. ^0") return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit) end function Utility.GetPointById(pointID) + print("^6 community_bridge ^: ^3Utility.GetPointById is deprecated. Please use Point.Get instead. ^0") return Point.Get(pointID) end function Utility.GetActivePoints() + print("^6 community_bridge ^: ^3Utility.GetActivePoints is deprecated. Please use Point.GetAll instead. ^0") return Point.GetAll() end function Utility.RemovePoint(pointID) + print("^6 community_bridge ^: ^3Utility.RemovePoint is deprecated. Please use Point.Remove instead. ^0") return Point.Remove(pointID) end diff --git a/locales/af.json b/locales/af.json index a383475..ca66b15 100644 --- a/locales/af.json +++ b/locales/af.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Jy het nie genoeg geld om hierdie item te koop nie", "Input": "Hoeveelheid Invoer", "PurchaseAmount": "Aankoop Hoeveelheid", - "PurchasedItem": "Jy het gekoop ", + "PurchasedItem": "Jy het gekoop %s %s", "PurchaseFailed": "Aankoop het misluk, inventaris vol", "CurrencySymbol": "$ %s", "Confirm": "Bevestig Aankoop", diff --git a/locales/ar.json b/locales/ar.json index 37f74a2..173b8bb 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "ليس لديك ما يكفي من المال لشراء هذا العنصر", "Input": "إدخال الكمية", "PurchaseAmount": "كمية الشراء", - "PurchasedItem": "لقد قمت بشراء ", + "PurchasedItem": "لقد قمت بشراء %s %s", "PurchaseFailed": "فشل الشراء، المخزون ممتلئ", "CurrencySymbol": "$ %s", "Confirm": "تأكيد الشراء", diff --git a/locales/bg.json b/locales/bg.json new file mode 100644 index 0000000..b75f9a3 --- /dev/null +++ b/locales/bg.json @@ -0,0 +1,49 @@ +{ + "Shops": { + "NotEnoughMoney": "Нямате достатъчно пари, за да купите този артикул", + "Input": "Въвеждане на количество", + "PurchaseAmount": "Количество за покупка", + "PurchasedItem": "Закупихте %s %s", + "PurchaseFailed": "Покупката е неуспешна, инвентарът е пълен", + "CurrencySymbol": "%s лв.", + "Confirm": "Потвърдете покупката", + "AreYouSure": "Сигурни ли сте, че искате да закупите %s", + "PayByCash": "Плащане на %s в брой", + "PayByCard": "Плащане на %s с карта", + "CardIcon": "fa-solid fa-building-columns", + "CashIcon": "fa-solid fa-money-bill-wave", + "ShopIcon": "fa-solid fa-basket-shopping", + "ShopName": "Име на магазина" + }, + "Notifications": { + "PlaceholderTitle": "Известие" + }, + "clipboard": { + "copy": "Копирано в клипборда" + }, + "input": { + "submit_text": "Изпрати" + }, + "placeable_object": { + "no_prop_defined": "Не сте дефинирали обект за поставяне", + "cant_place_here": "Не можете да поставите този обект тук", + "place_object_place": "[E] Поставяне \n", + "place_object_cancel": "[X] Отказ \n", + "place_object_scroll_up": "[Превъртане нагоре] Завъртане надясно \n", + "place_object_scroll_down": "[Превъртане надолу] Завъртане наляво \n", + "object_place": "[%s] Поставяне \n", + "object_cancel": "[%s] Отказ \n", + "object_scroll_up": "[%s] Завъртане надясно \n", + "object_scroll_down": "[%s] Завъртане наляво \n", + "rotate_left": "Завъртане наляво", + "rotate_right": "Завъртане надясно", + "rotate_clockwise": "[%s] Завъртане по часовниковата стрелка \n", + "rotate_counter_clockwise": "[%s] Завъртане обратно на часовниковата стрелка \n", + "depth_modifier": "[%s] Модификатор на дълбочината \n" + }, + "target": { + "interact": "[E] Взаимодействие", + "title": "Опции", + "description": "Няма описание" + } +} diff --git a/locales/cs.json b/locales/cs.json index 0bd49f9..16792f5 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Nemáte dostatek peněz na koupi této položky", "Input": "Zadání množství", "PurchaseAmount": "Množství nákupu", - "PurchasedItem": "Zakoupili jste ", + "PurchasedItem": "Zakoupili jste %s %s", "PurchaseFailed": "Nákup se nezdařil, inventář je plný", "CurrencySymbol": "$ %s", "Confirm": "Potvrdit nákup", diff --git a/locales/da.json b/locales/da.json index e6bbdbe..fd96cc8 100644 --- a/locales/da.json +++ b/locales/da.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Du har ikke nok penge til at købe denne vare", "Input": "Mængde input", "PurchaseAmount": "Købs mængde", - "PurchasedItem": "Du har købt ", + "PurchasedItem": "Du har købt %s %s", "PurchaseFailed": "Køb mislykkedes, inventar fuldt", "CurrencySymbol": "$ %s", "Confirm": "Bekræft køb", diff --git a/locales/de.json b/locales/de.json index 8a0f52d..968aee2 100644 --- a/locales/de.json +++ b/locales/de.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Sie haben nicht genug Geld, um diesen Artikel zu kaufen", "Input": "Mengen-Eingabe", "PurchaseAmount": "Kaufmenge", - "PurchasedItem": "Sie haben gekauft ", + "PurchasedItem": "Sie haben gekauft %s %s", "PurchaseFailed": "Kauf fehlgeschlagen, Inventar voll", "CurrencySymbol": "$ %s", "Confirm": "Kauf bestätigen", diff --git a/locales/el.json b/locales/el.json index f70f981..9d93cf1 100644 --- a/locales/el.json +++ b/locales/el.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Δεν έχετε αρκετά χρήματα για να αγοράσετε αυτό το αντικείμενο", "Input": "Εισαγωγή ποσότητας", "PurchaseAmount": "Ποσότητα αγοράς", - "PurchasedItem": "Αγοράσατε ", + "PurchasedItem": "Αγοράσατε %s %s", "PurchaseFailed": "Η αγορά απέτυχε, το αποθέμα είναι γεμάτο", "CurrencySymbol": "$ %s", "Confirm": "Επιβεβαίωση αγοράς", diff --git a/locales/en-pirate.json b/locales/en-pirate.json index ca2da43..1a8f874 100644 --- a/locales/en-pirate.json +++ b/locales/en-pirate.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Ye don't have enough booty to plunder this here item", "Input": "Amount o' Booty", "PurchaseAmount": "Plunder Quantity", - "PurchasedItem": "Ye Have Plundered ", + "PurchasedItem": "Ye Have Plundered %s %s", "PurchaseFailed": "Plunder failed, yer hold be full", "CurrencySymbol": "$ %s", "Confirm": "Aye, Plunder!", diff --git a/locales/en.json b/locales/en.json index bf4e35f..dd95130 100644 --- a/locales/en.json +++ b/locales/en.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "You don't have enough money to buy this item", "Input": "Amount Input", "PurchaseAmount": "Purchase Quantity", - "PurchasedItem": "You Have Purchased ", + "PurchasedItem": "You Have Purchased %s %s", "PurchaseFailed": "Purchase failed, inventory full", "CurrencySymbol": "$ %s", "Confirm": "Confirm Purchase", diff --git a/locales/es.json b/locales/es.json index 5c039a8..d9ab125 100644 --- a/locales/es.json +++ b/locales/es.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "No tienes suficiente dinero para comprar este artículo", "Input": "Entrada de cantidad", "PurchaseAmount": "Cantidad de compra", - "PurchasedItem": "Has comprado ", + "PurchasedItem": "Has comprado %s %s", "PurchaseFailed": "Compra fallida, inventario lleno", "CurrencySymbol": "$ %s", "Confirm": "Confirmar compra", diff --git a/locales/fi.json b/locales/fi.json index 7da2ca9..0a59126 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Sinulla ei ole tarpeeksi rahaa ostaaksesi tätä tuotetta", "Input": "Määrän syöttö", "PurchaseAmount": "Ostomäärä", - "PurchasedItem": "Olet ostanut ", + "PurchasedItem": "Olet ostanut %s %s", "PurchaseFailed": "Osto epäonnistui, varasto täynnä", "CurrencySymbol": "$ %s", "Confirm": "Vahvista osto", diff --git a/locales/fr.json b/locales/fr.json index ee8f64f..4a58588 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Vous n'avez pas assez d'argent pour acheter cet article", "Input": "Saisie de quantité", "PurchaseAmount": "Quantité d'achat", - "PurchasedItem": "Vous avez acheté ", + "PurchasedItem": "Vous avez acheté %s %s", "PurchaseFailed": "Achat échoué, inventaire plein", "CurrencySymbol": "$ %s", "Confirm": "Confirmer l'achat", diff --git a/locales/hi.json b/locales/hi.json index a4d41e5..864e7d3 100644 --- a/locales/hi.json +++ b/locales/hi.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "इस वस्तु को खरीदने के लिए आपके पास पर्याप्त पैसे नहीं हैं", "Input": "मात्रा इनपुट", "PurchaseAmount": "खरीदारी की मात्रा", - "PurchasedItem": "आपने खरीदा है ", + "PurchasedItem": "आपने खरीदा है %s %s", "PurchaseFailed": "खरीदारी विफल, इन्वेंटरी भरी हुई है", "CurrencySymbol": "$ %s", "Confirm": "खरीदारी की पुष्टि करें", diff --git a/locales/hr.json b/locales/hr.json index bb807c7..71bd72d 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Nemate dovoljno novca za kupnju ovog predmeta", "Input": "Unos količine", "PurchaseAmount": "Količina kupnje", - "PurchasedItem": "Kupili ste ", + "PurchasedItem": "Kupili ste %s %s", "PurchaseFailed": "Kupnja nije uspjela, inventar pun", "CurrencySymbol": "%s kn", "Confirm": "Potvrdi kupnju", diff --git a/locales/hu.json b/locales/hu.json index 3714c46..8574439 100644 --- a/locales/hu.json +++ b/locales/hu.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Nincs elég pénzed ennek a tételnek a megvásárlásához", "Input": "Mennyiség bevitel", "PurchaseAmount": "Vásárlási mennyiség", - "PurchasedItem": "Megvásároltad ", + "PurchasedItem": "Megvásároltad %s %s", "PurchaseFailed": "Vásárlás sikertelen, leltár tele", "CurrencySymbol": "$ %s", "Confirm": "Vásárlás megerősítése", diff --git a/locales/it.json b/locales/it.json index 44d026e..c0cc9f3 100644 --- a/locales/it.json +++ b/locales/it.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Non hai abbastanza denaro per comprare questo articolo", "Input": "Inserimento quantità", "PurchaseAmount": "Quantità di acquisto", - "PurchasedItem": "Hai acquistato ", + "PurchasedItem": "Hai acquistato %s %s", "PurchaseFailed": "Acquisto fallito, inventario pieno", "CurrencySymbol": "$ %s", "Confirm": "Conferma acquisto", diff --git a/locales/ja.json b/locales/ja.json index 5d74d85..4467456 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "このアイテムを購入するのに十分なお金がありません", "Input": "数量入力", "PurchaseAmount": "購入数量", - "PurchasedItem": "購入しました ", + "PurchasedItem": "購入しました %s %s", "PurchaseFailed": "購入に失敗しました、インベントリがいっぱいです", "CurrencySymbol": "$ %s", "Confirm": "購入を確認", diff --git a/locales/ko.json b/locales/ko.json index ca8240b..4fa6de8 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "이 아이템을 구매할 돈이 부족합니다", "Input": "수량 입력", "PurchaseAmount": "구매 수량", - "PurchasedItem": "구매했습니다 ", + "PurchasedItem": "구매했습니다 %s %s", "PurchaseFailed": "구매 실패, 인벤토리가 가득 찼습니다", "CurrencySymbol": "$ %s", "Confirm": "구매 확인", diff --git a/locales/lt.json b/locales/lt.json index dbd9ee9..454d9a9 100644 --- a/locales/lt.json +++ b/locales/lt.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Neturite pakankamai pinigų šiam daiktui nusipirkti", "Input": "Kiekio įvestis", "PurchaseAmount": "Pirkimo kiekis", - "PurchasedItem": "Jūs nusipirkote ", + "PurchasedItem": "Jūs nusipirkote %s %s", "PurchaseFailed": "Pirkimas nepavyko, inventorius pilnas", "CurrencySymbol": "%s €", "Confirm": "Patvirtinti pirkimą", diff --git a/locales/nl.json b/locales/nl.json index fa38717..711946a 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Je hebt niet genoeg geld om dit item te kopen", "Input": "Hoeveelheid invoer", "PurchaseAmount": "Aankoop hoeveelheid", - "PurchasedItem": "Je hebt gekocht ", + "PurchasedItem": "Je hebt gekocht %s %s", "PurchaseFailed": "Aankoop mislukt, inventaris vol", "CurrencySymbol": "$ %s", "Confirm": "Aankoop bevestigen", diff --git a/locales/no.json b/locales/no.json index 6b7e2af..0812664 100644 --- a/locales/no.json +++ b/locales/no.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Du har ikke nok penger til å kjøpe denne varen", "Input": "Mengde inndata", "PurchaseAmount": "Kjøpsmengde", - "PurchasedItem": "Du har kjøpt ", + "PurchasedItem": "Du har kjøpt %s %s", "PurchaseFailed": "Kjøp mislyktes, inventar fullt", "CurrencySymbol": "$ %s", "Confirm": "Bekreft kjøp", diff --git a/locales/pl.json b/locales/pl.json index 24f63eb..5213b81 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Nie masz wystarczająco pieniędzy, aby kupić ten przedmiot", "Input": "Wprowadzanie ilości", "PurchaseAmount": "Ilość zakupu", - "PurchasedItem": "Kupiłeś ", + "PurchasedItem": "Kupiłeś %s %s", "PurchaseFailed": "Zakup nieudany, ekwipunek pełny", "CurrencySymbol": "$ %s", "Confirm": "Potwierdź zakup", diff --git a/locales/pt.json b/locales/pt.json index 2c39cef..d10b4cd 100644 --- a/locales/pt.json +++ b/locales/pt.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Você não tem dinheiro suficiente para comprar este item", "Input": "Entrada de quantidade", "PurchaseAmount": "Quantidade de compra", - "PurchasedItem": "Você comprou ", + "PurchasedItem": "Você comprou %s %s", "PurchaseFailed": "Compra falhou, inventário cheio", "CurrencySymbol": "$ %s", "Confirm": "Confirmar compra", diff --git a/locales/ro.json b/locales/ro.json index 097a78d..be866e1 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Nu ai destui bani să cumperi acest articol", "Input": "Introducere cantitate", "PurchaseAmount": "Cantitate de cumpărare", - "PurchasedItem": "Ai cumpărat ", + "PurchasedItem": "Ai cumpărat %s %s", "PurchaseFailed": "Achiziție eșuată, inventar plin", "CurrencySymbol": "$ %s", "Confirm": "Confirmă cumpărarea", diff --git a/locales/ru.json b/locales/ru.json index 5cf6f65..609aec4 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "У вас недостаточно денег для покупки этого предмета", "Input": "Ввод количества", "PurchaseAmount": "Количество покупки", - "PurchasedItem": "Вы купили ", + "PurchasedItem": "Вы купили %s %s", "PurchaseFailed": "Покупка не удалась, инвентарь полон", "CurrencySymbol": "$ %s", "Confirm": "Подтвердить покупку", diff --git a/locales/sv.json b/locales/sv.json index 843d567..cbcb063 100644 --- a/locales/sv.json +++ b/locales/sv.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Du har inte tillräckligt med pengar för att köpa denna vara", "Input": "Mängd inmatning", "PurchaseAmount": "Inköpsmängd", - "PurchasedItem": "Du har köpt ", + "PurchasedItem": "Du har köpt %s %s", "PurchaseFailed": "Köp misslyckades, inventarium fullt", "CurrencySymbol": "$ %s", "Confirm": "Bekräfta köp", diff --git a/locales/th.json b/locales/th.json index d58e3dc..4a2097a 100644 --- a/locales/th.json +++ b/locales/th.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "คุณไม่มีเงินเพียงพอที่จะซื้อสิ่งนี้", "Input": "ป้อนจำนวน", "PurchaseAmount": "จำนวนที่ซื้อ", - "PurchasedItem": "คุณได้ซื้อ ", + "PurchasedItem": "คุณได้ซื้อ %s %s", "PurchaseFailed": "การซื้อล้มเหลว คลังเต็ม", "CurrencySymbol": "$ %s", "Confirm": "ยืนยันการซื้อ", diff --git a/locales/tr.json b/locales/tr.json index dc639d0..ee3d17b 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "Bu öğeyi satın almak için yeterli paranız yok", "Input": "Miktar girişi", "PurchaseAmount": "Satın alma miktarı", - "PurchasedItem": "Satın aldınız ", + "PurchasedItem": "Satın aldınız %s %s", "PurchaseFailed": "Satın alma başarısız, envanter dolu", "CurrencySymbol": "$ %s", "Confirm": "Satın almayı onayla", diff --git a/locales/zh-cn.json b/locales/zh-cn.json index 6bd96c5..6e5a2e3 100644 --- a/locales/zh-cn.json +++ b/locales/zh-cn.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "您没有足够的钱购买此物品", "Input": "数量输入", "PurchaseAmount": "购买数量", - "PurchasedItem": "您已购买 ", + "PurchasedItem": "您已购买 %s %s", "PurchaseFailed": "购买失败,库存已满", "CurrencySymbol": "$ %s", "Confirm": "确认购买", diff --git a/locales/zh-hk.json b/locales/zh-hk.json index 21873c1..0b98729 100644 --- a/locales/zh-hk.json +++ b/locales/zh-hk.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "您沒有足夠的錢購買此物品", "Input": "數量輸入", "PurchaseAmount": "購買數量", - "PurchasedItem": "您已購買 ", + "PurchasedItem": "你已購買 %s %s", "PurchaseFailed": "購買失敗,庫存已滿", "CurrencySymbol": "$ %s", "Confirm": "確認購買", diff --git a/locales/zh-tw.json b/locales/zh-tw.json index 83646c7..f77e476 100644 --- a/locales/zh-tw.json +++ b/locales/zh-tw.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "您沒有足夠的錢購買此物品", "Input": "數量輸入", "PurchaseAmount": "購買數量", - "PurchasedItem": "您已購買 ", + "PurchasedItem": "你已購買 %s %s", "PurchaseFailed": "購買失敗,庫存已滿", "CurrencySymbol": "$ %s", "Confirm": "確認購買", diff --git a/locales/zh.json b/locales/zh.json index 6bd96c5..6e5a2e3 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -3,7 +3,7 @@ "NotEnoughMoney": "您没有足够的钱购买此物品", "Input": "数量输入", "PurchaseAmount": "购买数量", - "PurchasedItem": "您已购买 ", + "PurchasedItem": "您已购买 %s %s", "PurchaseFailed": "购买失败,库存已满", "CurrencySymbol": "$ %s", "Confirm": "确认购买", diff --git a/modules/clothing/_default/client.lua b/modules/clothing/_default/client.lua index 7183d2d..41c4201 100644 --- a/modules/clothing/_default/client.lua +++ b/modules/clothing/_default/client.lua @@ -1,33 +1,34 @@ ---@diagnostic disable: duplicate-set-field Clothing = Clothing or {} - -ClothingBackup = {} Callback = Callback or Require("lib/callback/shared/callback.lua") -Ultility = Utility or Require('lib/utility/client/utility.lua') -Cache = Cache or Require('lib/cache/shared/cache.lua') - - -function Clothing.IsMale() - local ped = PlayerPedId() - if not ped then return end - if GetEntityModel(ped) == `mp_m_freemode_01` then - return true - end - return false -end +local ClothingBackup = {} ---This will get the name of the in use resource. ---@return string -Clothing.GetResourceName = function() +function Clothing.GetResourceName() return 'default' end +---This will open the clothing menu for a player, in the event there is not a supported menu it will print that. +function Clothing.OpenMenu() + print("^6 No supported clothing menu in use in community_bridge. ^0 ") +end + +---This will check if the player model if male/female +---@return boolean +function Clothing.IsMale() + local ped = PlayerPedId() + if not ped or not DoesEntityExist(ped) then return false end + if GetEntityModel(ped) == `mp_m_freemode_01` then return true end + return false +end + ---Get the skin data of a ped ---@param entity number ---@return table function Clothing.GetAppearance(entity) - if not entity and not DoesEntityExist(entity) then return end + if not entity and not DoesEntityExist(entity) then return {} end local model = GetEntityModel(entity) local skinData = { model = model, components = {}, props = {} } for i = 0, 11 do @@ -38,17 +39,10 @@ function Clothing.GetAppearance(entity) table.insert(skinData.props, { prop_id = i, drawable = GetPedPropIndex(entity, i), texture = GetPedPropTextureIndex(entity, i) }) end + ClothingBackup = skinData return skinData end -function Clothing.CopyAppearanceToClipboard() - local ped = PlayerPedId() - if not ped or not DoesEntityExist(ped) then return end - local skinData = Clothing.GetAppearance(ped) - if not skinData then return end - Ultility.CopyToClipboard(skinData) -end - Callback.Register('community_bridge:cb:GetAppearance', function() local ped = PlayerPedId() if not ped or not DoesEntityExist(ped) then return end @@ -57,101 +51,45 @@ Callback.Register('community_bridge:cb:GetAppearance', function() end) ---Apply skin data to a ped ----@param entity number +---@param ped number ---@param skinData table ---@return boolean -function Clothing.SetAppearance(entity, skinData) +function Clothing.SetAppearance(ped, skinData) for k, v in pairs(skinData.components or {}) do if v.component_id then - SetPedComponentVariation(entity, v.component_id, v.drawable, v.texture, 0) + SetPedComponentVariation(ped, v.component_id, v.drawable, v.texture, 0) end end for k, v in pairs(skinData.props or {}) do if v.prop_id then - SetPedPropIndex(entity, v.prop_id, v.drawable, v.texture, 0) + SetPedPropIndex(ped, v.prop_id, v.drawable, v.texture, false) end end + ClothingBackup = nil return true end ---This will return the peds components to the previously stored components +---@param ped number ---@return boolean -Clothing.RestoreAppearance = function(entity) - Clothing.SetAppearance(entity, ClothingBackup) +Clothing.RestoreAppearance = function(ped) + Clothing.SetAppearance(ped, ClothingBackup) return true end -Clothing.UpdateAppearanceBackup = function(data) - ClothingBackup = data -end - -Clothing.RunningDebug = false -Clothing.Cache = nil -- maybe change this to the actual cache system???!? For future not lazy me - -Cache.Create('Clothing', function() - local ped = Cache.Get('Ped') - local appearance = Clothing.GetAppearance(ped) - if Table.Compare(Clothing.Cache, appearance) then - return false - end - return appearance -end, 1000) - -local onChange = nil -Clothing.ToggleDebugging = function() - if Clothing.RunningDebug then - Clothing.RunningDebug = false - print("Clothing Debugging Disabled") - return Cache.RemoveOnChange('Clothing', onChange) - end - Clothing.RunningDebug = true - print("Clothing Debugging Enabled") - - if Clothing.OpenMenu then - Clothing.OpenMenu() - end - - onChange = Cache.OnChange('Clothing', function(new, old) - print("Clothing Debugging", new) - for k, v in pairs(old.components) do - if v.component_id then - if new.components[k].drawable ~= v.drawable or new.components[k].texture ~= v.texture then - print("Component ID: " .. - v.component_id .. - " Drawable: " .. new.components[k].drawable .. " Texture: " .. new.components[k].texture) - end - end - end - for k, v in pairs(old.props) do - if v.prop_id then - if new.props[k].drawable ~= v.drawable or new.props[k].texture ~= v.texture then - print("Prop ID: " .. - v.prop_id .. " Drawable: " .. new.props[k].drawable .. " Texture: " .. new.props[k].texture) - end - end - end - end) -end - RegisterNetEvent('community_bridge:client:SetAppearance', function(data) + if source ~= 65535 then return end Clothing.SetAppearance(PlayerPedId(), data) end) RegisterNetEvent('community_bridge:client:GetAppearance', function() + if source ~= 65535 then return end Clothing.GetAppearance(PlayerPedId()) end) RegisterNetEvent('community_bridge:client:RestoreAppearance', function() + if source ~= 65535 then return end Clothing.RestoreAppearance(PlayerPedId()) end) --- RegisterCommand("clothing:enabledebug", function(source, args, rawCommand) --- Clothing.ToggleDebugging() --- end) - --- RegisterCommand("clothing:copy", function(source, args, rawCommand) --- Clothing.CopyAppearanceToClipboard() --- end) - - -return Clothing +return Clothing \ No newline at end of file diff --git a/modules/clothing/_default/server.lua b/modules/clothing/_default/server.lua index c368691..a5d8a02 100644 --- a/modules/clothing/_default/server.lua +++ b/modules/clothing/_default/server.lua @@ -3,23 +3,32 @@ Clothing = Clothing or {} Clothing.LastAppearance = Clothing.LastAppearance or {} Callback = Callback or Require("lib/callback/shared/callback.lua") -function Clothing.IsMale(src) - local ped = GetPlayerPed(src) - if not ped or not DoesEntityExist(ped) then return end - return GetEntityModel(ped) == `mp_m_freemode_01` -end - ---This will get the name of the in use resource. ---@return string Clothing.GetResourceName = function() return 'default' end +---This will check if the player model if male/female +---@param src number +---@return boolean +function Clothing.IsMale(src) + local ped = GetPlayerPed(src) + if not ped or not DoesEntityExist(ped) then return false end + return GetEntityModel(ped) == `mp_m_freemode_01` +end + +---Get the skin data of a player +---@param src number +---@return table function Clothing.GetAppearance(src) return Callback.Trigger('community_bridge:cb:GetAppearance', src) end -Clothing.SetAppearance = function(src, data) +---Apply skin data to a player +---@param src number +---@param data table +function Clothing.SetAppearance(src, data) local strSrc = tostring(src) Clothing.LastAppearance[strSrc] = Clothing.GetAppearance(src) TriggerClientEvent('community_bridge:client:SetAppearance', src, data) @@ -34,29 +43,10 @@ function Clothing.SetAppearanceExt(src, data) Clothing.SetAppearance(src, tbl) end -Clothing.RestoreAppearance = function(src) +---Restore the last saved appearance of a player +---@param src number +function Clothing.RestoreAppearance(src) TriggerClientEvent('community_bridge:client:RestoreAppearance', src) end - --- RegisterNetEvent('community_bridge:client:SetAppearance', function(data) --- local src = source --- Clothing.SetAppearance(src, data) --- end) - --- RegisterNetEvent('community_bridge:client:GetAppearance', function() --- local src = source --- Clothing.GetAppearance(src) --- end) - --- RegisterNetEvent('community_bridge:client:RestoreAppearance', function() --- local src = source --- Clothing.RestoreAppearance(src) --- end) - --- RegisterNetEvent('community_bridge:client:ReloadSkin', function() --- local src = source --- Clothing.ReloadSkin(src) --- end) - -return Clothing +return Clothing \ No newline at end of file diff --git a/modules/clothing/esx_skin/server.lua b/modules/clothing/esx_skin/server.lua index cd223dd..4fb4238 100644 --- a/modules/clothing/esx_skin/server.lua +++ b/modules/clothing/esx_skin/server.lua @@ -146,6 +146,13 @@ function Clothing.OpenMenu(src) TriggerClientEvent('esx_skin:openMenu', src) end +---Callback handler for retrieving a player's appearance data +Callback.Register('community_bridge:cb:GetAppearance', function(source) + local src = source + return Clothing.GetAppearance(src) +end) + + ---Event handler for when a player loads into the server ---Caches the player's appearance data AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src) @@ -175,10 +182,4 @@ AddEventHandler('onResourceStart', function(resource) Clothing.Players[strSrc] = Clothing.GetAppearance(src) end end -end) - ----Callback handler for retrieving a player's appearance data -Callback.Register('community_bridge:cb:GetAppearance', function(source) - local src = source - return Clothing.GetAppearance(src) -end) +end) \ No newline at end of file diff --git a/modules/dialogue/_default/client/client.lua b/modules/dialogue/_default/client/client.lua index 52807cc..6f6e8a5 100644 --- a/modules/dialogue/_default/client/client.lua +++ b/modules/dialogue/_default/client/client.lua @@ -1,11 +1,8 @@ ---[[This module is incomplete]]-- - +Dialogue = {} local promises = {} local activeDialogue = nil local pendingCameraDestroy = false -Dialogue = {} - local cam = nil local npc = nil @@ -25,7 +22,7 @@ function Dialogue.Close(name) Wait(200) -- Small delay to allow new dialogue to open if pendingCameraDestroy and not activeDialogue then -- No new dialogue opened, safe to destroy camera - RenderScriptCams(false, 1, 1000, 1, 0) + RenderScriptCams(false, true, 1000, true, false) SetCamActive(cam, false) DestroyCam(cam, false) cam = nil @@ -38,7 +35,10 @@ end --- Open a dialogue with the player ---@param name string ---@param dialogue string ----@param options table example = {{ id = string, label = string}} +---@param characterOptions number|table entity or entity and offset/rotationOffset +---@param dialogueOptions table +---@param onSelected function +---@return any function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSelected) assert(name, "Name is required") assert(dialogue, "Dialogue is required") @@ -53,14 +53,12 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel pendingCameraDestroy = false activeDialogue = name - -- camera magic! if entity then Wait(500) local endLocation = GetOffsetFromEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z) - local pedHeading = GetEntityHeading(entity) - -- Get position in front of ped based on their heading + local pedHeading = GetEntityHeading(entity) -- Get position in front of ped based on their heading - if not cam then cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1) end + if not cam then cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) end local camAngle = (pedHeading + 180.0) % 360.0 SetCamRot(cam, rotationOffset.x, rotationOffset.y, camAngle + rotationOffset.z, 2) SetCamCoord(cam, endLocation.x, endLocation.y, endLocation.z) @@ -75,7 +73,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel }) SetNuiFocus(true, true) - local prom = promise.new() local wrappedFunction = function(selected) SetNuiFocus(false, false) @@ -87,7 +84,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel return Citizen.Await(prom) end - RegisterNuiCallback("dialogue:SelectOption", function(data) local promis = promises[data.name] if not promis then return end diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index cf79c99..99fb5f8 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -19,7 +19,7 @@ end ---@description This will get the name of the framework being used (if a supported framework). ---@return string Framework.GetFrameworkName = function() - print("This is depricated, please use Framework.GetResourceName() instead.") + --print("This is depricated, please use Framework.GetResourceName() instead.") return Framework.GetResourceName() end @@ -108,7 +108,7 @@ end ---@return string ---@return string Framework.GetPlayerJob = function() - print("This is depricated, please use Framework.GetPlayerJobData() instead.") + --print("This is depricated, please use Framework.GetPlayerJobData() instead.") local jobData = Framework.GetPlayerJobData() return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank end diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 077aa0f..a5c1ff2 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -13,7 +13,7 @@ local cachedItemList = nil --- @description This will return the name of the framework in use --- @return string Framework.GetFrameworkName = function() - print("This is deprecated, please use Framework.GetResourceName() instead.") + --print("This is deprecated, please use Framework.GetResourceName() instead.") return Framework.GetResourceName() end diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index d4ac0a3..c84a21d 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -150,7 +150,7 @@ end ---@return string ---@return string Framework.GetPlayerJob = function() - print("This is depricated, please use Framework.GetPlayerJobData() instead.") + --print("This is depricated, please use Framework.GetPlayerJobData() instead.") local jobData = Framework.GetPlayerJobData() return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank end diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 52196f8..704b8b6 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -372,7 +372,7 @@ end ---@return string | string | string | number | nil ---@return string | string | string | number | nil Framework.GetPlayerJob = function(src) - print("[Community Bridge] Warning: Framework.GetPlayerJob is deprecated, use Framework.GetPlayerJobData instead.") + --print("[Community Bridge] Warning: Framework.GetPlayerJob is deprecated, use Framework.GetPlayerJobData instead.") local jobData = Framework.GetPlayerJobData(src) if not jobData then return end return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeLevel diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index 05bc161..2009cfc 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -107,7 +107,7 @@ end ---@return string ---@return string Framework.GetPlayerJob = function() - print("This is depricated, please use Framework.GetPlayerJobData() instead.") + --print("This is depricated, please use Framework.GetPlayerJobData() instead.") local jobData = Framework.GetPlayerJobData() return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank end diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index a887481..b1b1709 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -357,7 +357,7 @@ Framework.GetPlayerJob = function(src) local player = Framework.GetPlayer(src) if not player then return end local playerData = player.PlayerData - print("This function is depricated, please use GetPlayerJobData instead.") + --print("This function is depricated, please use GetPlayerJobData instead.") return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end diff --git a/modules/notify/_default/client.lua b/modules/notify/_default/client.lua index ebbcedd..4688a89 100644 --- a/modules/notify/_default/client.lua +++ b/modules/notify/_default/client.lua @@ -5,6 +5,8 @@ Notify.GetResourceName = function() return "default" end + + ---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification ---12/13/25 ---@param message string @@ -12,7 +14,8 @@ end ---@param time number ---@return nil Notify.SendNotify = function(message, _type, time) - return Notify.SendNotification(nil, message, _type, time) + time = time or 3000 + return Framework.Notify(message, nil, time) end ---This will send a notify message of the type and time passed diff --git a/modules/notify/_default/server.lua b/modules/notify/_default/server.lua index fb0d7f6..232d505 100644 --- a/modules/notify/_default/server.lua +++ b/modules/notify/_default/server.lua @@ -5,6 +5,10 @@ Notify.GetResourceName = function() return "default" end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + ---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification ---12/13/25 ---@param src number @@ -27,7 +31,7 @@ end Notify.SendNotification = function(src, title, message, _type, time, props) time = time or 3000 if not title then - title = Bridge.Language.Locale("Notifications.PlaceholderTitle") + title = placeHolderText end TriggerClientEvent('community_bridge:Client:Notify', src, title, message, _type, time, props) end diff --git a/modules/notify/brutal_notify/client.lua b/modules/notify/brutal_notify/client.lua index 1ed7bdf..fc46d5c 100644 --- a/modules/notify/brutal_notify/client.lua +++ b/modules/notify/brutal_notify/client.lua @@ -9,6 +9,15 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + return exports['brutal_notify']:SendAlert('Notification', message, time, _type or "success", false) +end + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -18,7 +27,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end return exports['brutal_notify']:SendAlert(title, message, time, _type or "success", false) end diff --git a/modules/notify/fl-notify/client.lua b/modules/notify/fl-notify/client.lua index 5aa54bd..757bcfb 100644 --- a/modules/notify/fl-notify/client.lua +++ b/modules/notify/fl-notify/client.lua @@ -8,6 +8,25 @@ Notify.GetResourceName = function() return resourceName end + +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + if _type == "error" or _type == "info" then + _type = tostring(1) + elseif _type == "success" then + _type = tostring(2) + elseif _type == "warning" or _type == "warn" then + _type = tostring(3) + else + _type = tostring(2) -- Default to 2 if type is not recognized + end + return exports['FL-Notify']:Notify("Notification", "", message, 5000, tonumber(_type), 0) +end + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +36,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end if _type == "error" or _type == "info" then _type = tostring(1) elseif _type == "success" then diff --git a/modules/notify/lation_ui/client.lua b/modules/notify/lation_ui/client.lua index 336b603..4f660af 100644 --- a/modules/notify/lation_ui/client.lua +++ b/modules/notify/lation_ui/client.lua @@ -9,6 +9,16 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + return exports.lation_ui:notify({ message = message, type = _type or "success", duration = time, position = 'top-right' }) +end + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -18,7 +28,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end return exports.lation_ui:notify({ title = title, message = message, type = _type or "success", duration = time, position = 'top-right' }) end diff --git a/modules/notify/mythic_notify/client.lua b/modules/notify/mythic_notify/client.lua index df083f5..4355fdd 100644 --- a/modules/notify/mythic_notify/client.lua +++ b/modules/notify/mythic_notify/client.lua @@ -8,6 +8,17 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + _type = _type or "inform" + return exports['mythic_notify']:SendAlert(_type, message, time) +end + + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +28,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end _type = _type or "inform" return exports['mythic_notify']:SendAlert(_type, message, time) end diff --git a/modules/notify/okokNotify/client.lua b/modules/notify/okokNotify/client.lua index a5bcb23..9cf9860 100644 --- a/modules/notify/okokNotify/client.lua +++ b/modules/notify/okokNotify/client.lua @@ -8,6 +8,16 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + return exports['okokNotify']:Alert('Notification', message, time, _type or "Success", false) +end + + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +27,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end return exports['okokNotify']:Alert(title, message, time, _type or "Success", false) end diff --git a/modules/notify/ox_lib/client.lua b/modules/notify/ox_lib/client.lua index a946cb3..b1b676b 100644 --- a/modules/notify/ox_lib/client.lua +++ b/modules/notify/ox_lib/client.lua @@ -8,6 +8,16 @@ Notify.GetResourceName = function() return resourceName end + +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + return exports.ox_lib:notify({ description = message, type = _type, duration = time, position = 'top-right' }) +end + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +27,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end return exports.ox_lib:notify({ title = title, description = message, type = _type or "success", duration = time, position = 'top-right' }) end diff --git a/modules/notify/pNotify/client.lua b/modules/notify/pNotify/client.lua index 138878b..3f6bd8b 100644 --- a/modules/notify/pNotify/client.lua +++ b/modules/notify/pNotify/client.lua @@ -8,6 +8,16 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + return exports['pNotify']:SendNotification({ text = message, type = _type, timeout = time, layout = 'centerRight' }) +end + + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +27,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end return exports['pNotify']:SendNotification({ title = title, text = message, type = _type or "success", timeout = time, layout = 'centerRight' }) end diff --git a/modules/notify/r_notify/client.lua b/modules/notify/r_notify/client.lua index fd2fc38..78c953b 100644 --- a/modules/notify/r_notify/client.lua +++ b/modules/notify/r_notify/client.lua @@ -8,6 +8,15 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +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 + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +26,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end return exports.r_notify:notify({title = title, content = message, type = _type or "success", icon = "fas fa-check", duration = time, position = 'top-right', sound = false}) end diff --git a/modules/notify/t-notify/client.lua b/modules/notify/t-notify/client.lua index 43d4a36..740953e 100644 --- a/modules/notify/t-notify/client.lua +++ b/modules/notify/t-notify/client.lua @@ -8,6 +8,16 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + _type = _type or "info" + return exports['t-notify']:Alert({ style = _type, message = message, duration = time, }) +end + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +27,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end _type = _type or "info" return exports['t-notify']:Alert({ title = title, style = _type, message = message, duration = time, }) end diff --git a/modules/notify/wasabi_notify/client.lua b/modules/notify/wasabi_notify/client.lua index e3b777e..799b458 100644 --- a/modules/notify/wasabi_notify/client.lua +++ b/modules/notify/wasabi_notify/client.lua @@ -8,6 +8,16 @@ Notify.GetResourceName = function() return resourceName end +local Language = Language or Require("modules/locales/shared.lua") +local locale = Language.Locale +local placeHolderText = locale("Notifications.PlaceholderTitle") + +Notify.SendNotify = function(message, _type, time) + time = time or 3000 + _type = _type or "info" + return exports.wasabi_notify:notify(_type, message, time, _type) +end + ---This will send a notify message of the type and time passed ---@param title string ---@param message string @@ -17,7 +27,7 @@ end ---@return nil Notify.SendNotification = function(title, message, _type, time, props) time = time or 3000 - if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end + if not title then title = placeHolderText end _type = _type or "info" return exports.wasabi_notify:notify(_type, message, time, _type) end diff --git a/modules/shops/_default/server.lua b/modules/shops/_default/server.lua index f6ef0c8..3f78b24 100644 --- a/modules/shops/_default/server.lua +++ b/modules/shops/_default/server.lua @@ -4,7 +4,7 @@ Shops = Shops or {} local registeredShops = {} local Language = Language or Require("modules/locales/shared.lua") -local locales = Language.Locale +local locale = Language.Locale ---This can open a shop for the client ---@param src number @@ -51,23 +51,23 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, account) end end if not itemData or not itemData.price then return print("community_bridge Player ID "..src.." attempted to purchase invalid item from shop: "..shopName) end - if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, locales('Shops.NotEnoughStock'), "error", 5000) end + if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughStock'), "error", 5000) end local totalCost = tonumber(itemData.price) * amount local balance = Framework.GetAccountBalance(src, account) if not balance then return end - if balance <= 0 then return Notify.SendNotify(src, locales('Shops.NotEnoughMoney'), "error", 5000) end - if balance < totalCost then return Notify.SendNotify(src, locales('Shops.NotEnoughMoney'), "error", 5000) end + if balance <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end + if balance < totalCost then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end if not Framework.RemoveAccountBalance(src, account, totalCost) then return end local success = Inventory.AddItem(src, itemData.name, amount) if not success then Framework.AddAccountBalance(src, account, totalCost) - return Notify.SendNotify(src, locales('Shops.PurchaseFailed'), "error", 5000) + return Notify.SendNotify(src, locale('Shops.PurchaseFailed'), "error", 5000) end local itemLabel = Inventory.GetItemInfo(itemData.name).label or itemData.name - Notify.SendNotify(src, locales('Shops.PurchasedItem', itemLabel), "success", 5000) + Notify.SendNotify(src, locale('Shops.PurchasedItem', amount, itemLabel), "success", 5000) end ---This is an internal event to complete a checkout, complete with multiple validations. Please do not use this event directly. diff --git a/modules/skills/_default/client.lua b/modules/skills/_default/client.lua index 15cd0cb..961a319 100644 --- a/modules/skills/_default/client.lua +++ b/modules/skills/_default/client.lua @@ -1,42 +1,54 @@ ---@diagnostic disable: duplicate-set-field Skills = Skills or {} -XP_CACHE = {} +local cachedXp = {} --- Calculate XP required for a level using RuneScape algorithm (with caching) -Skills.GetXPForLevel = function(level) +function Skills.GetResourceName() + return "default" +end + +---Calculate XP required for a level using RuneScape algorithm (with caching) +---@param level number +---@return number +function Skills.GetXPForLevel(level) if not level or level < 1 then return 0 end if level == 1 then return 0 end -- Level 1 requires 0 XP - -- Check cache first - if XP_CACHE[level] then - return XP_CACHE[level] - end + if cachedXp[level] then return cachedXp[level] end - -- Calculate and cache local xp = 0 for n = 1, level - 1 do xp = xp + math.floor(n + 300 * (2 ^ (n / 7))) end local result = math.floor(xp / 4) - XP_CACHE[level] = result + cachedXp[level] = result return result end --- Create a skill (for initialization) -Skills.Create = function(name, maxLevel, baseXP) +---Create a skill (for initialization) +---@param name string +---@param maxLevel number +---@param baseXP number +---@return table +function Skills.Create(name, maxLevel, baseXP) if not name then return end Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 } return Skills.All[name] end -Skills.GetScaledXP = function(baseXP, playerLevel) +---Get scaled XP based on player level +---@param baseXP number +---@param playerLevel number +---@return number +function Skills.GetScaledXP(baseXP, playerLevel) return math.floor(baseXP * (1 + playerLevel * 0.05)) end -- Get XP required to complete the current level -Skills.GetXPRequiredForLevel = function(level) +---@param level number +---@return number +function Skills.GetXPRequiredForLevel(level) if not level or level < 1 then return 0 end if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP return Skills.GetXPForLevel(level) @@ -45,7 +57,7 @@ end ---This will get the skill level of the passed skill name. (returns 1 if not found) ---@param skillName string ---@return number -Skills.GetSkillLevel = function(skillName) +function Skills.GetSkillLevel(skillName) if not skillName then return 0 end local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills") if not plyrSkills or not plyrSkills[skillName] then return 1 end @@ -55,20 +67,11 @@ end ---This will get the skill xp of the passed skill name. (returns 1 if not found) ---@param skillName string ---@return number -Skills.GetXP = function(skillName) +function Skills.GetXP(skillName) if not skillName then return 0 end local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills") if not plyrSkills or not plyrSkills[skillName] then return 1 end return plyrSkills[skillName].currentXP or 1 end -Skills.GetResourceName = function() - return "default" -end - --- RegisterCommand("getfishingLevel", function(source, args) --- local level = Skills.GetSkillLevel("fishing") --- print("Client Fishing Level issssssssss " .. level) --- end, false) - return Skills \ No newline at end of file diff --git a/modules/skills/_default/server.lua b/modules/skills/_default/server.lua index 7ec6d55..6f53e52 100644 --- a/modules/skills/_default/server.lua +++ b/modules/skills/_default/server.lua @@ -3,31 +3,39 @@ Skills = Skills or {} Skills.All = Skills.All or {} -- XP Cache for performance -local XP_CACHE = {} - +local cachedXp = {} -- Default skill object: currentXP (0 to required), level -local DEFAULT_SKILL = { currentXP = 0, level = 1 } +local defaultSkills = { currentXP = 0, level = 1 } + +function Skills.GetResourceName() + return "default" +end -- Helper function to get or create a skill object +---@param src number +---@param skillName string +---@return table local function getOrCreateSkill(src, skillName) - if not src or not skillName then return table.clone(DEFAULT_SKILL) end + if not src or not skillName then return table.clone(defaultSkills) end local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {} if not playerSkills[skillName] then - playerSkills[skillName] = table.clone(DEFAULT_SKILL) + playerSkills[skillName] = table.clone(defaultSkills) end return playerSkills[skillName] end --- Calculate XP required for a level using RuneScape algorithm (with caching) -Skills.GetXPForLevel = function(level) +---Calculate XP required for a level using RuneScape algorithm (with caching) +---@param level number +---@return number +function Skills.GetXPForLevel(level) if not level or level < 1 then return 0 end if level == 1 then return 0 end -- Level 1 requires 0 XP -- Check cache first - if XP_CACHE[level] then - return XP_CACHE[level] + if cachedXp[level] then + return cachedXp[level] end -- Calculate and cache @@ -36,30 +44,44 @@ Skills.GetXPForLevel = function(level) xp = xp + math.floor(n + 300 * (2 ^ (n / 7))) end local result = math.floor(xp / 4) - XP_CACHE[level] = result + cachedXp[level] = result return result end -- Create a skill (for initialization) -Skills.Create = function(name, maxLevel, baseXP) - if not name then return end +---@param name string +---@param maxLevel number +---@param baseXP number +---@return table +function Skills.Create(name, maxLevel, baseXP) + if not name then return {} end Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 } return Skills.All[name] end -- Get player's current level -Skills.GetSkillLevel = function(src, skillName) +---@param src number +---@param skillName string +---@return number +function Skills.GetSkillLevel(src, skillName) if not src or not skillName then return 1 end local skill = getOrCreateSkill(src, skillName) return skill.level or 1 end -Skills.GetScaledXP = function(baseXP, playerLevel) +-- returns scaled XP based on player level +---@param baseXP number +---@param playerLevel number +---@return integer +function Skills.GetScaledXP(baseXP, playerLevel) return math.floor(baseXP * (1 + playerLevel * 0.05)) end -- Get current XP (0 to required XP for current level) -Skills.GetXP = function(src, skillName) +---@param src number +---@param skillName string +---@return number +function Skills.GetXP(src, skillName) if not src or not skillName then return 0 end local skill = getOrCreateSkill(src, skillName) local currentXP = skill.currentXP or 0 @@ -67,17 +89,21 @@ Skills.GetXP = function(src, skillName) end -- Get XP required to complete the current level -Skills.GetXPRequiredForLevel = function(level) +---@param level number +---@return number +function Skills.GetXPRequiredForLevel(level) if not level or level < 1 then return 0 end if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP return Skills.GetXPForLevel(level) end -- Add XP and handle level ups -Skills.AddXP = function(src, skillName, xp) - if not src or not skillName then - return false - end +---@param src number +---@param skillName string +---@param xp number +---@return boolean, number, number +function Skills.AddXP(src, skillName, xp) + if not src or not skillName then return false, 0, 0 end if not xp or xp <= 0 then xp = Skills.GetScaledXP(50, Skills.GetSkillLevel(src, skillName)) @@ -86,15 +112,14 @@ Skills.AddXP = function(src, skillName, xp) local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {} local skill = playerSkills[skillName] if not skill then - skill = table.clone(DEFAULT_SKILL) + skill = table.clone(defaultSkills) playerSkills[skillName] = skill end local oldLevel = skill.level or 1 local currentXP = skill.currentXP or 0 - -- Add XP - currentXP = currentXP + xp + currentXP = currentXP + xp local xpNeeded = Skills.GetXPRequiredForLevel(oldLevel + 1) if currentXP >= xpNeeded then @@ -112,11 +137,15 @@ Skills.AddXP = function(src, skillName, xp) end -- Set skill level directly (resets currentXP to 0) -Skills.SetSkillLevel = function(src, skillName, level) +---@param src number +---@param skillName string +---@param level number +---@return boolean +function Skills.SetSkillLevel(src, skillName, level) if not src or not skillName or not level or level < 1 then return false end local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {} - local skill = playerSkills[skillName] or table.clone(DEFAULT_SKILL) + local skill = playerSkills[skillName] or table.clone(defaultSkills) level = math.min(math.max(1, level), 99) skill.level = level @@ -128,11 +157,15 @@ Skills.SetSkillLevel = function(src, skillName, level) end -- Set current XP directly -Skills.SetXP = function(src, skillName, xp) +---@param src number +---@param skillName string +---@param xp number +---@return boolean +function Skills.SetXP(src, skillName, xp) if not src or not skillName or not xp or xp < 0 then return false end local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {} - local skill = playerSkills[skillName] or table.clone(DEFAULT_SKILL) + local skill = playerSkills[skillName] or table.clone(defaultSkills) skill.currentXP = xp playerSkills[skillName] = skill @@ -141,17 +174,4 @@ Skills.SetXP = function(src, skillName, xp) return true end -Skills.GetResourceName = function() - return "default" -end - --- Debug Commands --- RegisterCommand('clearskill', function(source, args, rawCommand) --- if not source or source == 0 then return end --- local skillName = args[1] or "fishing" --- Skills.SetXP(source, skillName, 0) --- Skills.SetSkillLevel(source, skillName, 1) --- print("Skill " .. skillName .. " cleared for player " .. source) --- end, false) - return Skills \ No newline at end of file diff --git a/modules/skills/evolent_skills/client.lua b/modules/skills/evolent_skills/client.lua index b471888..1c8ae61 100644 --- a/modules/skills/evolent_skills/client.lua +++ b/modules/skills/evolent_skills/client.lua @@ -13,7 +13,7 @@ end ---This will return the skill level of the passed skill name. ---@param skillName string ---@return number -Skills.GetSkillLevel = function(skillName) +function Skills.GetSkillLevel(skillName) local skillData = exports.evolent_skills:getSkillLevel(skillName) return skillData or 0 end diff --git a/modules/skills/evolent_skills/server.lua b/modules/skills/evolent_skills/server.lua index 78d4c7c..045eb73 100644 --- a/modules/skills/evolent_skills/server.lua +++ b/modules/skills/evolent_skills/server.lua @@ -7,14 +7,14 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c ---This will get the name of the Skills system being used. ---@return string -Skills.GetResourceName = function() +function Skills.GetResourceName() return resourceName end ---This will return the skill level of the passed skill name. ---@param src number ---@param skillName string ---@return number -Skills.GetSkillLevel = function(src, skillName) +function Skills.GetSkillLevel(src, skillName) local skillData = exports.evolent_skills:getSkillLevel(src, skillName) return skillData or 0 end @@ -24,7 +24,7 @@ end ---@param skillName string ---@param amount number ---@return boolean -Skills.AddXp = function(src, skillName, amount) +function Skills.AddXp(src, skillName, amount) local skillData = exports.evolent_skills:getSkillLevel(src, skillName) if not skillData then return false, print("Skill not found") end if not Skills.All[skillName] then @@ -39,7 +39,7 @@ end ---@param skillName string ---@param amount number ---@return boolean -Skills.RemoveXp = function(src, skillName, amount) +function Skills.RemoveXp(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) diff --git a/modules/skills/ot_skills/client.lua b/modules/skills/ot_skills/client.lua index d619467..96dd47e 100644 --- a/modules/skills/ot_skills/client.lua +++ b/modules/skills/ot_skills/client.lua @@ -7,14 +7,14 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c ---This will return the name of the Skills system being used. ---@return string -Skills.GetResourceName = function() +function Skills.GetResourceName() return resourceName end ---This will return the skill level of the passed skill name. ---@param skillName string ---@return number -Skills.GetSkillLevel = function(skillName) +function Skills.GetSkillLevel(skillName) local skillData = exports.OT_skills:getSkill(skillName) return skillData.level or 0 end diff --git a/modules/skills/ot_skills/server.lua b/modules/skills/ot_skills/server.lua index 1981e5a..7e985d1 100644 --- a/modules/skills/ot_skills/server.lua +++ b/modules/skills/ot_skills/server.lua @@ -7,7 +7,7 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c ---This will return the name of the Skills system being used. ---@return string -Skills.GetResourceName = function() +function Skills.GetResourceName() return resourceName end @@ -15,7 +15,7 @@ end ---@param src number ---@param skillName string ---@return number -Skills.GetSkillLevel = function(src, skillName) +function Skills.GetSkillLevel(src, skillName) local skillData = exports.OT_skills:getSkill(src, skillName) return skillData.level or 0 end @@ -25,7 +25,7 @@ end ---@param skillName string ---@param amount number ---@return boolean -Skills.AddXp = function(src, skillName, amount) +function Skills.AddXp(src, skillName, amount) local skillData = exports.OT_skills:getSkill(src, skillName) if not skillData then return false, print("Skill not found") end if not Skills.All[skillName] then @@ -40,7 +40,7 @@ end ---@param skillName string ---@param amount number ---@return boolean -Skills.RemoveXp = function(src, skillName, amount) +function Skills.RemoveXp(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) diff --git a/modules/skills/pickle_xp/client.lua b/modules/skills/pickle_xp/client.lua index 89bd99b..a98707e 100644 --- a/modules/skills/pickle_xp/client.lua +++ b/modules/skills/pickle_xp/client.lua @@ -6,14 +6,14 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c ---This will get the name of the Skills system being used. ---@return string -Skills.GetResourceName = function() +function Skills.GetResourceName() return resourceName end ---This will return the skill level of the passed skill name. ---@param skillName string ---@return number -Skills.GetSkillLevel = function(skillName) +function Skills.GetSkillLevel(skillName) local skillData = exports.pickle_xp:GetLevel(skillName) return skillData or 0 end diff --git a/modules/skills/pickle_xp/server.lua b/modules/skills/pickle_xp/server.lua index 5039bf0..cc6df96 100644 --- a/modules/skills/pickle_xp/server.lua +++ b/modules/skills/pickle_xp/server.lua @@ -7,7 +7,7 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c ---This will get the name of the Skills system being used. ---@return string -Skills.GetResourceName = function() +function Skills.GetResourceName() return resourceName end @@ -15,7 +15,7 @@ end ---@param src number ---@param skillName string ---@return number -Skills.GetSkillLevel = function(src, skillName) +function Skills.GetSkillLevel(src, skillName) local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName) return skillData or 0 end @@ -25,15 +25,11 @@ end ---@param skillName string ---@param amount number ---@return boolean -Skills.AddXp = function(src, skillName, amount) +function Skills.AddXp(src, skillName, amount) local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName) - if not skillData then return false, print("Skill not found") end - if not Skills.All[skillName] then - Skills.All[skillName] = Skills.Create(skillName, 99, 50) - end - -- if not amount or amount < 0 then - -- amount = Skills.GetScaledXP(Skills.All[skillName].baseXP, Skills.GetSkillLevel(src, skillName)) - -- end + if not skillData then return false, print("^6 Skill "..skillName.." not found ^0 ") end + if not Skills.All[skillName] then Skills.All[skillName] = Skills.Create(skillName, 99, 50) end + exports.pickle_xp:AddPlayerXP(src, skillName, amount) return true end @@ -43,7 +39,7 @@ end ---@param skillName string ---@param amount number ---@return boolean -Skills.RemoveXp = function(src, skillName, amount) +function Skills.RemoveXp(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) diff --git a/modules/target/_default/client.lua b/modules/target/_default/client.lua index d554be4..62a66cf 100644 --- a/modules/target/_default/client.lua +++ b/modules/target/_default/client.lua @@ -2,16 +2,21 @@ Target = Target or {} Ids = Ids or Require("lib/utility/shared/ids.lua") +local InteractIds = {} + local function warnUser() print("Currently Only Targeting Is Supported By Community Bridge, You Are Using A Resource That Requires The Target Module To Be Used.") end -local InteractIds = {} -Target.GetCanInteract = function(id) +function Target.GetResourceName() + return "default" +end + +function Target.GetCanInteract(id) return InteractIds[id] end -Target.CreateCanInteract = function(cb) +function Target.CreateCanInteract(cb) if not cb then return end local id = Ids.CreateUniqueId(InteractIds) InteractIds[id] = { @@ -22,7 +27,7 @@ Target.CreateCanInteract = function(cb) return id end -Target.CanInteract = function(id, ...) +function Target.CanInteract(id, ...) local interactData = InteractIds[id] if not interactData then return true end if interactData.ableToInteract == -1 then @@ -36,7 +41,7 @@ Target.CanInteract = function(id, ...) return interactData.ableToInteract > 0 end -Target.FixOptions = function(options) +function Target.FixOptions(options) for k, v in pairs(options) do local action = v.onSelect or v.action local select = function(entityOrData) @@ -57,19 +62,19 @@ Target.FixOptions = function(options) return options end -Target.AddGlobalPlayer = function(options) +function Target.AddGlobalPlayer(options) warnUser() end -Target.AddGlobalVehicle = function(options) +function Target.AddGlobalVehicle(options) warnUser() end -Target.RemoveGlobalVehicle = function(options) +function Target.RemoveGlobalVehicle(options) warnUser() end -Target.AddLocalEntity = function(entities, _options) +function Target.AddLocalEntity(entities, _options) local fixedOptions = Target.FixOptions(_options) if type(entities) == "string" or type(entities) == "number" then entities = { entities } @@ -117,11 +122,11 @@ Target.AddLocalEntity = function(entities, _options) end end -Target.AddModel = function(models, options) +function Target.AddModel(models, options) warnUser() end -Target.AddBoxZone = function(name, coords, size, heading, options) +function Target.AddBoxZone(name, coords, size, heading, options) local fixedOptions = Target.FixOptions(options) local id = Ids.RandomString() local title = Bridge.Language.Locale("target.title") @@ -162,24 +167,20 @@ Target.AddBoxZone = function(name, coords, size, heading, options) end) end -Target.RemoveGlobalPlayer = function() +function Target.RemoveGlobalPlayer() warnUser() end -Target.RemoveLocalEntity = function(entity) +function Target.RemoveLocalEntity(entity) warnUser() end -Target.RemoveModel = function(model) +function Target.RemoveModel(model) warnUser() end -Target.RemoveZone = function(name) +function Target.RemoveZone(name) warnUser() end -Target.GetResourceName = function() - return "default" -end - return Target \ No newline at end of file diff --git a/modules/target/ox_target/client.lua b/modules/target/ox_target/client.lua index 639c18c..45ffd85 100644 --- a/modules/target/ox_target/client.lua +++ b/modules/target/ox_target/client.lua @@ -4,12 +4,9 @@ if GetResourceState(resourceName) == 'missing' then return end Target = Target or {} local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false - local ox_target = exports.ox_target local targetZones = {} -Target = Target or {} - Target.GetResourceName = function() return "ox_target" end @@ -17,7 +14,7 @@ end ---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc. ---@param options table ---@return table -Target.FixOptions = function(options) +function Target.FixOptions(options) for _, v in pairs(options) do local action = v.onSelect or v.action if not action then @@ -50,45 +47,45 @@ end ---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely. ---@param bool boolean -Target.DisableTargeting = function(bool) +function Target.DisableTargeting(bool) ox_target:disableTargeting(bool) end ---This will add target options to players. ---@param options table -Target.AddGlobalPlayer = function(options) +function Target.AddGlobalPlayer(options) options = Target.FixOptions(options) ox_target:addGlobalPlayer(options) end ---This will remove target options from all players. -Target.RemoveGlobalPlayer = function() +function Target.RemoveGlobalPlayer() ox_target:removeGlobalPlayer() end ---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type. ---@param options table -Target.AddGlobalPed = function(options) +function Target.AddGlobalPed(options) options = Target.FixOptions(options) ox_target:addGlobalPed(options) end ---This will remove target options from all peds. This is useful for when you want to remove target options from all peds. ---@param options any -Target.RemoveGlobalPed = function(options) +function Target.RemoveGlobalPed(options) ox_target:removeGlobalPed(options) end ---This will add taget options to all vehicles. ---@param options table -Target.AddGlobalVehicle = function(options) +function Target.AddGlobalVehicle(options) options = Target.FixOptions(options) ox_target:addGlobalVehicle(options) end ---This will remove target options from all vehicles. ---@param options table -Target.RemoveGlobalVehicle = function(options) +function Target.RemoveGlobalVehicle(options) local assembledLables = {} for k, v in pairs(options) do table.insert(assembledLables, v.name) @@ -99,7 +96,7 @@ end ---This will generate targets on non networked entites with the passed options. ---@param entities number | table ---@param options table -Target.AddLocalEntity = function(entities, options) +function Target.AddLocalEntity(entities, options) options = Target.FixOptions(options) ox_target:addLocalEntity(entities, options) end @@ -107,14 +104,14 @@ end ---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity. ---@param entities table ---@param optionNames string | table | nil -Target.RemoveLocalEntity = function(entities, optionNames) +function Target.RemoveLocalEntity(entities, optionNames) ox_target:removeLocalEntity(entities, optionNames) end ---This will add a networked entity to the target system. ---@param netids table | number ---@param options table -Target.AddNetworkedEntity = function(netids, options) +function Target.AddNetworkedEntity(netids, options) options = Target.FixOptions(options) ox_target:addEntity(netids, options) end @@ -122,21 +119,21 @@ end ---This will remove a networked entity from the target system. ---@param netids table | number ---@param optionNames string -Target.RemoveNetworkedEntity = function(netids, optionNames) +function Target.RemoveNetworkedEntity(netids, optionNames) ox_target:removeEntity(netids, optionNames) end ---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type. ---@param models number | table ---@param options table -Target.AddModel = function(models, options) +function Target.AddModel(models, options) options = Target.FixOptions(options) ox_target:addModel(models, options) end ---This will remove target options from all specified models. ---@param model number -Target.RemoveModel = function(model) +function Target.RemoveModel(model) ox_target:removeModel(model) end @@ -146,7 +143,7 @@ end ---@param size table ---@param heading number ---@param options table -Target.AddBoxZone = function(name, coords, size, heading, options, debug) +function Target.AddBoxZone(name, coords, size, heading, options, debug) options = Target.FixOptions(options or {}) if not next(options) then return end local target = ox_target:addBoxZone({ @@ -165,7 +162,7 @@ end ---@param coords table ---@param radius number ---@param options table -Target.AddSphereZone = function(name, coords, radius, options, debug) +function Target.AddSphereZone(name, coords, radius, options, debug) options = Target.FixOptions(options) local target = ox_target:addSphereZone({ coords = coords, @@ -180,7 +177,7 @@ end ---This will remove target options from a specific zone. ---@param name string -Target.RemoveZone = function(name) +function Target.RemoveZone(name) if not name then return end for _, data in pairs(targetZones) do if data.name == name then diff --git a/modules/target/qb-target/client.lua b/modules/target/qb-target/client.lua index 4a8fa90..77dea11 100644 --- a/modules/target/qb-target/client.lua +++ b/modules/target/qb-target/client.lua @@ -5,18 +5,14 @@ if GetResourceState("ox_target") ~= 'missing' then return end Target = Target or {} local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false - local targetZones = {} - -Target = Target or {} - local qb_target = exports['qb-target'] -Target.GetResourceName = function() +function Target.GetResourceName() return "qb-target" end -function GetLargestDistance(data) +local function getLargestDistance(data) local largestDistance = -1 for _, v in pairs(data) do if v.distance and v.distance > largestDistance then @@ -30,7 +26,7 @@ end ---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc. ---@param options table ---@return table -Target.FixOptions = function(options) +function Target.FixOptions(options) for k, v in pairs(options) do local action = v.onSelect or v.action local select = action and function(entityOrData) @@ -62,55 +58,55 @@ end ---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely. ---@param bool boolean -Target.DisableTargeting = function(bool) +function Target.DisableTargeting(bool) qb_target:AllowTargeting(not bool) end ---This will add target options to players. ---@param options table -Target.AddGlobalPlayer = function(options) +function Target.AddGlobalPlayer(options) options = Target.FixOptions(options) qb_target:AddGlobalPlayer({ options = options, - distance = GetLargestDistance(options) + distance = getLargestDistance(options) }) end ---This will remove target options from all players. -Target.RemoveGlobalPlayer = function() +function Target.RemoveGlobalPlayer() qb_target:RemoveGlobalPlayer() end ---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type. ---@param options table -Target.AddGlobalPed = function(options) +function Target.AddGlobalPed(options) options = Target.FixOptions(options) qb_target:AddGlobalPed({ options = options, - distance = GetLargestDistance(options) + distance = getLargestDistance(options) }) end ---This will remove target options from all peds. This is useful for when you want to remove target options from all peds. ---@param options any -Target.RemoveGlobalPed = function(options) +function Target.RemoveGlobalPed(options) qb_target:RemoveGlobalPed(options) end ---This will add taget options to all vehicles. ---@param options table -Target.AddGlobalVehicle = function(options) +function Target.AddGlobalVehicle(options) options = Target.FixOptions(options) qb_target:AddGlobalVehicle({ options = options, - distance = GetLargestDistance(options) + distance = getLargestDistance(options) }) end ---This will add a networked entity to the target system. ---@param netids table | number ---@param options table -Target.AddNetworkedEntity = function(netids, options) +function Target.AddNetworkedEntity(netids, options) options = Target.FixOptions(options) qb_target:AddTargetEntity(netids, options) end @@ -118,13 +114,13 @@ end ---This will remove a networked entity from the target system. ---@param netids table | number ---@param optionNames string -Target.RemoveNetworkedEntity = function(netids, optionNames) +function Target.RemoveNetworkedEntity(netids, optionNames) qb_target:RemoveTargetEntity(netids, optionNames) end ---This will remove target options from all vehicles. ---@param options table -Target.RemoveGlobalVehicle = function(options) +function Target.RemoveGlobalVehicle(options) local assembledLables = {} for k, v in pairs(options) do table.insert(assembledLables, v.label) @@ -135,35 +131,35 @@ end ---This will generate targets on non networked entites with the passed options. ---@param entities number | table ---@param options table -Target.AddLocalEntity = function(entities, options) +function Target.AddLocalEntity(entities, options) options = Target.FixOptions(options) qb_target:AddTargetEntity(entities, { options = options, - distance = GetLargestDistance(options) + distance = getLargestDistance(options) }) end ---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity. ---@param entity number | table ---@param labels string | table | nil -Target.RemoveLocalEntity = function(entity, labels) +function Target.RemoveLocalEntity(entity, labels) qb_target:RemoveTargetEntity(entity, labels) end ---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type. ---@param models number | table ---@param options table -Target.AddModel = function(models, options, distance) +function Target.AddModel(models, options, distance) options = Target.FixOptions(options) qb_target:AddTargetModel(models, { options = options, - distance = GetLargestDistance(options), + distance = getLargestDistance(options), }) end ---This will remove target options from all specified models. ---@param model number -Target.RemoveModel = function(model) +function Target.RemoveModel(model) qb_target:RemoveTargetModel(model) end @@ -173,7 +169,7 @@ end ---@param size table ---@param heading number ---@param options table -Target.AddBoxZone = function(name, coords, size, heading, options, debug) +function Target.AddBoxZone(name, coords, size, heading, options, debug) options = Target.FixOptions(options) if not next(options) then return end qb_target:AddBoxZone(name, coords, size.x, size.y, { @@ -184,7 +180,7 @@ Target.AddBoxZone = function(name, coords, size, heading, options, debug) maxZ = coords.z + (size.z * 0.5), }, { options = options, - distance = GetLargestDistance(options), + distance = getLargestDistance(options), }) table.insert(targetZones, { name = name, creator = GetInvokingResource() }) return name @@ -195,14 +191,14 @@ end ---@param coords table ---@param radius number ---@param options table -Target.AddSphereZone = function(name, coords, radius, options, debug) +function Target.AddSphereZone(name, coords, radius, options, debug) options = Target.FixOptions(options) qb_target:AddCircleZone(name, coords, radius, { name = name, debugPoly = targetDebug or debug, }, { options = options, - distance = GetLargestDistance(options), + distance = getLargestDistance(options), }) table.insert(targetZones, { name = name, creator = GetInvokingResource() }) return name @@ -210,7 +206,7 @@ end ---This will remove target options from a specific zone. ---@param name string -Target.RemoveZone = function(name) +function Target.RemoveZone(name) if not name then return end for _, data in pairs(targetZones) do if data.name == name then diff --git a/modules/target/sleepless_interact/client.lua b/modules/target/sleepless_interact/client.lua index 194e308..f2cb8e5 100644 --- a/modules/target/sleepless_interact/client.lua +++ b/modules/target/sleepless_interact/client.lua @@ -3,22 +3,20 @@ local resourceName = "sleepless_interact" if GetResourceState(resourceName) == 'missing' then return end if GetResourceState("ox_target") == 'started' then return end -local targetDebug = false -local function detectDebugEnabled() - if BridgeSharedConfig.DebugLevel == 2 then targetDebug = true end -end - -detectDebugEnabled() - +local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false local sleepless_interact = exports.sleepless_interact local targetZones = {} Target = Target or {} +function Target.GetResourceName() + return "sleepless_interact" +end + ---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc. ---@param options table ---@return table -Target.FixOptions = function(options) +function Target.FixOptions(options) for k, v in pairs(options) do local action = v.onSelect or v.action local select = function(entityOrData) @@ -42,45 +40,45 @@ end ---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely. ---@param bool boolean -Target.DisableTargeting = function(bool) -- someone disabled this mistakenly +function Target.DisableTargeting(bool) -- someone disabled this mistakenly sleepless_interact:disableInteract(bool) end ---This will add target options to players. ---@param options table -Target.AddGlobalPlayer = function(options) +function Target.AddGlobalPlayer(options) options = Target.FixOptions(options) sleepless_interact:addGlobalPlayer(options) end ---This will remove target options from all players. -Target.RemoveGlobalPlayer = function() +function Target.RemoveGlobalPlayer() sleepless_interact:removeGlobalPlayer() end ---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type. ---@param options table -Target.AddGlobalPed = function(options) +function Target.AddGlobalPed(options) options = Target.FixOptions(options) sleepless_interact:addGlobalPed(options) end ---This will remove target options from all peds. This is useful for when you want to remove target options from all peds. ---@param options any -Target.RemoveGlobalPed = function(options) +function Target.RemoveGlobalPed(options) sleepless_interact:removeGlobalPed(options) end ---This will add taget options to all vehicles. ---@param options table -Target.AddGlobalVehicle = function(options) +function Target.AddGlobalVehicle(options) options = Target.FixOptions(options) sleepless_interact:addGlobalVehicle(options) end ---This will remove target options from all vehicles. ---@param options table -Target.RemoveGlobalVehicle = function(options) +function Target.RemoveGlobalVehicle(options) local assembledLables = {} for k, v in pairs(options) do table.insert(assembledLables, v.name) @@ -91,7 +89,7 @@ end ---This will add a networked entity to the target system. ---@param netids table | number ---@param options table -Target.AddNetworkedEntity = function(netids, options) +function Target.AddNetworkedEntity(netids, options) options = Target.FixOptions(options) sleepless_interact:addEntity(netids, options) end @@ -99,14 +97,14 @@ end ---This will remove a networked entity from the target system. ---@param netids table | number ---@param optionNames string -Target.RemoveNetworkedEntity = function(netids, optionNames) +function Target.RemoveNetworkedEntity(netids, optionNames) sleepless_interact:removeEntity(netids, optionNames) end ---This will generate targets on non networked entites with the passed options. ---@param entities number | table ---@param options table -Target.AddLocalEntity = function(entities, options) +function Target.AddLocalEntity(entities, options) options = Target.FixOptions(options) sleepless_interact:addLocalEntity(entities, options) end @@ -114,21 +112,21 @@ end ---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity. ---@param entity number | table ---@param labels string | table | nil -Target.RemoveLocalEntity = function(entity, labels) +function Target.RemoveLocalEntity(entity, labels) sleepless_interact:removeLocalEntity(entity, labels) end ---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type. ---@param models number | table ---@param options table -Target.AddModel = function(models, options) +function Target.AddModel(models, options) options = Target.FixOptions(options) sleepless_interact:addModel(models, options) end ---This will remove target options from all specified models. ---@param model number -Target.RemoveModel = function(model) +function Target.RemoveModel(model) sleepless_interact:removeModel(model) end @@ -138,7 +136,7 @@ end ---@param size table ---@param heading number ---@param options table -Target.AddBoxZone = function(name, coords, size, heading, options) +function Target.AddBoxZone(name, coords, size, heading, options) options = Target.FixOptions(options) local target = sleepless_interact:addCoords({ coords = coords, @@ -153,7 +151,7 @@ end ---@param coords table ---@param radius number ---@param options table -Target.AddSphereZone = function(name, coords, radius, options, debug) +function Target.AddSphereZone(name, coords, radius, options, debug) options = Target.FixOptions(options) local target = sleepless_interact:addSphereZone({ coords = coords, @@ -168,7 +166,7 @@ end ---This will remove target options from a specific zone. ---@param name string -Target.RemoveZone = function(name) +function Target.RemoveZone(name) for _, data in pairs(targetZones) do if data.name == name then sleepless_interact:removeCoords(data.id) @@ -188,8 +186,4 @@ AddEventHandler('onResourceStop', function(resource) targetZones = {} end) -Target.GetResourceName = function() - return "sleepless_interact" -end - return Target \ No newline at end of file