diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 58c83be78..d97cbfbb6 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -91,4 +91,5 @@ fix lint error: unused argument last; accessing undefined variable Invoke; unuse 64. [bpt_crafting]: fix: correct ingredients to use @bitpredator 65. [bpt_streetfight]: chore: supports map point through local translation @bitpredator 67. [bpt_teleport]: chore: set English as the default language @bitpredator -68. [bpt_teleport]: chore: update the license file and readme for the year 2024 @bitpredator \ No newline at end of file +68. [bpt_teleport]: chore: update the license file and readme for the year 2024 @bitpredator +69. [bpt_unicornjob]: refactor: bpt_unicornjob inventory implementation @bitpredator \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/LICENSE b/server-data/resources/[bpt_addons]/bpt_unicornjob/LICENSE index 26ecd4f64..7c1b638e7 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/LICENSE +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/LICENSE @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) 2022-2023 bitpredator + Copyright (C) 2022-2024 bitpredator This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) 2022-2023 bitpredator + Copyright (C) 2022-2024 bitpredator This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/README.md b/server-data/resources/[bpt_addons]/bpt_unicornjob/README.md index 8c21ab046..02f601c79 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/README.md +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/README.md @@ -1,16 +1,19 @@ -# bpt_unicornjob +

bpt_unicornjob

+

Discord -Copyright (C) 2022-2023 bitpredator +Copyright (C) 2022-2024 bitpredator -This program is a project for the fivem community, you have legal permission to distribute and / or modify it only if you have forked this repository, if it is not a fork repository, the version will be removed from the DMCA request. +This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. + +This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. ATTENTION: -You are not authorized to change the name of the resource. +You are not authorized to change the name of the resource and the resources within it. If you want to contribute you can open a pull request. -You are not authorized to sell this software (this is a free project). +You are not authorized to sell this software (this is free project). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. +You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/bpt_unicornjob.sql b/server-data/resources/[bpt_addons]/bpt_unicornjob/bpt_unicornjob.sql index 2144fdc40..38681f4a8 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/bpt_unicornjob.sql +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/bpt_unicornjob.sql @@ -20,4 +20,4 @@ INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_ ('unicorn',2,'driver','barrista',36,'{"hair_2":0,"hair_color_2":0,"torso_1":26,"bags_1":0,"helmet_2":0,"chain_2":0,"eyebrows_3":0,"makeup_3":0,"makeup_2":0,"tshirt_1":57,"makeup_1":0,"bags_2":0,"makeup_4":0,"eyebrows_4":0,"chain_1":0,"lipstick_4":0,"bproof_2":0,"hair_color_1":0,"decals_2":0,"pants_2":4,"age_2":0,"glasses_2":0,"ears_2":0,"arms":11,"lipstick_1":0,"ears_1":-1,"mask_2":0,"sex":0,"lipstick_3":0,"helmet_1":-1,"shoes_2":0,"beard_2":0,"beard_1":0,"lipstick_2":0,"beard_4":0,"glasses_1":0,"bproof_1":0,"mask_1":0,"decals_1":0,"hair_1":0,"eyebrows_2":0,"beard_3":0,"age_1":0,"tshirt_2":0,"skin":0,"torso_2":0,"eyebrows_1":0,"face":0,"shoes_1":10,"pants_1":24}', '{"hair_2":0,"hair_color_2":0,"torso_1":57,"bags_1":0,"helmet_2":0,"chain_2":0,"eyebrows_3":0,"makeup_3":0,"makeup_2":0,"tshirt_1":38,"makeup_1":0,"bags_2":0,"makeup_4":0,"eyebrows_4":0,"chain_1":0,"lipstick_4":0,"bproof_2":0,"hair_color_1":0,"decals_2":0,"pants_2":1,"age_2":0,"glasses_2":0,"ears_2":0,"arms":21,"lipstick_1":0,"ears_1":-1,"mask_2":0,"sex":1,"lipstick_3":0,"helmet_1":-1,"shoes_2":0,"beard_2":0,"beard_1":0,"lipstick_2":0,"beard_4":0,"glasses_1":5,"bproof_1":0,"mask_1":0,"decals_1":1,"hair_1":0,"eyebrows_2":0,"beard_3":0,"age_1":0,"tshirt_2":0,"skin":0,"torso_2":0,"eyebrows_1":0,"face":0,"shoes_1":49,"pants_1":11}'), ('unicorn',3,'responsible','responsabile',48,'{"hair_2":0,"hair_color_2":0,"torso_1":26,"bags_1":0,"helmet_2":0,"chain_2":0,"eyebrows_3":0,"makeup_3":0,"makeup_2":0,"tshirt_1":57,"makeup_1":0,"bags_2":0,"makeup_4":0,"eyebrows_4":0,"chain_1":0,"lipstick_4":0,"bproof_2":0,"hair_color_1":0,"decals_2":0,"pants_2":4,"age_2":0,"glasses_2":0,"ears_2":0,"arms":11,"lipstick_1":0,"ears_1":-1,"mask_2":0,"sex":0,"lipstick_3":0,"helmet_1":-1,"shoes_2":0,"beard_2":0,"beard_1":0,"lipstick_2":0,"beard_4":0,"glasses_1":0,"bproof_1":0,"mask_1":0,"decals_1":0,"hair_1":0,"eyebrows_2":0,"beard_3":0,"age_1":0,"tshirt_2":0,"skin":0,"torso_2":0,"eyebrows_1":0,"face":0,"shoes_1":10,"pants_1":24}', '{"hair_2":0,"hair_color_2":0,"torso_1":57,"bags_1":0,"helmet_2":0,"chain_2":0,"eyebrows_3":0,"makeup_3":0,"makeup_2":0,"tshirt_1":38,"makeup_1":0,"bags_2":0,"makeup_4":0,"eyebrows_4":0,"chain_1":0,"lipstick_4":0,"bproof_2":0,"hair_color_1":0,"decals_2":0,"pants_2":1,"age_2":0,"glasses_2":0,"ears_2":0,"arms":21,"lipstick_1":0,"ears_1":-1,"mask_2":0,"sex":1,"lipstick_3":0,"helmet_1":-1,"shoes_2":0,"beard_2":0,"beard_1":0,"lipstick_2":0,"beard_4":0,"glasses_1":5,"bproof_1":0,"mask_1":0,"decals_1":1,"hair_1":0,"eyebrows_2":0,"beard_3":0,"age_1":0,"tshirt_2":0,"skin":0,"torso_2":0,"eyebrows_1":0,"face":0,"shoes_1":49,"pants_1":11}'), ('unicorn',4,'boss','Direttore',0,'{"hair_2":0,"hair_color_2":0,"torso_1":29,"bags_1":0,"helmet_2":0,"chain_2":0,"eyebrows_3":0,"makeup_3":0,"makeup_2":0,"tshirt_1":31,"makeup_1":0,"bags_2":0,"makeup_4":0,"eyebrows_4":0,"chain_1":0,"lipstick_4":0,"bproof_2":0,"hair_color_1":0,"decals_2":0,"pants_2":4,"age_2":0,"glasses_2":0,"ears_2":0,"arms":1,"lipstick_1":0,"ears_1":-1,"mask_2":0,"sex":0,"lipstick_3":0,"helmet_1":-1,"shoes_2":0,"beard_2":0,"beard_1":0,"lipstick_2":0,"beard_4":0,"glasses_1":0,"bproof_1":0,"mask_1":0,"decals_1":0,"hair_1":0,"eyebrows_2":0,"beard_3":0,"age_1":0,"tshirt_2":0,"skin":0,"torso_2":4,"eyebrows_1":0,"face":0,"shoes_1":10,"pants_1":24}', '{"hair_2":0,"hair_color_2":0,"torso_1":57,"bags_1":0,"helmet_2":0,"chain_2":0,"eyebrows_3":0,"makeup_3":0,"makeup_2":0,"tshirt_1":38,"makeup_1":0,"bags_2":0,"makeup_4":0,"eyebrows_4":0,"chain_1":0,"lipstick_4":0,"bproof_2":0,"hair_color_1":0,"decals_2":0,"pants_2":1,"age_2":0,"glasses_2":0,"ears_2":0,"arms":21,"lipstick_1":0,"ears_1":-1,"mask_2":0,"sex":1,"lipstick_3":0,"helmet_1":-1,"shoes_2":0,"beard_2":0,"beard_1":0,"lipstick_2":0,"beard_4":0,"glasses_1":5,"bproof_1":0,"mask_1":0,"decals_1":1,"hair_1":0,"eyebrows_2":0,"beard_3":0,"age_1":0,"tshirt_2":0,"skin":0,"torso_2":0,"eyebrows_1":0,"face":0,"shoes_1":49,"pants_1":11}') -; +; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/client/main.lua b/server-data/resources/[bpt_addons]/bpt_unicornjob/client/main.lua index 83aeadd0c..84d314514 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/client/main.lua @@ -1,5 +1,6 @@ -local HasAlreadyEnteredMarker, CurrentAction, CurrentActionData = false, false, false -local LastZone, CurrentActionMsg +local HasAlreadyEnteredMarker +local CurrentAction, CurrentActionMsg, CurrentActionData = nil, '', {} +local LastZone RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) @@ -59,7 +60,7 @@ function OpenCloakroom() end end) end - ESX.CloseContext() + ESX.CloseContext() end, function() CurrentAction = 'cloakroom' CurrentActionMsg = _U('cloakroom_prompt') @@ -75,7 +76,7 @@ function OpenVehicleSpawnerMenu() if Config.EnableSocietyOwnedVehicles then ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(vehicles) - if #vehicles == 0 then + if #vehicles == 0 then ESX.ShowNotification(_U('empty_garage')) return end @@ -94,7 +95,7 @@ function OpenVehicleSpawnerMenu() return end - if element.value == nil then + if element.value == nil then print("ERROR: Context menu clicked item value is nil!") return end @@ -111,7 +112,8 @@ function OpenVehicleSpawnerMenu() end) end, 'unicorn') else -- not society vehicles - if #Config.AuthorizedVehicles == 0 then + + if #Config.AuthorizedVehicles == 0 then ESX.ShowNotification(_U('empty_garage')) return end @@ -129,13 +131,15 @@ function OpenVehicleSpawnerMenu() ESX.ShowNotification(_U('spawnpoint_blocked')) return end - if element.value == nil then + + if element.value == nil then print("ERROR: Context menu clicked item value is nil!") return end + ESX.TriggerServerCallback("bpt_unicornjob:SpawnVehicle", function() ESX.ShowNotification(_U('vehicle_spawned'), "success") - end, element.value, {plate = "UNIC JOB"}) + end, element.value, {plate = "CORN JOB"}) ESX.CloseContext() end, function() CurrentAction = 'vehicle_spawner' @@ -146,7 +150,6 @@ function OpenVehicleSpawnerMenu() end function DeleteJobVehicle() - if Config.EnableSocietyOwnedVehicles then local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle) TriggerServerEvent('esx_society:putVehicleInGarage', 'unicorn', vehicleProps) @@ -154,6 +157,10 @@ function DeleteJobVehicle() else if IsInAuthorizedVehicle() then ESX.Game.DeleteVehicle(CurrentActionData.vehicle) + + if Config.MaxInService ~= -1 then + TriggerServerEvent('esx_service:disableService', 'unicorn') + end else ESX.ShowNotification(_U('only_unicorn')) end @@ -162,7 +169,9 @@ end function OpenUnicornActionsMenu() local elements = { - {unselectable = true, icon = "fas fa-unicorn", title = _U('unicorn')} + {unselectable = true, icon = "fas fa-unicorn", title = _U('unicorn')}, + {icon = "fas fa-box",title = _U('deposit_stock'),value = 'put_stock'}, + {icon = "fas fa-box", title = _U('take_stock'), value = 'get_stock'} } if Config.EnablePlayerManagement and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.grade_name == 'boss' then @@ -173,8 +182,15 @@ function OpenUnicornActionsMenu() } end - ESX.OpenContext("right", elements, function(_,element) - if element.value == 'boss_actions' then + ESX.OpenContext("right", elements, function(_, element) + if Config.OxInventory and (element.value == 'put_stock' or element.value == 'get_stock') then + exports.ox_inventory:openInventory('stash', 'society_unicorn') + return ESX.CloseContext() + elseif element.value == 'put_stock' then + OpenPutStocksMenu() + elseif element.value == 'get_stock' then + OpenGetStocksMenu() + elseif element.value == 'boss_actions' then TriggerEvent('esx_society:openBossMenu', 'unicorn', function(_, menu) menu.close() end) @@ -192,12 +208,12 @@ function OpenMobileUnicornActionsMenu() {icon = "fas fa-scroll", title = _U('billing'), value = "billing"}, } - ESX.OpenContext("right", elements, function(_,element) + ESX.OpenContext("right", elements, function(_, element) if element.value == "billing" then local elements2 = { {unselectable = true, icon = "fas fa-unicorn", title = element.title}, - {title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 250000, inputPlaceholder = "Amount to bill.."}, - {icon = "fas fa-check-double", title = "Confirm", value = "confirm"} + {title = _U('amount'), input = true, inputType = "number", inputMin = 1, inputMax = 250000, inputPlaceholder = _U('bill_amount')}, + {icon = "fas fa-check-double", title = _U('confirm'), value = "confirm"} } ESX.OpenContext("right", elements2, function(menu2) @@ -271,11 +287,11 @@ CreateThread(function() local blip = AddBlipForCoord(Config.Zones.UnicornActions.Pos.x, Config.Zones.UnicornActions.Pos.y, Config.Zones.UnicornActions.Pos.z) - SetBlipSprite(blip, 121) - SetBlipDisplay(blip, 4) - SetBlipScale(blip, 1.0) - SetBlipColour(blip, 27) - SetBlipAsShortRange(blip, true) + SetBlipSprite(blip, 121) + SetBlipDisplay(blip, 4) + SetBlipScale(blip, 1.0) + SetBlipColour(blip, 27) + SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName('STRING') AddTextComponentSubstringPlayerName(_U('blip_unicorn')) @@ -290,7 +306,7 @@ CreateThread(function() local coords = GetEntityCoords(PlayerPedId()) local isInMarker, currentZone = false - local inVeh = IsPedInAnyVehicle(PlayerPedId()) + local inVeh = IsPedInAnyVehicle(PlayerPedId()) for k, v in pairs(Config.Zones) do local zonePos = vector3(v.Pos.x, v.Pos.y, v.Pos.z) @@ -298,15 +314,16 @@ CreateThread(function() if v.Type ~= -1 and distance < Config.DrawDistance then sleep = 0 - if k == "VehicleDeleter" then + if k == "VehicleDeleter" then if inVeh then DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size.x, v.Size.y, - v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, false, 2, v.Rotate, nil, nil, false) + v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, false, 2, v.Rotate, nil, nil, false) end else DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size.x, v.Size.y, - v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, false, 2, v.Rotate, nil, nil, false) + v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, false, 2, v.Rotate, nil, nil, false) end + end if distance < v.Size.x then @@ -355,7 +372,8 @@ CreateThread(function() end) RegisterCommand('unicornmenu', function() - if not ESX.PlayerData.dead and Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.name == 'unicorn' then + if not ESX.PlayerData.dead and Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.name == + 'unicorn' then OpenMobileUnicornActionsMenu() end end, false) diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/config.lua b/server-data/resources/[bpt_addons]/bpt_unicornjob/config.lua index a61c8e3a9..c472494ef 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/config.lua @@ -3,6 +3,7 @@ Config.DrawDistance = 10.0 -- How close do you need to be for the Config.EnablePlayerManagement = true -- Enable society managing. Config.EnableSocietyOwnedVehicles = false Config.Locale = 'en' +Config.OxInventory = ESX.GetConfig().OxInventory Config.AuthorizedVehicles = { {model = 'rentalbus', label = 'rentalbus'} diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_unicornjob/fxmanifest.lua index f841b714c..b58af7d9c 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/fxmanifest.lua @@ -1,10 +1,8 @@ fx_version 'adamant' - game 'gta5' - description 'bpt_unicornjob' lua54 'yes' -version '0.0.4' +version '1.0.0' shared_script '@es_extended/imports.lua' diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/en.lua index ba34707bd..9181addba 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/en.lua +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/en.lua @@ -4,6 +4,11 @@ Locales['en'] = { ['cloakroom_prompt'] = 'press [E] to access the cloakroom.', ['wear_citizen'] = 'civilian clothes', ['wear_work'] = 'work clothes', + -- Inventory + ['deposit_stock'] = 'Deposit stock', + ['take_stock'] = 'Take stock', + ['have_deposited'] = 'Have deposited', + ['quantity_invalid'] = 'Quantity invelid', -- garage ['spawner_prompt'] = 'press [E] to access the Garage.', ["vehicle_spawned"] = "Vehicle picked up successfully!", @@ -19,5 +24,9 @@ Locales['en'] = { ['no_players_near'] = 'no players nearby', ['boss_actions'] = 'Boss action', ['blip_unicorn'] = 'unicorn', - ['unicorn'] = 'unicorn' + ['unicorn'] = 'unicorn', + -- billing + ['bill_amount'] = "Amount to bill..", + ['confirm'] = "Confirm", + ['amount'] = "Amount" } \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/it.lua index 3d54be392..8695b7cea 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/locales/it.lua @@ -4,6 +4,11 @@ Locales['it'] = { ['cloakroom_prompt'] = 'premi [E] per accedere al guardaroba.', ['wear_citizen'] = 'abiti civili', ['wear_work'] = 'abiti da lavoro', + -- Inventory + ['deposit_stock'] = 'Depositare', + ['take_stock'] = 'Prendi', + ['have_deposited'] = 'Hai depositato', + ['quantity_invalid'] = 'Quantità non valida', -- garage ['spawner_prompt'] = 'premi [E] per accedere al Garage.', ["vehicle_spawned"] = "Veicolo ritirato con successo!", @@ -19,5 +24,9 @@ Locales['it'] = { ['no_players_near'] = 'nessun giocatore nelle vicinanze', ['boss_actions'] = 'Azioni del boss', ['blip_unicorn'] = 'unicorn', - ['unicorn'] = 'unicorn' + ['unicorn'] = 'unicorn', + -- billing + ['bill_amount'] = "importo della fattura", + ['confirm'] = "Conferma", + ['amount'] = "Importo" } \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_unicornjob/server/main.lua b/server-data/resources/[bpt_addons]/bpt_unicornjob/server/main.lua index 4d46eb68a..dfd95060d 100644 --- a/server-data/resources/[bpt_addons]/bpt_unicornjob/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_unicornjob/server/main.lua @@ -1,6 +1,11 @@ TriggerEvent('esx_society:registerSociety', 'unicorn', 'Unicorn', 'society_unicorn', 'society_unicorn', 'society_unicorn', { type = 'public' }) + +if Config.MaxInService ~= -1 then + TriggerEvent('esx_service:activateService', 'unicorn', Config.MaxInService) +end + ESX.RegisterServerCallback("bpt_unicornjob:SpawnVehicle", function(source, cb, model , props) local xPlayer = ESX.GetPlayerFromId(source) @@ -17,4 +22,59 @@ ESX.RegisterServerCallback("bpt_unicornjob:SpawnVehicle", function(source, cb, m TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1) end) cb() +end) + +RegisterNetEvent('bpt_unicornjob:getStockItem') +AddEventHandler('bpt_unicornjob:getStockItem', function(itemName, count) + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.job.name == 'unicorn' then + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_unicorn', function(inventory) + local item = inventory.getItem(itemName) + + -- is there enough in the society? + if count > 0 and item.count >= count then + -- can the player carry the said amount of x item? + if xPlayer.canCarryItem(itemName, count) then + inventory.removeItem(itemName, count) + xPlayer.addInventoryItem(itemName, count) + xPlayer.showNotification(_U('have_withdrawn', count, item.label)) + else + xPlayer.showNotification(_U('player_cannot_hold')) + end + else + xPlayer.showNotification(_U('quantity_invalid')) + end + end) + else + print(('[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_unicornjob:getStockItem^7 (cheating)'):format(source)) + end +end) + +ESX.RegisterServerCallback('bpt_unicornjob:getStockItems', function(_, cb) + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_unicorn', function(inventory) + cb(inventory.items) + end) +end) + +RegisterNetEvent('bpt_unicornjob:putStockItems') +AddEventHandler('bpt_unicornjob:putStockItems', function(itemName, count) + local xPlayer = ESX.GetPlayerFromId(source) + local sourceItem = xPlayer.getInventoryItem(itemName) + + if xPlayer.job.name == 'unicorn' then + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_unicorn', function(inventory) + local item = inventory.getItem(itemName) + + if sourceItem.count >= count and count > 0 then + xPlayer.removeInventoryItem(itemName, count) + inventory.addItem(itemName, count) + xPlayer.showNotification(_U('have_deposited', count, item.label)) + else + xPlayer.showNotification(_U('quantity_invalid')) + end + end) + else + print(('[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_unicornjob:putStockItems^7 (cheating)'):format(source)) + end end) \ No newline at end of file diff --git a/server-data/resources/[ox]/ox_inventory/data/stashes.lua b/server-data/resources/[ox]/ox_inventory/data/stashes.lua index 9d44bf736..fa81944d0 100644 --- a/server-data/resources/[ox]/ox_inventory/data/stashes.lua +++ b/server-data/resources/[ox]/ox_inventory/data/stashes.lua @@ -56,25 +56,6 @@ return { groups = {['unicorn'] = 0} }, - { - coords = vec3(93.204399, -1291.833008, 29.263062), - target = { - loc = vec3(93.204399, -1291.833008, 29.263062), - length = 0.6, - width = 1.8, - heading = 340, - minZ = 43.34, - maxZ = 44.74, - label = 'Storage Personal' - }, - name = 'unicornlocker', - label = 'Storage Personal', - owner = true, - slots = 70, - weight = 70000, - groups = {['unicorn'] = 0} - }, - { coords = vec3(-344.452759, -127.437363, 39.002197), target = {