Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete vending machine and transfer to qb-shops #482

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,6 @@ end

exports('HasItem', HasItem)

---Gets the closest vending machine object to the client
---@return integer closestVendingMachine
local function GetClosestVending()
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local object = nil
for _, machine in pairs(Config.VendingObjects) do
local ClosestObject = GetClosestObjectOfType(pos.x, pos.y, pos.z, 0.75, joaat(machine), false, false, false)
if ClosestObject ~= 0 then
if object == nil then
object = ClosestObject
end
end
end
return object
end

---Opens the vending machine shop
local function OpenVending()
local ShopItems = {}
ShopItems.label = 'Vending Machine'
ShopItems.items = Config.VendingItem
ShopItems.slots = #Config.VendingItem
TriggerServerEvent('inventory:server:OpenInventory', 'shop', 'Vendingshop_' .. math.random(1, 99), ShopItems)
end

---Draws 3d text in the world on the given position
---@param x number The x coord of the text to draw
---@param y number The y coord of the text to draw
Expand Down Expand Up @@ -676,8 +650,6 @@ RegisterCommand('inventory', function()
if not PlayerData.metadata['isdead'] and not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['ishandcuffed'] and not IsPauseMenuActive() then
local ped = PlayerPedId()
local curVeh = nil
local VendingMachine = nil
if not Config.UseTarget then VendingMachine = GetClosestVending() end

if IsPedInAnyVehicle(ped, false) then -- Is Player In Vehicle
local vehicle = GetVehiclePedIsIn(ped, false)
Expand Down Expand Up @@ -729,12 +701,6 @@ RegisterCommand('inventory', function()
TriggerServerEvent('inventory:server:OpenInventory', 'glovebox', CurrentGlovebox)
elseif CurrentDrop ~= 0 then
TriggerServerEvent('inventory:server:OpenInventory', 'drop', CurrentDrop)
elseif VendingMachine then
local ShopItems = {}
ShopItems.label = 'Vending Machine'
ShopItems.items = Config.VendingItem
ShopItems.slots = #Config.VendingItem
TriggerServerEvent('inventory:server:OpenInventory', 'shop', 'Vendingshop_' .. math.random(1, 99), ShopItems)
else
openAnim()
TriggerServerEvent('inventory:server:OpenInventory')
Expand Down Expand Up @@ -993,23 +959,6 @@ CreateThread(function()
end
end)

CreateThread(function()
if Config.UseTarget then
exports['qb-target']:AddTargetModel(Config.VendingObjects, {
options = {
{
icon = 'fa-solid fa-cash-register',
label = Lang:t('menu.vending'),
action = function()
OpenVending()
end
},
},
distance = 2.5
})
end
end)

CreateThread(function()
if Config.UseTarget then
exports['qb-target']:AddTargetModel(Config.CraftingObject, {
Expand Down
25 changes: 0 additions & 25 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,12 @@ Config.MaxDropViewDistance = 12.5 -- The distance in GTA Units tha
Config.UseItemDrop = false -- This will enable item object to spawn on drops instead of markers
Config.ItemDropObject = `prop_nigel_bag_pickup` -- if Config.UseItemDrop is true, this will be the prop that spawns for the item

Config.VendingObjects = {
'prop_vend_soda_01',
'prop_vend_soda_02',
'prop_vend_water_01'
}

Config.BinObjects = {
'prop_bin_05a',
}

Config.CraftingObject = `prop_toolchest_05`

Config.VendingItem = {
{
name = 'kurkakola',
price = 4,
amount = 50,
info = {},
type = 'item',
slot = 1,
},
{
name = 'water_bottle',
price = 4,
amount = 50,
info = {},
type = 'item',
slot = 2,
},
}

-- See the vehicle class here: https://docs.fivem.net/natives/?_0x29439776AAA00A62
-- The template:
-- [vehicleClass] = {slots = [number], maxWeight = [number]}
Expand Down
Loading