Skip to content

Commit

Permalink
Inventory Update
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage committed May 20, 2024
1 parent 1d29344 commit 3b2ec56
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,68 @@ local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('qb-vineyard:server:getGrapes', function()
local Player = QBCore.Functions.GetPlayer(source)
local amount = math.random(Config.GrapeAmount.min, Config.GrapeAmount.max)
Player.Functions.AddItem("grape", amount)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['grape'], "add")
exports['qb-inventory']:AddItem(source, 'grape', amount, false, false, 'qb-vineyard:server:getGrapes')
TriggerClientEvent('qb-inventory:client:ItemBox', source, QBCore.Shared.Items['grape'], 'add')
end)

QBCore.Functions.CreateCallback('qb-vineyard:server:loadIngredients', function(source, cb)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local grape = Player.Functions.GetItemByName('grapejuice')
if Player.PlayerData.items ~= nil then
if Player.PlayerData.items ~= nil then
if grape ~= nil then
if grape.amount >= 23 then
Player.Functions.RemoveItem("grapejuice", 23, false)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['grapejuice'], "remove")
exports['qb-inventory']:RemoveItem(src, 'grapejuice', 23, false, 'qb-vineyard:server:loadIngredients')
TriggerClientEvent('qb-inventory:client:ItemBox', source, QBCore.Shared.Items['grapejuice'], 'remove')
cb(true)
else
TriggerClientEvent('QBCore:Notify', source, Lang:t("error.invalid_items"), 'error')
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.invalid_items'), 'error')
cb(false)
end
else
TriggerClientEvent('QBCore:Notify', source, Lang:t("error.invalid_items"), 'error')
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.invalid_items'), 'error')
cb(false)
end
else
TriggerClientEvent('QBCore:Notify', source, Lang:t("error.no_items"), "error")
else
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.no_items'), 'error')
cb(false)
end
end
end)

QBCore.Functions.CreateCallback('qb-vineyard:server:grapeJuice', function(source, cb)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local grape = Player.Functions.GetItemByName('grape')
if Player.PlayerData.items ~= nil then
if Player.PlayerData.items ~= nil then
if grape ~= nil then
if grape.amount >= 16 then
Player.Functions.RemoveItem("grape", 16, false)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['grape'], "remove")
exports['qb-inventory']:RemoveItem(src, 'grape', 16, false, 'qb-vineyard:server:grapeJuice')
TriggerClientEvent('qb-inventory:client:ItemBox', source, QBCore.Shared.Items['grape'], 'remove')
cb(true)
else
TriggerClientEvent('QBCore:Notify', source, Lang:t("error.invalid_items"), 'error')
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.invalid_items'), 'error')
cb(false)
end
else
TriggerClientEvent('QBCore:Notify', source, Lang:t("error.invalid_items"), 'error')
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.invalid_items'), 'error')
cb(false)
end
else
TriggerClientEvent('QBCore:Notify', source, Lang:t("error.no_items"), "error")
else
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.no_items'), 'error')
cb(false)
end
end
end)

RegisterNetEvent('qb-vineyard:server:receiveWine', function()
local Player = QBCore.Functions.GetPlayer(tonumber(source))
local Player = QBCore.Functions.GetPlayer(tonumber(source))
local amount = math.random(Config.WineAmount.min, Config.WineAmount.max)
Player.Functions.AddItem("wine", amount, false)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['wine'], "add")
exports['qb-inventory']:AddItem(source, 'wine', amount, false, false, 'qb-vineyard:server:receiveWine')
TriggerClientEvent('qb-inventory:client:ItemBox', source, QBCore.Shared.Items['wine'], 'add')
end)

RegisterNetEvent('qb-vineyard:server:receiveGrapeJuice', function()
local Player = QBCore.Functions.GetPlayer(tonumber(source))
local Player = QBCore.Functions.GetPlayer(tonumber(source))
local amount = math.random(Config.GrapeJuiceAmount.min, Config.GrapeJuiceAmount.max)
Player.Functions.AddItem("grapejuice", amount, false)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['grapejuice'], "add")
exports['qb-inventory']:AddItem(source, 'grapejuice', amount, false, false, 'qb-vineyard:server:receiveGrapeJuice')
TriggerClientEvent('qb-inventory:client:ItemBox', source, QBCore.Shared.Items['grapejuice'], 'add')
end)

0 comments on commit 3b2ec56

Please sign in to comment.