Moon Warehouse is a feature-rich warehouse system designed for QBCore, a popular framework for FiveM servers. This script enhances the gameplay experience by introducing the concept of warehouses, where players can store their items and manage their inventory efficiently.
- -# Features - -1) 16 PreBuilt Warehouses: Moon Warehouse comes with 16 pre-built warehouse locations, making it easy for players to choose a storage facility that suits their needs. - -2) Lease System: Players can own a warehouse for a period of 7 days. After this period, they must renew their lease to continue using the warehouse. - -3) Automatic Lease Expiry: If players fail to renew their lease, the script will automatically delete the warehouse, ensuring the map isn't cluttered with abandoned warehouses. - -4) Warehouse Upgrades: Players have the option to upgrade their warehouse stash capacity, allowing them to store up to 5000 kilograms of items. They can also expand their warehouse slots, providing space for up to 110 items. - -5) Easy Warehouse Addition: Adding a new warehouse is hassle-free. Simply add coordinates in the configuration file, and the script will automatically execute the SQL necessary to create it. - -6) Warehouse Removal: Removing a warehouse is just as straightforward. Delete the coordinates from the configuration, and the warehouse will be removed from the map. - -7) Shared Stashes: Warehouses have shared stashes, meaning that if a player forgets to renew their lease and their warehouse is deleted, a new owner can access, remove, and use the items left behind by the previous owner. - -8) Admin Management: Administrators have the power to manage warehouses by using the /pullwarehousestash [warehouseid] command to access the contents of a specific warehouse. - -9) Customization: You can easily customize the default price, stash size, and stash slots through SQL to fit the needs of your server. - -# Dependencies - -ox_lib: Moon Warehouse relies on the ox_lib library. -# Installation - -Execute the SQL query below to set up the necessary database table: -```sql -CREATE TABLE `warehouses` ( - `location` INT(11) NOT NULL, - `owned` INT(11) NULL DEFAULT NULL, - `owner` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci', - `stashsize` INT(11) NULL DEFAULT NULL, - `slots` INT(11) NULL DEFAULT NULL, - `price` INT(11) NULL DEFAULT NULL, - `date_purchased` DATE NULL DEFAULT NULL, - `passwordset` INT(11) NULL DEFAULT '0', - `password` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci', - PRIMARY KEY (`location`) USING BTREE -) -COLLATE='utf8mb3_general_ci' -ENGINE=InnoDB -; -``` - -If Upgrading to 1.2.0 then execute this -```sql -ALTER TABLE warehouses ADD COLUMN `passwordset` INT DEFAULT '0'; -ALTER TABLE warehouses ADD COLUMN `password` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci'; -``` -ENGINE=InnoDB; -``` -That's it! Moon Warehouse is now ready to elevate the storage and inventory management experience for players on your FiveM server. - -Enjoy the script and provide feedback on the Script Support Discord if needed. -Discord - https://discord.gg/n9eSC4Zb diff --git a/resources/[inventory]/omi-warehouse/client/client.lua b/resources/[inventory]/omi-warehouse/client/client.lua deleted file mode 100644 index da20edb50..000000000 --- a/resources/[inventory]/omi-warehouse/client/client.lua +++ /dev/null @@ -1,586 +0,0 @@ -local QBCore = exports["qb-core"]:GetCoreObject() -Targets = {} - -local function despawntargets() - for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end -end - -RegisterNetEvent("moon-warehouse:client:openmenu", function(meow) - DisablePurchase = false - DisableOwnerMenu = true - DisablePoliceRaid = true - local Player = QBCore.Functions.GetPlayerData() - if Player.job.type == "leo" then DisablePoliceRaid = false end - QBCore.Functions.TriggerCallback('moon-warehouse:server:warehousepurchased', function(result) - if not result then - DisablePurchase = false - DisableOwnerMenu = true - else - DisablePurchase = true - end - end, meow) - - QBCore.Functions.TriggerCallback('moon-warehouse:server:isowner', function(result) - local CitizenID = QBCore.Functions.GetPlayerData().citizenid - if result then - DisableOwnerMenu = false - else - DisableOwnerMenu = true - end - end, meow) - - Wait(400) - - lib.registerContext({ - id = 'warehouse_menu', - title = 'Lager Interaktion', - options = { - { - icon = "check", - title = 'Lager verwalten', - disabled = DisableOwnerMenu, - arrow = false, -- puts arrow to the right - onSelect = function() - lib.registerContext({ - id = 'warehouse_owner_menu', - title = 'Lager Interaktion', - options = { - { - icon = "hand", - title = 'Lager öffnen', - arrow = false, -- puts arrow to the right - onSelect = function() - TriggerEvent("moon-warehouse:client:openwarehousestash", meow) - end - }, - { - icon = "arrows-up-to-line", - title = "Lager upgraden", - arrow = false, -- puts arrow to the right - onSelect = function() - lib.registerContext({ - id = 'warehouse_upgrade_menu', - title = 'Lagermodernisierung', - options = { - { - icon = "arrows-up-to-line", - title = 'Lager Plätze ausbauen', - arrow = false, - onSelect = function() - TriggerEvent("moon-warehouse:client:upgradewarehousesize", meow) - end - }, - { - icon = "arrows-up-to-line", - title = 'Lagerplätze erhöhen', - arrow = false, - onSelect = function() - TriggerEvent("moon-warehouse:client:upgradewarehouseslots", meow) - end - }, - { - icon = "backward", - title = "Zurück", - arrow = false, -- puts arrow to the right - onSelect = function() - TriggerEvent("moon-warehouse:client:openmenu", meow) - end, - }, - } - }) - lib.showContext('warehouse_upgrade_menu') - end, - }, - { - icon = "arrows-up-to-line", - title = 'Lagerpasswort zurücksetzen', - arrow = false, - onSelect = function() - TriggerEvent("moon-warehouse:client:resetpassword", meow) - end - }, - { - icon = "xmark", - title = "Lager verkaufen", - arrow = false, -- puts arrow to the right - onSelect = function() - TriggerEvent("moon-warehouse:client:sellwarehouse", {location = meow}) - end, - }, - { - icon = "clock", - title = 'Lager erneuern', - arrow = false, - onSelect = function() - TriggerEvent("moon-warehouse:client:renewwarehouse", meow) - end - }, - { - icon = "clock", - title = 'Lager Ablaufdatum prüfen', - arrow = false, - onSelect = function() - TriggerEvent("moon-warehouse:client:checkwarehouse", meow) - end - }, - { - icon = "backward", - title = "zurück", - arrow = false, -- puts arrow to the right - onSelect = function() - TriggerEvent("moon-warehouse:client:openmenu", meow) - end, - }, - } - }) - lib.showContext('warehouse_owner_menu') - end - }, - { - icon = "dollar-sign", - title = 'Lager kaufen', - disabled = DisablePurchase, - arrow = false, -- puts arrow to the right - onSelect = function() - TriggerEvent("moon-warehouse:client:openbuyingcontext", meow) - end, - }, - { - icon = "dollar-sign", - title = 'Lager mit Passwort öffnen', - arrow = false, -- puts arrow to the right - onSelect = function() - TriggerEvent("moon-warehouse:client:openwithpassword", meow) - end, - }, - { - icon = "dollar-sign", - title = 'Lager durchsuchen', - disabled = DisablePoliceRaid, - arrow = false, -- puts arrow to the right - onSelect = function() - local HasItem = exports['qb-inventory']:HasItem("police_stormram") - if not HasItem then QBCore.Functions.Notify("You Dont have ".. QBCore.Shared.Items["police_stormram"].label .." To raid this warehouse", "primary", 2500) return end - TriggerEvent('animations:client:EmoteCommandStart', {"knock2"}) - local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'}) - if success then - TriggerEvent('animations:client:EmoteCommandStart', {"c"}) - TriggerEvent("moon-warehouse:client:openwarehousestash", meow) - else - TriggerEvent('animations:client:EmoteCommandStart', {"c"}) - QBCore.Functions.Notify("You Failed to Raid", "primary", 2500) - end - end, - }, - { - icon = "xmark", - title = "Menü schließen", - arrow = false, -- puts arrow to the right - onSelect = function() - lib.hideContext() - end, - }, - } - }) - lib.showContext('warehouse_menu') -end) - -RegisterNetEvent("moon-warehouse:client:openwithpassword", function(id) - local warehouseid = id - QBCore.Functions.TriggerCallback('moon-warehouse:server:ispwdset', function(result) - if result then - isPwdSet = true - else - isPwdSet = false - end - Wait(100) - if isPwdSet then - local input = lib.inputDialog('Enter Password for Warehouse #'..warehouseid, { - { type = 'input', label = 'Enter Password', password = true, disabled = false }, - }) - if input ~= nil then - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - if result.password == input[1] then - local stashname = "warehouse"..warehouseid.."_moon" - TriggerEvent("inventory:client:SetCurrentStash", stashname) - TriggerServerEvent("inventory:server:OpenInventory", "stash", stashname, - { maxweight = result.stashsize, slots = result.slots }) - else - QBCore.Functions.Notify("Wrong Password", "error", 3000) - end - end, warehouseid) - else - QBCore.Functions.Notify("You Cancelled the Process", "error", 2500) - end - elseif not isPwdSet then - QBCore.Functions.Notify("Owner Did not Set A Password Yet", "error", 2500) - end - end, warehouseid) -end) - -RegisterNetEvent("moon-warehouse:client:resetpassword", function(id) - local input = lib.inputDialog('Set Password for Warehouse #'..id, { - { type = 'input', label = 'Enter Password', password = true, disabled = false }, - }) - if input ~= nil then - TriggerEvent("moon-warehouse:client:client:updatepassword", { location = id, password = input[1]}) - else - QBCore.Functions.Notify("You Cancelled the Process", "error", 2500) - end -end) - -RegisterNetEvent("moon-warehouse:client:openwarehousestash", function(id) - local warehouseid = id - if Config.inventory == "qb" then - QBCore.Functions.TriggerCallback('moon-warehouse:server:ispwdset', function(result) - if result then - isPwdSet = true - else - isPwdSet = false - end - Wait(100) - if isPwdSet then - local input = lib.inputDialog('Enter Password for Warehouse #'..warehouseid, { - { type = 'input', label = 'Enter Password', password = true, disabled = false }, - }) - if input ~= nil then - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - if result.password == input[1] then - local stashname = "warehouse"..warehouseid.."_moon" - TriggerEvent("inventory:client:SetCurrentStash", stashname) - TriggerServerEvent("inventory:server:OpenInventory", "stash", stashname, - { maxweight = result.stashsize, slots = result.slots }) - else - QBCore.Functions.Notify("Wrong Password", "error", 3000) - end - end, warehouseid) - else - QBCore.Functions.Notify("You Cancelled the Process", "error", 2500) - end - elseif not isPwdSet then - local input = lib.inputDialog('Set Password for Warehouse #'..warehouseid, { - { type = 'input', label = 'Enter Password', password = true, disabled = false }, - }) - if input ~= nil then - TriggerEvent("moon-warehouse:client:client:updatepassword", { location = warehouseid, password = input[1]}) - else - QBCore.Functions.Notify("You Cancelled the Process", "error", 2500) - end - end - end, warehouseid) - elseif Config.inventory == "ox" then - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - local stashname = "warehouse"..warehouseid.."_moon" - TriggerServerEvent('moon:warehouse:server:oxinventorystash', warehouseid, stashname, result.stashsize, result.slots) - end, warehouseid) - end -end) - -RegisterNetEvent('moon-warehouse:client:openstash', function(id) - exports.ox_inventory:openInventory('stash', id) -end) - -RegisterNetEvent("moon-warehouse:client:checkwarehouse", function(id) - local warehouseid = id - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - local date = result.date_purchased / 1000 - TriggerServerEvent("moon-warehouse:server:checkwarehouse", warehouseid, date) - end, warehouseid) -end) - -RegisterNetEvent("moon-warehouse:client:renewwarehouse", function(id) - local warehouseid = id - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - local renewwarehouse = lib.alertDialog({ - header = 'Renew Warehouse', - content = 'Your Renewal Will Cost $'.. result.price.. ', Do you Want Renew?', - centered = true, - cancel = true - }) - if renewwarehouse == "cancel" then QBCore.Functions.Notify("You Cancelled the Renwal of your Warehouse", "error", 3500) return end - local date = result.date_purchased / 1000 - TriggerServerEvent("moon-warehouse:server:renewwarehouse", warehouseid, result.price, date) - end, warehouseid) -end) - -RegisterNetEvent("moon-warehouse:client:upgradewarehouseslots", function(meow) - local warehouseid = meow - local currentPos = GetEntityCoords(PlayerPedId()) - local locationInfo = getStreetandZone(currentPos) - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - local requiredSlotsOptions = {} - - if result.slots == 50 then - requiredSlotsOptions = { - { label = "+20 Slots", value = 20 }, - } - elseif result.slots == 70 then - requiredSlotsOptions = { - { label = "+40 Slots", value = 40 }, - } - elseif result.slots == 110 then - requiredSlotsOptions = { - { label = "+60 Slots", value = 60 }, - } - elseif result.slots == 170 then - QBCore.Functions.Notify("Can't Upgrade More", "error", 5200) - return - end - - local input = lib.inputDialog('Upgrade Warehouse #'..warehouseid, { - { type = 'input', label = 'Warehouse Location', default = locationInfo.." Warehouse#"..warehouseid, disabled = true }, - { type = 'input', label = 'Default Stash Slots', default = result.slots, disabled = true, min = 1, max = 7 }, - { type = 'select', label = 'Required Stash Slots', options = requiredSlotsOptions, disabled = false }, - }) - - if input ~= nil then - TriggerEvent("moon-warehouse:client:client:upgradewarehouseslots", { location = warehouseid, slotsinc = input[3]}) - else - QBCore.Functions.Notify("You Cancelled the Process", "error", 2500) - end - end, warehouseid) -end) - -RegisterNetEvent("moon-warehouse:client:upgradewarehousesize", function(meow) - local warehouseid = meow - local currentPos = GetEntityCoords(PlayerPedId()) - local locationInfo = getStreetandZone(currentPos) - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - local requiredSizeOptions = {} - - if result.stashsize == 3000 * 1000 then - requiredSizeOptions = { - { label = "+500 Kg", value = 500 }, - } - elseif result.stashsize == 3500 * 1000 then - requiredSizeOptions = { - { label = "+1000 Kg", value = 1000 }, - } - elseif result.stashsize == 4500 * 1000 then - requiredSizeOptions = { - { label = "+1500 Kg", value = 1500 }, - } - elseif result.stashsize == 6000 * 1000 then - QBCore.Functions.Notify("Can't Upgrade More", "error", 5200) - return - end - - local input = lib.inputDialog('Upgrade Warehouse #'..warehouseid, { - { type = 'input', label = 'Warehouse Location', default = locationInfo.." Warehouse#"..warehouseid, disabled = true }, - { type = 'input', label = 'Default Stash Size [Kg]', default = result.stashsize / 1000, disabled = true, min = 1, max = 7 }, - { type = 'select', label = 'Required Stash Size', options = requiredSizeOptions, disabled = false }, - }) - - if input ~= nil then - TriggerEvent("moon-warehouse:client:client:upgradewarehousesize", {location = warehouseid, sizeinc = input[3]}) - else - QBCore.Functions.Notify("Your Cancelled the Process", "error", 2500) - end - end, warehouseid) -end) - -RegisterNetEvent('moon-warehouse:client:client:upgradewarehouseslots', function(data) - local warehouseid = data.location - local slots = data.slotsinc - local CitizenID = QBCore.Functions.GetPlayerData().citizenid - canUpgrade = false - Wait(5) - QBCore.Functions.TriggerCallback('moon-warehouse:server:isowner', function(result) - if result then - canUpgrade = true - else - QBCore.Functions.Notify("You Dont Own This Warehouse", 'error', 7500) - canUpgrade = false - end - end, warehouseid) - Wait(400) - if canUpgrade then - TriggerServerEvent('moon-warehouse:server:Upgradewarehouseslots', warehouseid, CitizenID, slots) - else - QBCore.Functions.Notify("Cannot Sale the Ware House", 'error', 7500) - end -end) - -RegisterNetEvent('moon-warehouse:client:client:updatepassword', function(data) - local warehouseid = data.location - local password = data.password - local CitizenID = QBCore.Functions.GetPlayerData().citizenid - ispwdset = false - Wait(5) - QBCore.Functions.TriggerCallback('moon-warehouse:server:isowner', function(result) - if result then - ispwdset = true - else - QBCore.Functions.Notify("You Dont Own This Warehouse", 'error', 7500) - ispwdset = false - end - end, warehouseid) - Wait(400) - if ispwdset then - TriggerServerEvent('moon-warehouse:server:updatepassword', warehouseid, CitizenID, password) - else - QBCore.Functions.Notify("Cannot Sale the Ware House", 'error', 7500) - end -end) - -RegisterNetEvent('moon-warehouse:client:client:upgradewarehousesize', function(data) - local warehouseid = data.location - local size = data.sizeinc - local CitizenID = QBCore.Functions.GetPlayerData().citizenid - canUpgrade = false - Wait(5) - QBCore.Functions.TriggerCallback('moon-warehouse:server:isowner', function(result) - if result then - canUpgrade = true - else - QBCore.Functions.Notify("You Dont Own This Warehouse", 'error', 7500) - canUpgrade = false - end - end, warehouseid) - Wait(400) - if canUpgrade then - TriggerServerEvent('moon-warehouse:server:upgradewarehousesize', warehouseid, CitizenID, size) - else - QBCore.Functions.Notify("Cannot Sale the Ware House", 'error', 7500) - end -end) - -RegisterNetEvent("moon-warehouse:client:openbuyingcontext", function(meow) - local warehouseid = meow - local currentPos = GetEntityCoords(PlayerPedId()) - local locationInfo = getStreetandZone(currentPos) - local Player = QBCore.Functions.GetPlayerData() - QBCore.Functions.TriggerCallback('moon-warehouse:server:getdetails', function(result) - local input = lib.inputDialog('Buy Warehouse #'..warehouseid, { - {type = 'input', label = 'Warehouse Location', default = locationInfo.." Warehouse#"..warehouseid, disabled = true}, - {type = 'input', label = 'Price', default = result.price, disabled = true, min = 1, max = 7}, - {type = 'input', label = 'Stash Size', default = result.stashsize / 1000 .. " Kg", disabled = true, min = 1, max = 7}, - {type = 'input', label = 'CitizenID', default = Player.citizenid, disabled = true, min = 1, max = 7}, - {type = 'input', label = 'Full Name', default = Player.charinfo.firstname.. " " .. Player.charinfo.lastname, disabled = true, min = 1, max = 7}, - {type = 'input', label = 'Birthdate', default = Player.charinfo.birthdate, disabled = true, min = 1, max = 7}, - }) - if input ~= nil then - TriggerEvent("moon-warehouse:client:client:purchasewarehouse", {location = warehouseid, price = result.price}) - else - QBCore.Functions.Notify("Your Cancelled the Process", "error", 2500) - end - end, warehouseid) -end) - -RegisterNetEvent('moon-warehouse:client:client:purchasewarehouse', function(data) - local warehouseid = data.location - local price = data.price - local CitizenID = QBCore.Functions.GetPlayerData().citizenid - CanOpen = false - Wait(5) - QBCore.Functions.TriggerCallback('moon-warehouse:server:warehousepurchased', function(result) - if result then - IsOwned = true - else - IsOwned = false - end - end, warehouseid) - Wait(400) - if not IsOwned then - TriggerServerEvent('moon-warehouse:server:buyWareHouse', warehouseid, CitizenID, price) - elseif IsOwned then - QBCore.Functions.Notify("Warehouse Already Owned", 'error', 7500) - end -end) - -RegisterNetEvent('moon-warehouse:client:sellwarehouse', function(data) - local sellwarehousealert = lib.alertDialog({ - header = 'Sell Warehouse', - content = 'Your Upgradation Would be Reset, Do you Want To Still Sell the warehouse?', - centered = true, - cancel = true - }) - if sellwarehousealert == "cancel" then QBCore.Functions.Notify("You Cancelled the Sale of your Warehouse", "error", 3500) return end - local warehouseid = data.location - local CitizenID = QBCore.Functions.GetPlayerData().citizenid - CanSell = false - Wait(5) - QBCore.Functions.TriggerCallback('moon-warehouse:server:isowner', function(result) - if result then - CanSell = true - else - QBCore.Functions.Notify("You Dont Own This Warehouse", 'error', 7500) - CanSell = false - end - end, warehouseid) - Wait(400) - if CanSell then - TriggerServerEvent('moon-warehouse:server:sellwarehouse', warehouseid) - else - QBCore.Functions.Notify("Cannot Sale the Ware House", 'error', 7500) - end -end) - -RegisterNetEvent("moon-warehouse:client:pullstash", function(id) - local warehouseid = id - TriggerServerEvent("inventory:server:OpenInventory", "stash", "warehouse"..warehouseid.."_moon") -end) - -CreateThread(function() - while true do - for k, v in pairs(Config.WareHouses) do - for k, v in pairs(v) do - local name = "Warehouse "..k - QBCore.Functions.TriggerCallback('moon-warehouse:server:warehousepurchased', function(result) - if result then - IsOwned2 = true - else - IsOwned2 = false - end - end, k) - Wait(400) - if not IsOwned2 then - makeBlip({coords = v, sprite = 474, col = 2, name = name}) - elseif IsOwned2 then - makeBlip({coords = v, sprite = 474, col = 5, name = name}) - end - end - end - Wait(Config.RefreshBlipInterval * 60 * 60 * 1000) - end -end) - -CreateThread(function() - -- Warte kurz, um sicherzustellen, dass qb-target geladen ist - Wait(1000) - - for k,v in pairs(Config.WareHouses) do - for k,v in pairs(v) do - local name = 'WareHouse'.. k - -- Korrigierte Vektorverarbeitung - local coords = vector3(v.x, v.y, v.z) - Targets[name] = - exports['qb-target']:AddBoxZone(name, coords, 2.0, 2.0, { - heading = v.w, - debugPoly = false, - minZ = v.z - 1, - maxZ = v.z + 4, - }, { - options = { - { - action = function() - TriggerEvent("moon-warehouse:client:openmenu", k) - end, - icon = "fas fa-clipboard", - label = 'Interact', - }, - }, - distance = 3.0 - }) - end - end -end) - -AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - despawntargets() - end -end) - - - diff --git a/resources/[inventory]/omi-warehouse/config.lua b/resources/[inventory]/omi-warehouse/config.lua deleted file mode 100644 index 2939fc6d0..000000000 --- a/resources/[inventory]/omi-warehouse/config.lua +++ /dev/null @@ -1,42 +0,0 @@ -Config = {} - -Config.WareHouseSellPrice = 5000 --- for hw much a player can sell his ware house to Government -Config.RefreshBlipInterval = 6 ---- In Hours -Config.RentPeriod = 7 --- Days -Config.inventory = "qb" --- qb/ox - -Config.WareHouses = { - ['Warehouses'] = { - [1] = vector4(912.16, -2174.31, 30.49, 267.01), - [2] = vector4(908.17, -2192.15, 30.52, 261.7), - [3] = vector4(932.1, -2283.45, 30.97, 264.82), - [4] = vector4(929.5, -2308.12, 30.65, 267.2), - [5] = vector4(877.94, -2387.05, 27.94, 86.88), - [6] = vector4(877.33, -2395.11, 27.94, 86.7), - [7] = vector4(876.8, -2403.2, 27.94, 81.23), - [8] = vector4(876.2, -2410.96, 27.94, 87.69), - [9] = vector4(864.84, -2429.56, 28.13, 356.28), - [10] = vector4(853.31, -2432.59, 28.07, 352.47), - [11] = vector4(843.11, -2427.26, 27.97, 351.29), - [12] = vector4(974.63, -2435.51, 30.19, 80.32), - [13] = vector4(991.53, -2395.29, 30.53, 264.56), - [14] = vector4(991.53, -2395.29, 30.53, 264.56), - [15] = vector4(976.91, -2189.53, 30.55, 350.49), - [16] = vector4(992.78, -2190.86, 30.55, 352.98), - [17] = vector4(186.0672, 2786.8179, 46.0194, 99.1695), - [18] = vector4(-35.3069, 6424.2715, 31.4337, 44.0006), - }, -} - -Config.Upgradation = { - StashSize = { - ["500 Kg"] = 50000, - ["1000 Kg"] = 100000, - ["1500 Kg"] = 200000, - }, - Slots = { - ["+20"] = 10000, - ["+40"] = 20000, - ["+60"] = 30000, - }, -} diff --git a/resources/[inventory]/omi-warehouse/fxmanifest.lua b/resources/[inventory]/omi-warehouse/fxmanifest.lua deleted file mode 100644 index 4214cde18..000000000 --- a/resources/[inventory]/omi-warehouse/fxmanifest.lua +++ /dev/null @@ -1,39 +0,0 @@ -fx_version 'cerulean' -game 'gta5' - -author 'Nullvalue' -version '1.2.0' - -client_scripts { - '@PolyZone/client.lua', - '@PolyZone/BoxZone.lua', - '@PolyZone/CircleZone.lua', - '@PolyZone/ComboZone.lua', - 'client/*.lua' -} - -server_scripts { - '@oxmysql/lib/MySQL.lua', - 'server/*.lua' -} - -shared_scripts { - 'config.lua', - 'shared/*.lua', - '@ox_lib/init.lua', -} - -dependencies { - 'qb-core', - 'qb-target', - 'oxmysql', - 'PolyZone', - 'ox_lib' -} - -escrow_ignore { - 'client/*.lua', - 'server/*.lua', -} - -lua54 'yes' diff --git a/resources/[inventory]/omi-warehouse/server/server.lua b/resources/[inventory]/omi-warehouse/server/server.lua deleted file mode 100644 index f248236c4..000000000 --- a/resources/[inventory]/omi-warehouse/server/server.lua +++ /dev/null @@ -1,281 +0,0 @@ -local QBCore = exports["qb-core"]:GetCoreObject() - -function CleanupWarehouses() - local currentDate = os.date('%Y-%m-%d') -- Get the current date in YYYY-MM-DD format - local sevenDaysAgo = os.date('%Y-%m-%d', os.time() - Config.RentPeriod * 24 * 60 * 60) -- Calculate the date 7 days ago - - MySQL.Async.execute('UPDATE warehouses SET owned = 0, owner = 0, date_purchased = NULL, stashsize = 3000000, slots = 50, passwordset = 0, password = NULL WHERE `date_purchased` <= ?', {sevenDaysAgo}) -end - -RegisterNetEvent('moon-warehouse:server:buyWareHouse', function(location, CitizenID, price) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local CostOfWarehouse = price - local PlayerBankMoney = Player.PlayerData.money['bank'] - - if PlayerBankMoney <= CostOfWarehouse then - TriggerClientEvent('QBCore:Notify', src, "You cannot afford this. You need $".. CostOfWarehouse, "error", 2500) - return - end - - if Player.Functions.RemoveMoney("bank", CostOfWarehouse, "Purchased Warehouse") then - local purchaseDate = os.date('%Y-%m-%d') -- Get the current date in YYYY-MM-DD format - MySQL.Async.execute('UPDATE warehouses SET owned = ?, owner = ?, date_purchased = ? WHERE `location` = ?', {1, CitizenID, purchaseDate, location}) - TriggerClientEvent('QBCore:Notify', src, "You have purchased the warehouse.", "success", 2500) - end -end) - -RegisterServerEvent("moon-warehouse:server:renewwarehouse") -AddEventHandler("moon-warehouse:server:renewwarehouse", function(meow, price, date) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local costtoUpgrade = price - local PlayerBankMoney = Player.PlayerData.money['bank'] - local FORMATTEDdate = os.date('%Y-%m-%d', date) - - if PlayerBankMoney <= costtoUpgrade then - TriggerClientEvent('QBCore:Notify', src, "You cannot afford this. You need $".. costtoUpgrade, "error", 2500) - return - end - - if Player.Functions.RemoveMoney("bank", costtoUpgrade, "Purchased Warehouse") then - local currentDate = os.date('%Y-%m-%d') - local dateTimestamp = os.time({year = tonumber(FORMATTEDdate:sub(1, 4)), month = tonumber(FORMATTEDdate:sub(6, 7)), day = tonumber(FORMATTEDdate:sub(9, 10))}) - local newTimestamp = dateTimestamp + 7 * 24 * 60 * 60 - local newPurchaseDate = os.date('%Y-%m-%d', newTimestamp) - MySQL.Async.execute('UPDATE warehouses SET date_purchased = ? WHERE `location` = ?', {newPurchaseDate, meow}) - TriggerClientEvent('QBCore:Notify', src, "Warehouse Renewed for 7 days.", 'success', 2500) - end -end) - -RegisterServerEvent("moon-warehouse:server:checkwarehouse") -AddEventHandler("moon-warehouse:server:checkwarehouse", function(meow, date) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local FORMATTEDdate = os.date('%Y-%m-%d', date) - local currentDate = os.date('%Y-%m-%d') - local dateTimestamp = os.time({year = tonumber(FORMATTEDdate:sub(1, 4)), month = tonumber(FORMATTEDdate:sub(6, 7)), day = tonumber(FORMATTEDdate:sub(9, 10))}) - local newTimestamp = dateTimestamp + 7 * 24 * 60 * 60 - local newPurchaseDate = os.date('%Y-%m-%d', newTimestamp) - TriggerClientEvent('QBCore:Notify', src, "Your Warehouse Will Expire On ".. newPurchaseDate, 'success', 10000) -end) - -RegisterNetEvent('moon-warehouse:server:Upgradewarehouseslots', function(location, CitizenID, slots) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local slotstoincrease = slots - if slotstoincrease == 20 then - Upgradationcost = Config.Upgradation.Slots["+20"] - elseif slotstoincrease == 40 then - Upgradationcost = Config.Upgradation.Slots["+40"] - elseif slotstoincrease == 60 then - Upgradationcost = Config.Upgradation.Slots["+60"] - end - local PlayerBankMoney = Player.PlayerData.money['bank'] - if PlayerBankMoney <= Upgradationcost then TriggerClientEvent('QBCore:Notify', src, "You cannot Afford This You Need $".. Upgradationcost, "error", 2500) return end - if Player.Functions.RemoveMoney("bank", Upgradationcost, "Upgraded Slots") then - MySQL.Async.fetchScalar('SELECT slots FROM warehouses WHERE `location` = ?', {location}, function(currentSlots) - if currentSlots then - local newSlots = tonumber(currentSlots) + tonumber(slotstoincrease) - MySQL.Async.execute('UPDATE warehouses SET slots = ? WHERE `location` = ?', {newSlots, location}) - TriggerClientEvent('QBCore:Notify', src, "Warehouse Slots are Now Upgraded, You now have ".. newSlots .. " Slots in Your Stash", 'success') - end - end) - else - TriggerClientEvent('QBCore:Notify', src, "Warehouse Slots Cannot Be Upgraded", 'error') - end -end) - -RegisterNetEvent('moon-warehouse:server:updatepassword', function(location, CitizenID, password) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local password = password - MySQL.Async.execute('UPDATE warehouses SET passwordset = ?, password = ? WHERE `location` = ?', {1, password, location}) - TriggerClientEvent('QBCore:Notify', src, "You have Updated the Password", 'success') -end) - -RegisterNetEvent('moon-warehouse:server:upgradewarehousesize', function(location, CitizenID, size) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local sizetoincrease = size * 1000 - if sizetoincrease == 500 * 1000 then - UpgradationcostStash = Config.Upgradation.StashSize["500 Kg"] - elseif sizetoincrease == 1000 * 1000 then - UpgradationcostStash = Config.Upgradation.StashSize["1000 Kg"] - elseif sizetoincrease == 1500 * 1000 then - UpgradationcostStash = Config.Upgradation.StashSize["1500 Kg"] - end - local PlayerBankMoney = Player.PlayerData.money['bank'] - if PlayerBankMoney <= UpgradationcostStash then TriggerClientEvent('QBCore:Notify', src, "You cannot Afford This You Need $".. UpgradationcostStash, "error", 2500) return end - if Player.Functions.RemoveMoney("bank", UpgradationcostStash, "Upgraded Stash") then - MySQL.Async.fetchScalar('SELECT stashsize FROM warehouses WHERE `location` = ?', {location}, function(currentsize) - if currentsize then - local newSize = tonumber(currentsize) + tonumber(sizetoincrease) - MySQL.Async.execute('UPDATE warehouses SET stashsize = ? WHERE `location` = ?', {newSize, location}) - TriggerClientEvent('QBCore:Notify', src, "Warehouse Stash is Now Upgraded New Stash Size is ".. newSize / 1000 .. " Kg", 'success') - end - end) - else - TriggerClientEvent('QBCore:Notify', src, "Warehouse Stash Cannot Be Upgraded", 'error') - end -end) - -RegisterNetEvent('moon:warehouse:server:oxinventorystash', function(warehouseid, stashname, stashsize, slots) - local Player = QBCore.Functions.GetPlayer(source) - local id = warehouseid - local stashname = stashname - local slots = slots - exports.ox_inventory:RegisterStash(stashname, stashname, slots, stashsize) - TriggerClientEvent("moon-warehouse:client:openstash", source, id) -end) - -RegisterNetEvent('moon-warehouse:server:sellwarehouse', function(location) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local WareHouseSellPrice = Config.WareHouseSellPrice - if Player.Functions.AddMoney("bank", WareHouseSellPrice, "Sold Warehouse") then - MySQL.Async.execute('UPDATE warehouses SET owned = ? WHERE `location` = ?', {0, location}) - MySQL.Async.execute('UPDATE warehouses SET owner = ? WHERE `location` = ?', {0, location}) - MySQL.Async.execute('UPDATE warehouses SET slots = ? WHERE `location` = ?', {50, location}) - MySQL.Async.execute('UPDATE warehouses SET stashsize = ? WHERE `location` = ?', {3000000, location}) - MySQL.Async.execute('UPDATE warehouses SET date_purchased = NULL WHERE `location` = ?', {location}) - MySQL.Async.execute('UPDATE warehouses SET passwordset = ? WHERE `location` = ?', {0, location}) - MySQL.Async.execute('UPDATE warehouses SET password = NULL WHERE `location` = ?', {location}) - TriggerClientEvent('QBCore:Notify', src, "Warehouse Sold", 'success') - else - TriggerClientEvent('QBCore:Notify', src, "Warehouse Cannot Be Sold", 'error') - end -end) - -QBCore.Functions.CreateCallback('moon-warehouse:server:getdetails', function(_,cb,location) - local result = MySQL.query.await('SELECT * FROM warehouses WHERE location = ?', {location}) - if result[1] ~= nil then - cb(result[1]) - end -end) - -QBCore.Functions.CreateCallback('moon-warehouse:server:isowner', function(source, cb, location) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local citizenid = Player.PlayerData.citizenid - local result = MySQL.Sync.fetchAll('SELECT * FROM warehouses WHERE `owner` = ? AND location = ?', {citizenid, location}) - if result then - for _, v in pairs(result) do - if v.owner == citizenid and v.owned == 1 then - cb(true) - else - cb(false) - end - end - else - cb(false) - end -end) - -QBCore.Functions.CreateCallback('moon-warehouse:server:ispwdset', function(source, cb, location) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - local result = MySQL.Sync.fetchAll('SELECT * FROM warehouses WHERE location = ?', {location}) - if result then - for _, v in pairs(result) do - if v.passwordset == 0 then - cb(false) - elseif v.passwordset == 1 then - cb(true) - end - end - else - cb(false) - end -end) - -QBCore.Functions.CreateCallback('moon-warehouse:server:warehousepurchased', function(source, cb, location) - local result = MySQL.Sync.fetchAll('SELECT * FROM warehouses WHERE `location` = ?', {location}) - if result then - for k, v in pairs(result) do - local warehouseinfo = json.encode(v) - local owned = false - if v.owned == 1 then - owned = true - elseif v.owned == 0 then - owned = false - end - cb(owned) - end - end -end) - -AddEventHandler('onResourceStart', function(resourceName) - if GetCurrentResourceName() == resourceName then - CleanupWarehouses() - UpdateWarehouses() - end -end) - -QBCore.Commands.Add("pullwarehousestash", "Pull warehouse Stash through location", {{name = "id", help = "Warehouse ID"}}, false, function(source, args) - local src = source - local warehouseId = tonumber(args[1]) - if warehouseId then - local sql = "SELECT * FROM `warehouses` WHERE `location` = ?" - local values = {warehouseId} - MySQL.Async.fetchAll(sql, values, function(result) - if result and #result > 0 then - TriggerClientEvent('moon-warehouse:client:pullstash', src, warehouseId) - else - -- No warehouse with such ID exists - TriggerClientEvent('QBCore:Notify', src, "No warehouse with that ID exists.", "error") - end - end) - else - TriggerClientEvent('QBCore:Notify', src, "Invalid warehouse ID.", "error") - end -end, "admin") - -function UpdateWarehouses() - -- Load existing warehouses from the database - local existingWarehouses = {} - local sql = "SELECT * FROM `warehouses`" - local result = MySQL.Sync.fetchAll(sql, {}) - for _, row in ipairs(result) do - existingWarehouses[row.location] = "Warehouse "..row.location - end - - -- Loop through your Config.WareHouses and update as needed - for location, data in pairs(Config.WareHouses['Warehouses']) do - if not existingWarehouses[location] then - local name = "Warehouse "..location - local sql = "INSERT INTO `warehouses` (`location`, `owned`, `owner`, `stashsize`, `slots`, `price`, `date_purchased`, `passwordset`, `password`) VALUES (?, 0, '0', 3000000, 50, 10000, NULL, 0, NULL )" - local values = {location} - MySQL.Async.execute(sql, values, function(rowsInserted) - if rowsInserted > 0 then - print("Added warehouse to database: " .. name) - else - print("Failed to add warehouse to database: " .. name) - end - end) - - -- Update the existingWarehouses table - existingWarehouses[location] = name - end - end - - -- Check for locations in the database that are no longer in Config.WareHouses and remove them - for location, label in pairs(existingWarehouses) do - if not Config.WareHouses['Warehouses'][location] then - -- Remove the warehouse from the database - local sql = "DELETE FROM `warehouses` WHERE `location` = ?" - local values = {location} - MySQL.Async.execute(sql, values, function(rowsDeleted) - if rowsDeleted > 0 then - print("Removed warehouse from database: " .. label) - else - print("Failed to remove warehouse from database: " .. label) - end - end) - - -- Remove the location from existingWarehouses - existingWarehouses[location] = nil - end - end -end - diff --git a/resources/[inventory]/omi-warehouse/shared/shared.lua b/resources/[inventory]/omi-warehouse/shared/shared.lua deleted file mode 100644 index d46de5dbd..000000000 --- a/resources/[inventory]/omi-warehouse/shared/shared.lua +++ /dev/null @@ -1,25 +0,0 @@ -local QBCore = exports["qb-core"]:GetCoreObject() -RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end) - -function makeBlip(data) - local blip = AddBlipForCoord(data.coords) - SetBlipAsShortRange(blip, true) - SetBlipSprite(blip, data.sprite or 1) - SetBlipColour(blip, data.col or 0) - SetBlipScale(blip, data.scale or 0.5) - -- SetBlipDisplay(blip, (data.disp or 6)) - BeginTextCommandSetBlipName('STRING') - AddTextComponentString(tostring(data.name) or 'Delivery Job') - EndTextCommandSetBlipName(blip) - if Config.Debug then print("^5Debug^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end - return blip -end - -function getStreet() return currentStreetName end -function getStreetandZone(coords) - local zone = GetLabelText(GetNameOfZone(coords.x, coords.y, coords.z)) - local currentStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z) - currentStreetName = GetStreetNameFromHashKey(currentStreetHash) - playerStreetsLocation = currentStreetName .. ", " .. zone - return playerStreetsLocation -end \ No newline at end of file