Skip to content

Commit

Permalink
Update server.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
FBFezz authored Aug 1, 2021
1 parent 0768e92 commit 11ead8d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ ESX.RegisterServerCallback('szi_vendingmachine:canRob', function(source, cb, pos
end
end

if (itemcount == #(Config.RequiredItems)) and (police >= Config.PoliceRequired) then
if (itemcount == #(Config.RequiredItems)) and (police >= GetOptions("PoliceRequired")) then
cb(true)
itemcount = 0
else
cb(false)
itemcount = 0
if police < Config.PoliceRequired then
TriggerClientEvent('esx:showNotification', source, _U('min_police', Config.PoliceRequired))
if police < GetOptions("PoliceRequired") then
TriggerClientEvent('esx:showNotification', source, _U('min_police', GetOptions("PoliceRequired")))
end
end
end)
Expand Down Expand Up @@ -103,13 +103,12 @@ RegisterServerEvent('szi_vendingmachine:buyItem')
AddEventHandler('szi_vendingmachine:buyItem', function(itemName, price, amount)
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.getMoney() >= price and xPlayer.canCarryItem(itemName, amount) then
xPlayer.addInventoryItem(itemName, amount)
if xPlayer.getMoney() >= price then
xPlayer.removeMoney(price)
xPlayer.addInventoryItem(itemName, amount)
xPlayer.showNotification(_U('bought', amount, itemName, ESX.Math.GroupDigits(price)))
elseif xPlayer.getMoney() <= price then
xPlayer.showNotification('you don\'t have enough money!')
else
xPlayer.showNotification('You cannot carry anything else')
end
end)

Expand Down

0 comments on commit 11ead8d

Please sign in to comment.