diff --git a/fxmanifest.lua b/fxmanifest.lua index 4acca46..82f0d80 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ lua54 'yes' use_experimental_fxv2_oal 'yes' author 'The Order of the Sacred Framework' description 'A bridge made for the community to use as a base for their own projects. This bridge will allow a single format to work with nearly all commonly used systems while still offering expandability.' -version '0.5.0' +version '0.5.1' shared_scripts { '@ox_lib/init.lua', @@ -28,6 +28,7 @@ server_scripts { 'modules/clothing/**/server.lua', 'modules/shops/**/server.lua', 'modules/notify/**/server.lua', + 'modules/housing/**/server.lua', 'init.lua', } @@ -50,6 +51,7 @@ client_scripts { 'modules/notify/**/client.lua', 'modules/dialogue/**/client/*.lua', 'modules/shops/**/client.lua', + 'modules/housing/**/client.lua', 'modules/accessibility/client.lua', 'init.lua', } diff --git a/init.lua b/init.lua index 3c6340b..a13bd78 100644 --- a/init.lua +++ b/init.lua @@ -53,6 +53,7 @@ Bridge.RegisterModule("Doorlock", Doorlock) Bridge.RegisterModule("Phone", Phone) Bridge.RegisterModule("Dispatch", Dispatch) Bridge.RegisterModule("Shops", Shops) +Bridge.RegisterModule("Housing", Housing) --lib Bridge.RegisterModule("Tables", cLib.Tables) @@ -109,7 +110,7 @@ Bridge.RegisterModule("Raycast", cLib.Raycast) Bridge.RegisterModule("PlaceableObject", cLib.PlaceableObject) Bridge.RegisterModule("Point", cLib.Point) Bridge.RegisterModule("Object", cLib.Object) - +Bridge.RegisterModule("Particle", cLib.Particle) -- Fill the bridge tables with player data. diff --git a/lib/particles/client/particles.lua b/lib/particles/client/particles.lua index 89ed5f2..f0cc83a 100644 --- a/lib/particles/client/particles.lua +++ b/lib/particles/client/particles.lua @@ -1,22 +1,20 @@ Particle = {} -Particles = {} - ---- Load a particle dictionary. This function will block until the dictionary is loaded. ---- @param dict string -- The name of the particle dictionary to load. ---- @return boolean -- Returns true if the dictionary was loaded successfully, false otherwise. ---- @throws string -- Throws an error if the dictionary fails to load after 100 attempts. -function Particle.LoadDict(dict) - RequestNamedPtfxAsset(dict) +---Loads a ptfx asset into memory. +---@param dict string +---@return boolean +function LoadPtfxAsset(dict) local failed = 100 while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do + RequestNamedPtfxAsset(dict) failed = failed - 1 - Wait(50) + Wait(100) end - assert(failed >= 0, "Failed to load particle dictionary: " .. dict) - return true + assert(failed > 0, "Failed to load dict asset: " .. dict) + return HasNamedPtfxAssetLoaded(dict) end + --- Create a particle effect at the specified position and rotation. --- @param dict string --- @param ptfx string @@ -28,26 +26,57 @@ end --- @param loopLength number|nil --- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create. function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength) - if not Particle.LoadDict(dict) then return end - UseParticleFxAssetNextCall(dict) - local handle = nil - if looped then - handle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) - SetParticleFxLoopedColour(handle, color.x, color.y, color.z, false) - if loopLength then - Wait(loopLength) - StopParticleFxLooped(handle, 0) - RemoveParticleFx(handle, false) - end - else + LoadPtfxAsset(dict) + CreateThread(function() + UseParticleFxAssetNextCall(dict) SetParticleFxNonLoopedColour(color.x, color.y, color.z) - handle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false) - RemoveParticleFx(handle, false) - end - return handle + if looped then + StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) + if loopLength then + Wait(loopLength) + RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01) + end + else + StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) + end + RemoveNamedPtfxAsset(ptfx) + end) end --- need to add looping effects (regarless of if its a looped particle or not) +function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength) + LoadPtfxAsset(dict) + UseParticleFxAssetNextCall(dict) + SetParticleFxNonLoopedColour(color.x, color.y, color.z) + local particle = nil + if looped then + particle = StartNetworkedParticleFxLoopedOnEntity(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, scale, false, false, false) + if loopLength then + Wait(loopLength) + RemoveParticleFxFromEntity(entity) + end + else + particle = StartNetworkedParticleFxLoopedOnEntity(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, scale, false, false, false) + end + RemoveNamedPtfxAsset(ptfx) + return particle +end +function Particle.CreateOnEntityBone(dict, ptfx, entity, bone, offset, rot, scale, color, looped, loopLength) + LoadPtfxAsset(dict) + UseParticleFxAssetNextCall(dict) + SetParticleFxNonLoopedColour(color.x, color.y, color.z) + local particle = nil + if looped then + particle = StartNetworkedParticleFxLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) + if loopLength then + Wait(loopLength) + RemoveParticleFxFromEntity(entity) + end + else + particle = StartNetworkedParticleFxNonLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) + end + RemoveNamedPtfxAsset(ptfx) + return particle +end return Particle \ No newline at end of file diff --git a/modules/doorlock/doors_creator/client.lua b/modules/doorlock/doors_creator/client.lua index dbf6c86..88b9745 100644 --- a/modules/doorlock/doors_creator/client.lua +++ b/modules/doorlock/doors_creator/client.lua @@ -2,6 +2,8 @@ if GetResourceState('doors_creator') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() return exports["doors_creator"]:getClosestActiveDoor() end \ No newline at end of file diff --git a/modules/doorlock/ox_doorlock/server.lua b/modules/doorlock/ox_doorlock/server.lua index 1594980..a0324ba 100644 --- a/modules/doorlock/ox_doorlock/server.lua +++ b/modules/doorlock/ox_doorlock/server.lua @@ -2,6 +2,10 @@ if GetResourceState('ox_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) local state = toggle if state then diff --git a/modules/doorlock/qb-doorlock/client.lua b/modules/doorlock/qb-doorlock/client.lua index ba8166e..11929e5 100644 --- a/modules/doorlock/qb-doorlock/client.lua +++ b/modules/doorlock/qb-doorlock/client.lua @@ -2,6 +2,8 @@ if GetResourceState('qb-doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() local closestDoor = exports["qb-doorlock"]:GetClosestDoor() if Table.CheckPopulated(closestDoor) then return closestDoor end diff --git a/modules/doorlock/qb-doorlock/server.lua b/modules/doorlock/qb-doorlock/server.lua index 3a48b0c..21648e3 100644 --- a/modules/doorlock/qb-doorlock/server.lua +++ b/modules/doorlock/qb-doorlock/server.lua @@ -2,6 +2,10 @@ if GetResourceState('qb-doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) TriggerClientEvent('qb-doorlock:client:setState', -1, 0, doorID, toggle, false, false, false) return true diff --git a/modules/doorlock/rcore_doorlock/client.lua b/modules/doorlock/rcore_doorlock/client.lua index 041307f..efb90be 100644 --- a/modules/doorlock/rcore_doorlock/client.lua +++ b/modules/doorlock/rcore_doorlock/client.lua @@ -2,6 +2,8 @@ if GetResourceState('rcore_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() local allDoors = exports.rcore_doorlock:getLoadedDoors() local pedCoords = GetEntityCoords(cache.ped) diff --git a/modules/doorlock/rcore_doorlock/server.lua b/modules/doorlock/rcore_doorlock/server.lua index 1af685e..9535aab 100644 --- a/modules/doorlock/rcore_doorlock/server.lua +++ b/modules/doorlock/rcore_doorlock/server.lua @@ -2,6 +2,10 @@ if GetResourceState('rcore_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) local state = toggle if state then diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index 31bdd58..9f0145c 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index f717a22..fabaf0e 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('es_extended') ~= 'started' then return end ESX = exports["es_extended"]:getSharedObject() @@ -171,12 +172,41 @@ Framework.GetPlayerPhone = function(src) return xPlayer.get("phone_number") end --- Framework.GetPlayerJob(src) --- Returns the job name, label, grade name, and grade level of the player. + +---Returns the job name, label, grade name, and grade level of the player. +---@param src number +---@return string | nil +---@return string | nil +---@return string | nil +---@return string | nil Framework.GetPlayerJob = function(src) local xPlayer = ESX.GetPlayerFromId(src) if not xPlayer then return end - return xPlayer.getJob().name, xPlayer.getJob().label, xPlayer.getJob().grade_label, xPlayer.getJob().grade + local job = xPlayer.getJob() + return job.name, job.label, job.grade_label, job.grade +end + +---Returns the players duty status. +---@param src number +---@return boolean +Framework.GetPlayerDuty = function(src) + local xPlayer = ESX.GetPlayerFromId(src) + if not xPlayer then return false end + local job = xPlayer.getJob() + if not job.onDuty then return false end + return true +end + +---Sets the players duty status. +---@param src number +---@param dutystatus boolean +---@return boolean +Framework.SetPlayerDuty = function(src, dutystatus) + local xPlayer = ESX.GetPlayerFromId(src) + if not xPlayer then return false end + local job = xPlayer.getJob() + if not job.onDuty then return false end + return xPlayer.setJob(job.name, job.grade, dutystatus) end -- Framework.GetPlayersByJob(jobname) @@ -202,14 +232,6 @@ Framework.SetPlayerJob = function(src, name, grade) return xPlayer.setJob(name, grade, true) end -Framework.ToggleDuty = function(src, status) - local xPlayer = ESX.GetPlayerFromId(src) - if not xPlayer then return end - local name = xPlayer.getJob().name - local grade = xPlayer.getJob().grade - xPlayer.setJob(name, grade, status) -end - -- Framework.AddAccountBalance(src, _type, amount) -- Adds the specified amount to the player's account balance of the specified type. Framework.AddAccountBalance = function(src, _type, amount) diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index e9e9a04..a3ed050 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-core') ~= 'started' then return end if GetResourceState('qbx_core') == 'started' then return end diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 631532a..8df05f2 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -1,10 +1,11 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qb-core') ~= 'started' then return end if GetResourceState('qbx_core') == 'started' then return end QBCore = exports['qb-core']:GetCoreObject() Framework = {} - +Framework.Shared = QBCore.Shared Framework.GetFrameworkName = function() return 'qb-core' end @@ -221,7 +222,9 @@ Framework.AddHunger = function(src, value) local playerData = player.PlayerData local newHunger = (playerData.metadata.hunger or 0) + value player.Functions.SetMetaData('hunger', Math.Clamp(newHunger, 0, 100)) + TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, playerData.metadata.thirst) --TriggerClientEvent('hud:client:UpdateStress', src, newStress) + return newHunger end @@ -234,6 +237,7 @@ Framework.AddThirst = function(src, value) local playerData = player.PlayerData local newThirst = (playerData.metadata.thirst or 0) + value player.Functions.SetMetaData('thirst', Math.Clamp(newThirst, 0, 100)) + TriggerClientEvent('hud:client:UpdateNeeds', src, playerData.metadata.hunger, newThirst) --TriggerClientEvent('hud:client:UpdateStress', src, newStress) return newThirst end @@ -307,6 +311,28 @@ Framework.GetPlayerJob = function(src) return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end +---Returns the players duty status. +---@param src number +---@return boolean | nil +Framework.GetPlayerDuty = function(src) + local player = QBCore.Functions.GetPlayer(src) + if not player then return end + local playerData = player.PlayerData + if not playerData.job.onduty then return false end + return true +end + +---This will toggle a players duty status +---@param src number +---@param status boolean +---@return nil +Framework.SetPlayerDuty = function(src, status) + local player = QBCore.Functions.GetPlayer(src) + if not player then return end + player.Functions.SetJobDuty(status) + TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) +end + -- Sets the player's job to the specified name and grade. ---@param src number ---@param name string @@ -318,18 +344,6 @@ Framework.SetPlayerJob = function(src, name, grade) return player.Functions.SetJob(name, grade) end ----This will toggle a players duty status ----@param src number ----@param status boolean ----@return nil -Framework.ToggleDuty = function(src, status) - local player = QBCore.Functions.GetPlayer(src) - if not player then return end - player.Functions.SetJobDuty(status) - TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) -end - - ---This will add money based on the type of account (money/bank) ---@param src number ---@param _type string @@ -401,8 +415,8 @@ Framework.SetMetadata = function(src, item, slot, metadata) end end end - player.Functions.RemoveItem(item, 1, itemSlot) - return player.Functions.AddItem(item, 1, freeSlot, metadata) + if not player.Functions.RemoveItem(item, 1, itemSlot) then return false end + return player.Functions.AddItem(item, 1, slot, metadata) end ---This will get all owned vehicles for the player @@ -449,4 +463,5 @@ end) Framework.Commands = {} Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...) QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...) -end \ No newline at end of file +end + diff --git a/modules/framework/qbx_core/client.lua b/modules/framework/qbx_core/client.lua index 9e7564a..a0da4bb 100644 --- a/modules/framework/qbx_core/client.lua +++ b/modules/framework/qbx_core/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qbx_core') ~= 'started' then return end QBox = exports.qbx_core diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index d9e48d0..94e30c4 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -1,13 +1,19 @@ +---@diagnostic disable: duplicate-set-field if GetResourceState('qbx_core') ~= 'started' then return end local QBox = exports.qbx_core Framework = {} +---Returns the name of the framework being used (if a supported framework). +---@return string Framework.GetFrameworkName = function() return 'qbx_core' end +---Returns the player date of birth. +---@param src number +---@return string Framework.GetPlayerDob = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -15,12 +21,15 @@ Framework.GetPlayerDob = function(src) return playerData.charinfo.birthdate end +---Returns a table of the jobs in the framework. +---@return table Framework.GetFrameworkJobs = function() return QBox.GetJobs() end --- Framework.GetPlayerIdentifier(src) --- Returns the citizen ID of the player. +---Returns the citizen ID of the player. +---@param src number +---@return string | boolean Framework.GetPlayerIdentifier = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -40,8 +49,9 @@ Framework.GetPlayers = function() return playerList end --- Framework.GetPlayerName(src) --- Returns the first and last name of the player. +---Returns the first and last name of the player. +---@param src number +---@return string | nil Framework.GetPlayerName = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -49,9 +59,11 @@ Framework.GetPlayerName = function(src) return playerData.charinfo.firstname, playerData.charinfo.lastname end --- Framework.GetItem(src, item, metadata) -- Returns a table of items matching the specified name and if passed metadata from the player's inventory. --- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} +---@param src number +---@param item string +---@param metadata table +---@return table Framework.GetItem = function(src, item, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -70,8 +82,11 @@ Framework.GetItem = function(src, item, metadata) return repackedTable end --- Framework.GetItemCount(src, item, metadata) --- Returns the count of items matching the specified name and if passed metadata from the player's inventory. +---Returns the count of items matching the specified name and if passed metadata from the player's inventory. +---@param src number +---@param item string +---@param metadata table +---@return number Framework.GetItemCount = function(src, item, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -85,7 +100,7 @@ Framework.GetItemCount = function(src, item, metadata) return count end ----comment +---Returns boolean if the player has the specified item in their inventory. ---@param src number ---@param item string ---@return boolean @@ -94,9 +109,9 @@ Framework.HasItem = function(src, item) return getCount > 0 end --- Framework.GetPlayerInventory(src) --- Returns the entire inventory of the player as a table. --- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} +---Returns the entire inventory of the player as a table. +---@param src number +---@return table Framework.GetPlayerInventory = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -113,8 +128,11 @@ Framework.GetPlayerInventory = function(src) return repackedTable end --- Framework.SetMetadata(src, metadata, value) --- Adds the specified metadata key and number value to the player's data. +---Adds the specified metadata key and number value to the player's data. +---@param src number +---@param metadata string +---@param value string +---@return boolean Framework.SetPlayerMetadata = function(src, metadata, value) local player = QBox:GetPlayer(src) if not player then return end @@ -122,8 +140,10 @@ Framework.SetPlayerMetadata = function(src, metadata, value) return true end --- Framework.GetMetadata(src, metadata) --- Gets the specified metadata key to the player's data. +---Gets the specified metadata key to the player's data. +---@param src number +---@param metadata string +---@return string | boolean | nil Framework.GetPlayerMetadata = function(src, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -131,8 +151,10 @@ Framework.GetPlayerMetadata = function(src, metadata) return playerData.metadata[metadata] or false end --- Framework.AddStress(src, value) --- Adds the specified value to the player's stress level and updates the client HUD. +---Adds the specified value to the player's stress level and updates the client HUD. +---@param src number +---@param value number +---@return number | nil Framework.AddStress = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -143,8 +165,10 @@ Framework.AddStress = function(src, value) return newStress end --- Framework.RemoveStress(src, value) --- Removes the specified value from the player's stress level and updates the client HUD. +---Removes the specified value from the player's stress level and updates the client HUD. +---@param src number +---@param value number +---@return number | nil Framework.RemoveStress = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -155,8 +179,10 @@ Framework.RemoveStress = function(src, value) return newStress end --- Framework.AddHunger(src, value) --- Adds the specified value from the player's hunger level. +---Adds the specified value from the player's hunger level. +---@param src number +---@param value number +---@return number | nil Framework.AddHunger = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -167,8 +193,10 @@ Framework.AddHunger = function(src, value) return newHunger end --- Framework.AddThirst(src, value) -- Adds the specified value from the player's thirst level. +---@param src number +---@param value number +---@return number | nil Framework.AddThirst = function(src, value) local player = QBox:GetPlayer(src) if not player then return end @@ -179,6 +207,9 @@ Framework.AddThirst = function(src, value) return newThirst end +---This will return the players hunger level. +---@param src number +---@return number | nil Framework.GetHunger = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -187,6 +218,9 @@ Framework.GetHunger = function(src) return newHunger end +---This will return the players thirst level. +---@param src number +---@return number Framework.GetThirst = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -195,8 +229,9 @@ Framework.GetThirst = function(src) return newThirst end --- Framework.GetPlayerPhone(src) --- Returns the phone number of the player. +---Returns the phone number of the player. +---@param src number +---@return string | nil Framework.GetPlayerPhone = function(src) local player = QBox:GetPlayer(src) if not player then return end @@ -204,13 +239,17 @@ Framework.GetPlayerPhone = function(src) return playerData.charinfo.phone end --- Framework.GetPlayerGang(src) --- Returns the gang name of the player. +---Returns the gang name of the player. +---@param src number +---@return string | nil Framework.GetPlayerGang = function(src) local player = QBox:GetPlayer(src).PlayerData return player.gang.name end +---This will return a table of all players with the specified job. +---@param job string +---@return table Framework.GetPlayersByJob = function(job) local playerList = {} local players = QBox:GetQBPlayers() @@ -222,30 +261,56 @@ Framework.GetPlayersByJob = function(job) return playerList end --- Framework.GetPlayerJob(src) --- Returns the job name, label, grade name, and grade level of the player. +---Returns the job name, label, grade name, and grade level of the player. +---@param src number +---@return string | string | string | number | nil +---@return string | string | string | number | nil +---@return string | string | string | number | nil +---@return string | string | string | number | nil Framework.GetPlayerJob = function(src) local player = QBox:GetPlayer(src).PlayerData + if not player then return end return player.job.name, player.job.label, player.job.grade.name, player.job.grade.level end --- Framework.SetPlayerJob(src, name, grade) --- Sets the player's job to the specified name and grade. +---Sets the player's job to the specified name and grade. +---@param src number +---@param name string +---@param grade string +---@return boolean | nil Framework.SetPlayerJob = function(src, name, grade) local player = QBox:GetPlayer(src) if not player then return end return player.Functions.SetJob(name, grade) end -Framework.ToggleDuty = function(src, status) +---This will toggle the duty status of the player. +---@param src number +---@param status boolean +Framework.SetPlayerDuty = function(src, status) local player = QBox:GetPlayer(src) if not player then return end local playerData = player.PlayerData QBox:SetJobDuty(playerData.citizenid, status) + TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) end --- Framework.AddAccountBalance(src, _type, amount) --- Adds the specified amount to the player's account balance of the specified type. +---Returns the players duty status. +---@param src number +---@return boolean | nil +Framework.GetPlayerDuty = function(src) + local player = QBox:GetPlayer(src) + if not player then return end + local playerData = player.PlayerData + if not playerData.job.onduty then return false end + return true +end + +---Adds the specified amount to the player's account balance of the specified type. +---@param src number +---@param _type string +---@param amount number +---@return boolean | nil Framework.AddAccountBalance = function(src, _type, amount) local player = QBox:GetPlayer(src) if not player then return end @@ -253,8 +318,11 @@ Framework.AddAccountBalance = function(src, _type, amount) return player.Functions.AddMoney(_type, amount) end --- Framework.RemoveAccountBalance(src, _type, amount) --- Removes the specified amount from the player's account balance of the specified type. +---Removes the specified amount from the player's account balance of the specified type. +---@param src number +---@param _type string +---@param amount number +---@return boolean | nil Framework.RemoveAccountBalance = function(src, _type, amount) local player = QBox:GetPlayer(src) if not player then return end @@ -262,8 +330,10 @@ Framework.RemoveAccountBalance = function(src, _type, amount) return player.Functions.RemoveMoney(_type, amount) end --- Framework.GetAccountBalance(src, _type) --- Returns the player's account balance of the specified type. +---Returns the player's account balance of the specified type. +---@param src number +---@param _type string +---@return number | nil Framework.GetAccountBalance = function(src, _type) local player = QBox:GetPlayer(src) if not player then return end @@ -272,8 +342,13 @@ Framework.GetAccountBalance = function(src, _type) return playerData.money[_type] end --- Framework.AddItem(src, item, amount, slot, metadata) --- Adds the specified item to the player's inventory. +---Adds the specified item to the player's inventory. +---@param src number +---@param item string +---@param amount number +---@param slot number +---@param metadata table +---@return boolean | nil Framework.AddItem = function(src, item, amount, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -281,8 +356,13 @@ Framework.AddItem = function(src, item, amount, slot, metadata) return player.Functions.AddItem(item, amount, slot, metadata) end --- Framework.RemoveItem(src, item, amount, slot, metadata) --- Removes the specified item from the player's inventory. +---Removes the specified item from the player's inventory. +---@param src number +---@param item string +---@param amount number +---@param slot number +---@param metadata table +---@return boolean | nil Framework.RemoveItem = function(src, item, amount, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -290,9 +370,12 @@ Framework.RemoveItem = function(src, item, amount, slot, metadata) return player.Functions.RemoveItem(item, amount, slot) end --- Framework.SetMetadata(src, item, slot, metadata) --- Sets the metadata for the specified item in the player's inventory. --- Notes, this is kinda a jank workaround. with the framework aside from updating the entire table theres not really a better way +---Sets the metadata for the specified item in the player's inventory. +-----@param src number +---@param item string +---@param slot number +---@param metadata table +---@return boolean | nil Framework.SetMetadata = function(src, item, slot, metadata) local player = QBox:GetPlayer(src) if not player then return end @@ -300,6 +383,9 @@ Framework.SetMetadata = function(src, item, slot, metadata) return player.Functions.AddItem(item, 1, slot, metadata) end +---Returns a table of owned vehicles for the player. format is {vehicle = vehicle, plate = plate} +---@param src number +---@return table Framework.GetOwnedVehicles = function(src) local citizenId = Framework.GetPlayerIdentifier(src) local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'") @@ -312,6 +398,19 @@ Framework.GetOwnedVehicles = function(src) return vehicles end +---Registers a usable item with a callback function. +---@param itemName string +---@param cb function +---@return function +Framework.RegisterUsableItem = function(itemName, cb) + local func = function(src, item, itemData) + itemData = itemData or item + itemData.metadata = itemData.metadata or itemData.info or {} + cb(src, itemData) + end + return QBox:CreateUseableItem(itemName, func) +end + RegisterNetEvent("QBCore:Server:OnPlayerLoaded", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerLoaded", src) @@ -325,15 +424,4 @@ end) AddEventHandler("playerDropped", function() local src = source TriggerEvent("community_bridge:Server:OnPlayerUnload", src) -end) - --- Framework.RegisterUsableItem(item, cb) --- Registers a usable item with a callback function. -Framework.RegisterUsableItem = function(itemName, cb) - local func = function(src, item, itemData) - itemData = itemData or item - itemData.metadata = itemData.metadata or itemData.info or {} - cb(src, itemData) - end - return QBox:CreateUseableItem(itemName, func) -end \ No newline at end of file +end) \ No newline at end of file diff --git a/modules/fuel/_defualts/client.lua b/modules/fuel/_defualts/client.lua index b453052..9663fd4 100644 --- a/modules/fuel/_defualts/client.lua +++ b/modules/fuel/_defualts/client.lua @@ -1,5 +1,11 @@ Fuel = Fuel or {} + +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return 'default' +end ---This will get the fuel level of the vehicle. ---@param vehicle number The vehicle entity ID. ---@return number fuel The fuel level of the vehicle. diff --git a/modules/fuel/bigDaddy-Fuel/client.lua b/modules/fuel/bigDaddy-Fuel/client.lua index f1f0a46..d2e7a92 100644 --- a/modules/fuel/bigDaddy-Fuel/client.lua +++ b/modules/fuel/bigDaddy-Fuel/client.lua @@ -2,15 +2,26 @@ local resourceName = "BigDaddy-Fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading BigDaddy-Fuel") ---if GetResourceState('BigDaddy-Fuel') ~= 'started' then return end Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['BigDaddy-Fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end exports['BigDaddy-Fuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/cdn-fuel/client.lua b/modules/fuel/cdn-fuel/client.lua index bb5b1d7..c9ae93a 100644 --- a/modules/fuel/cdn-fuel/client.lua +++ b/modules/fuel/cdn-fuel/client.lua @@ -1,15 +1,27 @@ local resourceName = "cdn-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end -----print("Fuel: Loading cdn-fuel") ---if GetResourceState('cdn-fuel') ~= 'started' then return end + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['cdn-fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['cdn-fuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/esx-sna-fuel/client.lua b/modules/fuel/esx-sna-fuel/client.lua index acfac8d..6c4588c 100644 --- a/modules/fuel/esx-sna-fuel/client.lua +++ b/modules/fuel/esx-sna-fuel/client.lua @@ -1,16 +1,28 @@ local resourceName = "esx-sna-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading esx-sna-fuel") ---if GetResourceState('esx-sna-fuel') ~= 'started' then return end + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['esx-sna-fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end exports['esx-sna-fuel']:SetFuel(vehicle, fuel) -end +end \ No newline at end of file diff --git a/modules/fuel/lc_fuel/client.lua b/modules/fuel/lc_fuel/client.lua index d455e9c..5df01b9 100644 --- a/modules/fuel/lc_fuel/client.lua +++ b/modules/fuel/lc_fuel/client.lua @@ -1,17 +1,28 @@ local resourceName = "lc_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading lc_fuel") -if GetResourceState('lc_fuel') ~= 'started' then return end + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["lc_fuel"]:GetFuel(vehicle) end - +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["lc_fuel"]:SetFuel(vehicle, fuel) -end +end \ No newline at end of file diff --git a/modules/fuel/legacyfuel/client.lua b/modules/fuel/legacyfuel/client.lua index d788982..1eb4e92 100644 --- a/modules/fuel/legacyfuel/client.lua +++ b/modules/fuel/legacyfuel/client.lua @@ -1,15 +1,27 @@ local resourceName = "LegacyFuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading LegacyFuel") Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['LegacyFuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['LegacyFuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/okokGasStation/client.lua b/modules/fuel/okokGasStation/client.lua index 147588f..8c5741b 100644 --- a/modules/fuel/okokGasStation/client.lua +++ b/modules/fuel/okokGasStation/client.lua @@ -1,14 +1,27 @@ local resourceName = "okokGasStation" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading okokGasStation") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['okokGasStation']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['okokGasStation']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/ox_fuel/client.lua b/modules/fuel/ox_fuel/client.lua index 730fe27..75da8d7 100644 --- a/modules/fuel/ox_fuel/client.lua +++ b/modules/fuel/ox_fuel/client.lua @@ -1,14 +1,27 @@ local resourceName = "ox_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading ox_fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return Entity(vehicle).state.fuel end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end local currentFuel = Entity(vehicle).state.fuel diff --git a/modules/fuel/ps-fuel/client.lua b/modules/fuel/ps-fuel/client.lua index 87ad695..310f484 100644 --- a/modules/fuel/ps-fuel/client.lua +++ b/modules/fuel/ps-fuel/client.lua @@ -1,14 +1,27 @@ local resourceName = "ps-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading ps-fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["ps-fuel"]:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports["ps-fuel"]:SetFuel(vehicle, fuel) diff --git a/modules/fuel/qs-fuelstations/client.lua b/modules/fuel/qs-fuelstations/client.lua index 40007f8..9a4f5d7 100644 --- a/modules/fuel/qs-fuelstations/client.lua +++ b/modules/fuel/qs-fuelstations/client.lua @@ -1,15 +1,28 @@ local resourceName = "qs-fuelstations" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading qs-fuelstations") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['qs-fuelstations']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['qs-fuelstations']:SetFuel(vehicle, fuel) -end +end \ No newline at end of file diff --git a/modules/fuel/renewed-Fuel/client.lua b/modules/fuel/renewed-Fuel/client.lua index 52cf8ac..ca6e225 100644 --- a/modules/fuel/renewed-Fuel/client.lua +++ b/modules/fuel/renewed-Fuel/client.lua @@ -1,14 +1,27 @@ local resourceName = "Renewed-Fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading Renewed-Fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['Renewed-Fuel']:GetFuel(vehicle) end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['Renewed-Fuel']:SetFuel(vehicle, fuel) diff --git a/modules/fuel/ti_fuel/client.lua b/modules/fuel/ti_fuel/client.lua index 08779a8..253081c 100644 --- a/modules/fuel/ti_fuel/client.lua +++ b/modules/fuel/ti_fuel/client.lua @@ -1,15 +1,28 @@ local resourceName = "ti_fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading ti_fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end local level, _ = exports["ti_fuel"]:getFuel(vehicle) return level end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['ti_fuel']:setFuel(vehicle, fuel, "RON91") diff --git a/modules/fuel/x-fuel/client.lua b/modules/fuel/x-fuel/client.lua index 0af0b38..6eeaba5 100644 --- a/modules/fuel/x-fuel/client.lua +++ b/modules/fuel/x-fuel/client.lua @@ -1,15 +1,28 @@ local resourceName = "x-fuel" local configValue = BridgeClientConfig.Fuel if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end ---print("Fuel: Loading x-fuel") + Fuel = Fuel or {} +---This will get the name of the Fuel being used (if a supported Fuel). +---@return string +Fuel.GetFuelName = function() + return resourceName +end + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end local level, _ = exports["x-fuel"]:getFuel(vehicle) return level end +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return exports['x-fuel']:SetFuel(vehicle, fuel) diff --git a/modules/housing/_defualts/client.lua b/modules/housing/_defualts/client.lua new file mode 100644 index 0000000..4e660db --- /dev/null +++ b/modules/housing/_defualts/client.lua @@ -0,0 +1 @@ +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/_defualts/server.lua b/modules/housing/_defualts/server.lua new file mode 100644 index 0000000..dcfb42b --- /dev/null +++ b/modules/housing/_defualts/server.lua @@ -0,0 +1,12 @@ +Housing = Housing or {} + +---This is an internal event, listen for 'community_bridge:Client:OnPlayerInside' instead. +---This event is triggered when a player enters or leaves a property. +---@param src number +---@param insideId string +RegisterNetEvent('community_bridge:Server:_OnPlayerInside', function(src, insideId) + local currentBucket = GetPlayerRoutingBucket(src) + local playerEntity = GetPlayerPed(src) + local playerCoords = GetEntityCoords(playerEntity) + TriggerEvent('community_bridge:Client:OnPlayerInside', src, insideId, currentBucket, playerCoords) +end) \ No newline at end of file diff --git a/modules/housing/bcs-housing/client.lua b/modules/housing/bcs-housing/client.lua new file mode 100644 index 0000000..d5d2396 --- /dev/null +++ b/modules/housing/bcs-housing/client.lua @@ -0,0 +1,11 @@ +if GetResourceState('bcs-housing') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('Housing:client:EnterHome', function(insideId) + TriggerServerEvent('community_bridge:Server:_OnPlayerInside', insideId) +end) + +RegisterNetEvent("Housing:client:DeleteFurnitures", function() + TriggerServerEvent('community_bridge:Server:_OnPlayerInside', false) +end) \ No newline at end of file diff --git a/modules/housing/bcs-housing/server.lua b/modules/housing/bcs-housing/server.lua new file mode 100644 index 0000000..f4263c0 --- /dev/null +++ b/modules/housing/bcs-housing/server.lua @@ -0,0 +1,3 @@ +if GetResourceState('bcs-housing') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/esx_property/client.lua b/modules/housing/esx_property/client.lua new file mode 100644 index 0000000..3d3238f --- /dev/null +++ b/modules/housing/esx_property/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('esx_property') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/esx_property/server.lua b/modules/housing/esx_property/server.lua new file mode 100644 index 0000000..5243ae7 --- /dev/null +++ b/modules/housing/esx_property/server.lua @@ -0,0 +1,13 @@ +if GetResourceState('esx_property') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('esx_property:enter', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) + +RegisterNetEvent('esx_property:leave', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) \ No newline at end of file diff --git a/modules/housing/ps-housing/client.lua b/modules/housing/ps-housing/client.lua new file mode 100644 index 0000000..a40ae1c --- /dev/null +++ b/modules/housing/ps-housing/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('ps-housing') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/ps-housing/server.lua b/modules/housing/ps-housing/server.lua new file mode 100644 index 0000000..d364c2e --- /dev/null +++ b/modules/housing/ps-housing/server.lua @@ -0,0 +1,13 @@ +if GetResourceState('ps-housing') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('ps-housing:server:enterProperty', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) + +RegisterNetEvent('ps-housing:server:leaveProperty', function(insideId) + local src = source + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) \ No newline at end of file diff --git a/modules/housing/qb-appartments/client.lua b/modules/housing/qb-appartments/client.lua new file mode 100644 index 0000000..5d6b7f8 --- /dev/null +++ b/modules/housing/qb-appartments/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('qb-appartments') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/qb-appartments/server.lua b/modules/housing/qb-appartments/server.lua new file mode 100644 index 0000000..6c5f6c5 --- /dev/null +++ b/modules/housing/qb-appartments/server.lua @@ -0,0 +1,9 @@ +if GetResourceState('qb-appartments') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('qb-apartments:server:SetInsideMeta', function(house, insideId, bool, isVisiting) + local src = source + insideId = bool and house .. '-' .. insideId or nil + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) \ No newline at end of file diff --git a/modules/housing/qb-houses/client.lua b/modules/housing/qb-houses/client.lua new file mode 100644 index 0000000..e1e61cf --- /dev/null +++ b/modules/housing/qb-houses/client.lua @@ -0,0 +1,3 @@ +if GetResourceState('qb-houses') ~= 'started' then return end + +Housing = Housing or {} \ No newline at end of file diff --git a/modules/housing/qb-houses/server.lua b/modules/housing/qb-houses/server.lua new file mode 100644 index 0000000..7fac010 --- /dev/null +++ b/modules/housing/qb-houses/server.lua @@ -0,0 +1,9 @@ +if GetResourceState('qb-houses') ~= 'started' then return end + +Housing = Housing or {} + +RegisterNetEvent('qb-houses:server:SetInsideMeta', function(insideId, bool) + local src = source + insideId = bool and insideId or nil + TriggerEvent('community_bridge:Server:_OnPlayerInside', src, insideId) +end) \ No newline at end of file diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index afd63b6..21991ad 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -26,4 +26,11 @@ end ---@return string Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.StripPNG = function(item) + if string.find(item, ".png") then + item = string.gsub(item, ".png", "") + end + return item end \ No newline at end of file diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index 87eb68c..2d42c54 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -83,4 +83,11 @@ end ---@return string Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.StripPNG = function(item) + if string.find(item, ".png") then + item = string.gsub(item, ".png", "") + end + return item end \ No newline at end of file diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index fc616b5..11be4c5 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -8,13 +8,14 @@ local codem = exports['codem-inventory'] ---@return table Inventory.GetItemInfo = function(item) local itemData = codem:GetItemList(item) + local image = itemData.image and Inventory.GetImagePath(itemData.image) or Inventory.GetImagePath(item) local repackedTable = { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", weight = itemData.weight or "0", description = itemData.description or "none", - image = itemData.image or Inventory.GetImagePath(item), + image = image, } return repackedTable or {} end @@ -43,6 +44,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("codem-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/codem-inventory/server.lua b/modules/inventory/codem-inventory/server.lua index 55d0b3b..cbf6847 100644 --- a/modules/inventory/codem-inventory/server.lua +++ b/modules/inventory/codem-inventory/server.lua @@ -86,6 +86,7 @@ Inventory.GetItemBySlot = function(src, slot) end Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("codem-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua index 21d4fac..2e9cce0 100644 --- a/modules/inventory/core_inventory/client.lua +++ b/modules/inventory/core_inventory/client.lua @@ -10,6 +10,7 @@ Inventory = Inventory or {} ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item)) local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index 1fbfaca..f4aa30d 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -8,6 +8,7 @@ local core = exports.core_inventory ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item)) local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index 7f1afdd..f7deebc 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -20,6 +20,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index 06b4f12..9c7cf01 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -43,6 +43,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index 7f86414..a7f8359 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -43,6 +43,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index 5605d56..4bc27d4 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -104,6 +104,7 @@ Inventory.SetMetadata = function(src, item, slot, metadata) end Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/ox_inventory/client.lua b/modules/inventory/ox_inventory/client.lua index 721f8ca..766c571 100644 --- a/modules/inventory/ox_inventory/client.lua +++ b/modules/inventory/ox_inventory/client.lua @@ -40,6 +40,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item)) local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index e16db1e..a195b31 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -16,6 +16,24 @@ Inventory.AddItem = function(src, item, count, slot, metadata) return ox_inventory:AddItem(src, item, count, metadata) end +Inventory.GetItemInfo = function(item) + local itemData = ox_inventory:Items(item) + if not itemData then return {} end + local repackedTable = { + name = itemData.name or "Missing Name", + label = itemData.label or "Missing Label", + stack = itemData.stack or "true", + weight = itemData.weight or "0", + description = itemData.description or "none", + image = string.format("nui://ox_inventory/web/images/%s", itemData.client + and itemData.client.image + or string.format("%s.png", item) + ), + } + return repackedTable +end +-- string.format("nui://ox_inventory/web/images/%s.png", item) + ---This will remove an item, and return true or false based on success ---@param src number ---@param item string @@ -148,6 +166,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item)) local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index 7e459e2..6d37dd6 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -22,6 +22,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index 3854241..ff95702 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -36,6 +36,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index 2507543..0818f4f 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -21,6 +21,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" @@ -35,7 +36,7 @@ Inventory.GetItemInfo = function(item) stack = itemData.unique, weight = itemData.weight, description = itemData.description, - image = Inventory.GetImagePath(itemData.name) + image = Inventory.GetImagePath(itemData.image or itemData.name) } return repackedTable end diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index 03b43ff..ba70836 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -40,10 +40,26 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo end +Inventory.GetItemInfo = function(item) + local itemData = Framework.Shared.Items[item] + if not itemData then return {} end + local repackedTable = { + name = itemData.name, + label = itemData.label, + stack = itemData.unique, + weight = itemData.weight, + description = itemData.description, + image = Inventory.GetImagePath(itemData.image or itemData.name) + } + return repackedTable +end + ---comment ---@param item string ---@return string Inventory.GetImagePath = function(item) + -- check if contains.png and remove it if it does + item = Inventory.StripPNG(item) local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index 99a9c8b..91a1671 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -39,6 +39,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index a3496d1..699917f 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -153,6 +153,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index 93183fd..5ddcee4 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -44,6 +44,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item)) local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item) diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 0456e1d..6219a5e 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -135,6 +135,7 @@ end ---@param item string ---@return string Inventory.GetImagePath = function(item) + item = Inventory.StripPNG(item) local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item)) local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item) diff --git a/modules/progressbar/qb-progressbar/client.lua b/modules/progressbar/qb-progressbar/client.lua index a98cf58..5540dce 100644 --- a/modules/progressbar/qb-progressbar/client.lua +++ b/modules/progressbar/qb-progressbar/client.lua @@ -44,15 +44,19 @@ end ---@param options table ---@param cb any ---@param qbFormat boolean ----@return nil +---@return success boolean function ProgressBar.Open(options, cb, qbFormat) if not exports['progressbar'] then return false end if not qbFormat then options = convertFromOx(options) end - - exports['progressbar']:Progress(options, cb) + local prom = promise.new() + exports['progressbar']:Progress(options, function(cancelled) + if cb then cb(not cancelled) end + prom:resolve(not cancelled) + end) + return Citizen.Await(prom) end