diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 09c3877e2..0b3e862ba 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -73,4 +73,6 @@ fix lint error: unused argument last; accessing undefined variable Invoke; unuse 46. [npwd]: fix: Warning: could not find @bitpredator 47. [server.cfg]: fix: Couldn't find resource @bitpredator 48. fix: No such export getSharedObject in resource es_extended @bitpredator -49. [bpt_bakerjob]: refactor: bpt_bakerjob inventory implementation @bitpredator \ No newline at end of file +49. [bpt_bakerjob]: refactor: bpt_bakerjob inventory implementation @bitpredator +50. [bpt_ballasjob]: refactor: bpt_ballasjob inventory implementation @bitpredator +51. [bpt_ballasjob]: feat: bpt_ballasjob\locales\en.lua @bitpredator \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_ballasjob/README.md b/server-data/resources/[bpt_addons]/bpt_ballasjob/README.md index d228f005a..64559b85e 100644 --- a/server-data/resources/[bpt_addons]/bpt_ballasjob/README.md +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/README.md @@ -1,16 +1,20 @@ -# bpt_ballasjob +

bpt_ballasjob

+

Discord +📌 License Copyright (C) 2022-2023 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_ballasjob/client/main.lua b/server-data/resources/[bpt_addons]/bpt_ballasjob/client/main.lua index cd8ec7a6a..8c37e24bc 100644 --- a/server-data/resources/[bpt_addons]/bpt_ballasjob/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/client/main.lua @@ -1,5 +1,5 @@ local HasAlreadyEnteredMarker -local CurrentAction, CurrentActionMsg = nil, {} +local CurrentAction, CurrentActionMsg, CurrentActionData = nil, '', {} local LastZone RegisterNetEvent('esx:playerLoaded') @@ -39,8 +39,11 @@ function ShowLoadingPromt(msg, time, type) end) end -function OpenBallasActionsMenu() +function OpenballasActionsMenu() local elements = { + {unselectable = true, icon = "fas fa-ballas", title = _U('ballas')}, + {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 @@ -51,18 +54,23 @@ function OpenBallasActionsMenu() } end - ESX.UI.Menu.CloseAll() - - 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_ballas') + 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', 'ballas', function(_, menu) menu.close() end) end - end, function() CurrentAction = 'ballas_actions_menu' CurrentActionMsg = _U('press_to_open') + CurrentActionData = {} end) end @@ -103,11 +111,12 @@ AddEventHandler('bpt_ballasjob:hasEnteredMarker', function(zone) if zone == 'BallasActions' then CurrentAction = 'ballas_actions_menu' CurrentActionMsg = _U('press_to_open') + CurrentActionData = {} end end) AddEventHandler('bpt_ballasjob:hasExitedMarker', function() - ESX.UI.Menu.CloseAll() + ESX.CloseContext() CurrentAction = nil end) @@ -116,11 +125,11 @@ CreateThread(function() local blip = AddBlipForCoord(Config.Zones.BallasActions.Pos.x, Config.Zones.BallasActions.Pos.y, Config.Zones.BallasActions.Pos.z) - SetBlipSprite(blip, 106) - SetBlipDisplay(blip, 4) - SetBlipScale(blip, 1.0) - SetBlipColour(blip, 27) - SetBlipAsShortRange(blip, true) + SetBlipSprite(blip, 106) + SetBlipDisplay(blip, 4) + SetBlipScale(blip, 1.0) + SetBlipColour(blip, 27) + SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName('STRING') AddTextComponentSubstringPlayerName(_U('blip_ballas')) @@ -142,8 +151,16 @@ CreateThread(function() if v.Type ~= -1 and distance < Config.DrawDistance then sleep = 0 - 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) + if k == "" 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) + 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) + end + end if distance < v.Size.x then @@ -175,7 +192,7 @@ CreateThread(function() if IsControlJustReleased(0, 38) and ESX.PlayerData.job and ESX.PlayerData.job.name == 'ballas' then if CurrentAction == 'ballas_actions_menu' then - OpenBallasActionsMenu() + OpenballasActionsMenu() end CurrentAction = nil @@ -192,4 +209,4 @@ RegisterCommand('ballasmenu', function() end end, false) -RegisterKeyMapping('ballasmenu', 'Open ballas Menu', 'keyboard', 'f6') +RegisterKeyMapping('ballasmenu', 'Open Ballas Menu', 'keyboard', 'f6') \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_ballasjob/config.lua b/server-data/resources/[bpt_addons]/bpt_ballasjob/config.lua index 37ca33c2d..d3efbdcfe 100644 --- a/server-data/resources/[bpt_addons]/bpt_ballasjob/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/config.lua @@ -1,11 +1,7 @@ Config = {} - Config.DrawDistance = 10.0 -- How close do you need to be for the markers to be drawn (in GTA units). - Config.EnablePlayerManagement = true -- Enable society managing. - Config.Locale = 'it' - Config.OxInventory = ESX.GetConfig().OxInventory Config.Zones = { diff --git a/server-data/resources/[bpt_addons]/bpt_ballasjob/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_ballasjob/fxmanifest.lua index c6e261e8b..52d007aaa 100644 --- a/server-data/resources/[bpt_addons]/bpt_ballasjob/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/fxmanifest.lua @@ -4,7 +4,7 @@ game 'gta5' description 'bpt_ballasjob' lua54 'yes' -version '0.0.4' +version '1.0.0' autthor'bitpredator' shared_script '@es_extended/imports.lua' diff --git a/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/en.lua new file mode 100644 index 000000000..90192319d --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/en.lua @@ -0,0 +1,16 @@ +Locales['en'] = { + ['amount_invalid'] = 'invalid amount', + ['press_to_open'] = 'press [E] to access the menu', + ['billing'] = 'billing', + ['billing_sent'] = 'the account has been registered!', + ['invoice_amount'] = 'invoice amount', + ['no_players_near'] = 'no players nearby', + ['boss_actions'] = 'Boss actions', + ['blip_ballas'] = 'ballas', + ['ballas'] = 'ballas', + -- Inventory + ['deposit_stock'] = 'deposit stock', + ['take_stock'] = 'take stock', + ['have_deposited'] = 'have deposited', + ['quantity_invalid'] = 'quantity invalid' +} diff --git a/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/it.lua index f1dbf8246..6a7000230 100644 --- a/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/locales/it.lua @@ -7,5 +7,10 @@ Locales['it'] = { ['no_players_near'] = 'nessun giocatore nelle vicinanze', ['boss_actions'] = 'Azioni del boss', ['blip_ballas'] = 'ballas', - ['ballas'] = 'ballas' + ['ballas'] = 'ballas', + -- Inventory + ['deposit_stock'] = 'Depositare', + ['take_stock'] = 'Prendi', + ['have_deposited'] = 'Hai depositato', + ['quantity_invalid'] = 'Qunatità non valida' } diff --git a/server-data/resources/[bpt_addons]/bpt_ballasjob/server/main.lua b/server-data/resources/[bpt_addons]/bpt_ballasjob/server/main.lua index ec28b548a..63d4e22df 100644 --- a/server-data/resources/[bpt_addons]/bpt_ballasjob/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_ballasjob/server/main.lua @@ -10,3 +10,58 @@ ESX.RegisterServerCallback('bpt_ballasjob:getPlayerInventory', function(source, items = items }) end) + +RegisterNetEvent('bpt_ballasjob:getStockItem') +AddEventHandler('bpt_ballasjob:getStockItem', function(itemName, count) + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.job.name == 'ballas' then + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_ballas', 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_ballasjob:getStockItem^7 (cheating)'):format(source)) + end +end) + +ESX.RegisterServerCallback('bpt_ballasjob:getStockItems', function(_, cb) + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_ballas', function(inventory) + cb(inventory.items) + end) +end) + +RegisterNetEvent('bpt_ballasjob:putStockItems') +AddEventHandler('bpt_ballasjob:putStockItems', function(itemName, count) + local xPlayer = ESX.GetPlayerFromId(source) + local sourceItem = xPlayer.getInventoryItem(itemName) + + if xPlayer.job.name == 'ballas' then + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_ballas', 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_ballasjob:putStockItems^7 (cheating)'):format(source)) + end +end) diff --git a/server-data/resources/[ox]/ox_inventory/data/stashes.lua b/server-data/resources/[ox]/ox_inventory/data/stashes.lua index cd4c07305..74a5ac2d2 100644 --- a/server-data/resources/[ox]/ox_inventory/data/stashes.lua +++ b/server-data/resources/[ox]/ox_inventory/data/stashes.lua @@ -132,25 +132,6 @@ return { groups = {['dustman'] = 0} }, - { - coords = vec3(78.738464, -1962.184570, 18.041016), - target = { - loc = vec3(78.738464, -1962.184570, 18.041016), - length = 0.6, - width = 1.8, - heading = 340, - minZ = 43.34, - maxZ = 44.74, - label = 'Storage' - }, - name = 'ballaslocker', - label = 'Storage', - owner = false, - slots = 70, - weight = 70000, - groups = {['ballas'] = 0} - }, - { coords = vec3(-29.287910, -1103.182373, 26.415405), target = {