diff --git a/lib/client/scaleform.lua b/lib/client/scaleform.lua index 31763cd..1071b25 100644 --- a/lib/client/scaleform.lua +++ b/lib/client/scaleform.lua @@ -1,5 +1,6 @@ Scaleform = {} -local function SetupScaleform(scaleform, Buttons) + +function SetupScaleform(scaleform, Buttons) local scaleform = RequestScaleformMovie(scaleform) local timeout = 5000 while not HasScaleformMovieLoaded(scaleform) and timeout > 0 do @@ -46,8 +47,33 @@ function Scaleform.SetupInstructionalButtons(buttons) -- {type = "SET_BACKGROUND_COLOUR"}, } local scaleform = SetupScaleform("instructional_buttons", buttons) + return scaleform end + +local runningScaleform = nil +function Scaleform.Run(scaleform, onUpdate) + if runningScaleform then return end + runningScaleform = scaleform + CreateThread(function() + while runningScaleform do + DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0) + if onUpdate then + shouldQuit = onUpdate() + if shouldQuit then + Scaleform.Stop() + break + end + end + Wait(2) + end + end) +end + +function Scaleform.Stop() + runningScaleform = nil +end + exports("Scaleform", Scaleform) return Scaleform \ No newline at end of file diff --git a/lib/shared/callbacks.lua b/lib/shared/callbacks.lua index 79d36a3..02d27c5 100644 --- a/lib/shared/callbacks.lua +++ b/lib/shared/callbacks.lua @@ -113,7 +113,6 @@ function Callback.Trigger(name, func, ...) cbData[name] = nil end end) - print('Triggered') return Citizen.Await(p) end diff --git a/lib/shared/rebound_entities.lua b/lib/shared/rebound_entities.lua index 9ef9238..021aaf1 100644 --- a/lib/shared/rebound_entities.lua +++ b/lib/shared/rebound_entities.lua @@ -14,10 +14,9 @@ function ReboundEntities.RemoveFunction(id) registeredFunctions[id] = false end -local function FireFunctions(...) +function FireFunctions(...) for _, func in pairs(registeredFunctions) do - print(func) - if func then func(...) end + func(...) end end @@ -25,7 +24,6 @@ function ReboundEntities.Register(entityData) assert(entityData and entityData.position, "Invalid entity data") entityData.id = entityData.id or Ids.CreateUniqueId(Entities) entityData.isServer = isServer - entityData.id = tostring(entityData.id) setmetatable(entityData, { __tostring = function() return entityData.id end }) Entities[entityData.id] = entityData FireFunctions(entityData) @@ -97,11 +95,13 @@ function ReboundEntities.Create(entityData, src) return entity end + function ReboundEntities.SetCheckRestricted(entityData, cb) assert(type(cb) == "function", "Check restricted is not a function") entityData.restricted = cb end + function ReboundEntities.CheckRestricted(src, entityData) return entityData.restricted and entityData.restricted(tonumber(src), entityData) or false end @@ -115,6 +115,15 @@ function ReboundEntities.Delete(id) TriggerClientEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntity", -1, id) end +function ReboundEntities.DeleteMultiple(entityDatas) + local ids = {} + for _, data in pairs(entityDatas) do + Unregister(data.id) + table.insert(ids, data.id) + end + TriggerClientEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntities", -1, ids) +end + function ReboundEntities.CreateMultiple(entityDatas, src, restricted) local _entityDatas = {} for _, data in pairs(entityDatas) do @@ -218,7 +227,8 @@ function ReboundEntities.SpawnLoop(distanceToCheck, waitTime) while spawnLoopRunning do for _, entity in pairs(Entities) do local pos = GetEntityCoords(PlayerPedId()) - local dist = #(pos - entity.position) + local position = vector3(entity.position.x, entity.position.y, entity.position.z) + local dist = #(pos - position) if dist <= distanceToCheck and not entity.entity then entity.entity, entity.inRange = ReboundEntities.Spawn(entity) elseif dist > distanceToCheck and entity.entity then @@ -292,7 +302,7 @@ RegisterNetEvent(GetCurrentResourceName() .. ":client:CreateReboundEntities", fu end) RegisterNetEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntities", function(ids) - DeleteMultipleFromServer(ids) + ReboundEntities.DeleteMultipleClient(ids) end) RegisterNetEvent(GetCurrentResourceName() .. ":client:SetReboundSyncData", function(id, key, value) diff --git a/modules/input/_qb-input.lua b/modules/input/_qb-input.lua index 43809d0..a72dc2e 100644 --- a/modules/input/_qb-input.lua +++ b/modules/input/_qb-input.lua @@ -54,14 +54,32 @@ function OxToQBInput(data) end function OpenInput(title, data, isQBFormat, submitText) - print("Opening input", json.encode(data)) local input = data.inputs if not isQBFormat then input = OxToQBInput(data) end - return exports['qb-input']:ShowInput({ + local returnData = exports['qb-input']:ShowInput({ header = title, submitText = submitText or "Submit", inputs = input }) + if not returnData then return end + if returnData[1] then return returnData end + --converting to standard format (ox) + local convertedData = {} + if isQBFormat then + for i, v in pairs(input) do + for k, j in pairs(returnData) do + if k == v.text then + convertedData[tonumber(i)] = j + end + end + end + return convertedData + end + + for i, v in pairs(returnData) do + convertedData[tonumber(i)] = v + end + return convertedData end \ No newline at end of file diff --git a/modules/inventory/core_inventory/client.lua b/modules/inventory/core_inventory/client.lua deleted file mode 100644 index 124acd1..0000000 --- a/modules/inventory/core_inventory/client.lua +++ /dev/null @@ -1,7 +0,0 @@ -if GetResourceState('core_inventory') ~= 'started' then return end - -Inventory = Inventory or {} - -Inventory.TestFunction = function(item) - return 'test funct client inv' -end \ No newline at end of file diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua deleted file mode 100644 index bf8e186..0000000 --- a/modules/inventory/core_inventory/server.lua +++ /dev/null @@ -1,7 +0,0 @@ -if GetResourceState('core_inventory') ~= 'started' then return end - -Inventory = Inventory or {} - -Inventory.TestFunction = function(item) - return 'test funct server inv' -end \ No newline at end of file diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index 41225eb..ff40531 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -22,4 +22,16 @@ Inventory.GetItemBySlot = function(src, slot) local slotData = jpr:GetItemBySlot(src, slot) if not slotData then return {} end return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description } +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index a281302..4b35b94 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -98,4 +98,16 @@ Inventory.GetImagePath = function(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" +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index a747948..d3d2184 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -35,3 +35,15 @@ Inventory.RemoveItem = function(src, item, amount, slot, metadata) TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata}) return exports['ps-inventory']:RemoveItem(src, item, amount, slot, 'community_bridge') end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true +end \ No newline at end of file diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index a5ddf5a..afcd323 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -5,8 +5,7 @@ local qbInventory = exports['qb-inventory'] Inventory = Inventory or {} local function getInventoryNewVersion() - local version = GetResourceMetadata("qb-inventory", "version", 0) - if version and tonumber(version) < 2.0 then + if tonumber(string.sub(GetResourceMetadata("qb-inventory", "version", 0), 1, 1)) >= 2 then return true else return false @@ -42,6 +41,33 @@ Inventory.GetItemBySlot = function(src, slot) } end +Inventory.UpdatePlate = function(oldplate, newplate) + local newVersion = getInventoryNewVersion() + if newVersion then + local gloveboxInv = exports['qb-inventory']:GetInventory('glovebox-'..oldplate) or {slots = 5, maxweight = 10000, items = {}} + local storedGloveBox = Bridge.Tables.DeepClone(gloveboxInv, nil, nil) + local trunkInv = exports['qb-inventory']:GetInventory('trunk-'..oldplate) or {slots = 5, maxweight = 10000, items = {}} + local storedTrunk = Bridge.Tables.DeepClone(trunkInv, nil, nil) + exports['qb-inventory']:ClearStash('glovebox-'..oldplate) + exports['qb-inventory']:ClearStash('trunk-'..oldplate) + exports['qb-inventory']:CreateInventory('glovebox-'..newplate, {label = 'glovebox-'..newplate, slots = storedGloveBox.slots, maxweight = storedGloveBox.maxweight}) + exports['qb-inventory']:SetInventory('glovebox-'..newplate, storedGloveBox.items, "Community Bridge Moving Items In GloveBox") + exports['qb-inventory']:CreateInventory('trunk-'..newplate, {label = 'trunk-'..newplate, slots = storedTrunk.slots, maxweight = storedTrunk.maxweight}) + exports['qb-inventory']:SetInventory('trunk-'..newplate, storedTrunk.items, "Community Bridge Moving Items In Trunk") + return true + else + local queries = { + 'UPDATE inventory_glovebox SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE inventory_trunk SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + end + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true +end + Inventory.AddItem = function(src, item, amount, slot, metadata) TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add') TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata}) diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index d8aecb9..f42b0a1 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -87,4 +87,16 @@ Inventory.GetImagePath = function(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" +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE inventory_trunk SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE inventory_glovebox SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index 8a0a914..48e1bd6 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -75,4 +75,16 @@ Inventory.GetImagePath = function(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) return imagePath or "https://avatars.githubusercontent.com/u/47620135" +end + +Inventory.UpdatePlate = function(oldplate, newplate) + local queries = { + 'UPDATE tgiann_inventory_trunkitems SET plate = @newplate WHERE plate = @oldplate', + 'UPDATE tgiann_inventory_gloveboxitems SET plate = @newplate WHERE plate = @oldplate', + } + local values = { newplate = newplate, oldplate = oldplate } + MySQL.transaction.await(queries, values) + if GetResourceState('jg-mechanic') ~= 'started' then return true end + exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) + return true end \ No newline at end of file diff --git a/modules/menu/_oxlib.lua b/modules/menu/_oxlib.lua index a21207a..991d31c 100644 --- a/modules/menu/_oxlib.lua +++ b/modules/menu/_oxlib.lua @@ -47,9 +47,7 @@ OpenMenu = function(id, data, useQBinput) if useQBinput then data = QBToOxMenu(id, data) end - if not Menus[id] then - lib.registerContext(data) - end + lib.registerContext(data) lib.showContext(id) return data end diff --git a/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua b/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua index 7b17541..31230ac 100644 --- a/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua +++ b/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua @@ -2,7 +2,7 @@ if GetResourceState('MrNewbVehicleKeys') ~= 'started' then return end VehicleKey = VehicleKey or {} VehicleKey.GiveKeys = function(vehicle, plate) - if not DoesEntityExist(vehicle) then return false end + if not DoesEntityExist(vehicle) and not plate then return false end return exports.MrNewbVehicleKeys:GiveKeys(vehicle) end diff --git a/modules/vehicleKey/MrNewbVehicleKeys/server/server.lua b/modules/vehicleKey/MrNewbVehicleKeys/server/server.lua index f8d74ae..32f50ba 100644 --- a/modules/vehicleKey/MrNewbVehicleKeys/server/server.lua +++ b/modules/vehicleKey/MrNewbVehicleKeys/server/server.lua @@ -2,9 +2,19 @@ if GetResourceState('MrNewbVehicleKeys') ~= 'started' then return end VehicleKey = VehicleKey or {} VehicleKey.GiveKeys = function(src, vehicle, plate) - --wip + if vehicle then + local netId = NetworkGetNetworkIdFromEntity(vehicle) + return exports.MrNewbVehicleKeys:GiveKeys(src, netId) + elseif plate then + return exports.MrNewbVehicleKeys:GiveKeysByPlate(src, plate) + end end VehicleKey.RemoveKeys = function(src, vehicle, plate) - -- wip + if vehicle then + local netId = NetworkGetNetworkIdFromEntity(vehicle) + return exports.MrNewbVehicleKeys:RemoveKeys(src, netId) + elseif plate then + return exports.MrNewbVehicleKeys:RemoveKeysByPlate(src, plate) + end end \ No newline at end of file diff --git a/modules/vehicleKey/qb-vehiclekeys/client/client.lua b/modules/vehicleKey/qb-vehiclekeys/client/client.lua index fda29d8..e27b7f2 100644 --- a/modules/vehicleKey/qb-vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qb-vehiclekeys/client/client.lua @@ -3,9 +3,12 @@ if GetResourceState('qbx_vehiclekeys') == 'started' then return end VehicleKey = VehicleKey or {} VehicleKey.GiveKeys = function(vehicle, plate) + if plate == nil and vehicle and DoesEntityExist(vehicle) then + plate = GetVehicleNumberPlateText(vehicle) + end TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) end VehicleKey.RemoveKeys = function(vehicle, plate) - return true + TriggerEvent('qb-vehiclekeys:client:RemoveKeys', plate) end \ No newline at end of file diff --git a/modules/vehicleKey/qb-vehiclekeys/server/server.lua b/modules/vehicleKey/qb-vehiclekeys/server/server.lua index 6f07ac6..4709d37 100644 --- a/modules/vehicleKey/qb-vehiclekeys/server/server.lua +++ b/modules/vehicleKey/qb-vehiclekeys/server/server.lua @@ -3,9 +3,13 @@ if GetResourceState('qbx_vehiclekeys') == 'started' then return end VehicleKey = VehicleKey or {} VehicleKey.GiveKeys = function(src, vehicle, plate) - --wip + if plate then + return exports["qb-vehiclekeys"]:GiveKeys(src, plate) + end end VehicleKey.RemoveKeys = function(src, vehicle, plate) - -- wip + if plate then + return exports["qb-vehiclekeys"]:RemoveKeys(src, plate) + end end \ No newline at end of file