1
0
Fork 0
forked from Simnation/Main
Main/resources/[inventory]/cfx-mxc-vendingmachines/config_functions.lua
2025-08-12 17:34:22 +02:00

51 lines
1.7 KiB
Lua

Config.Functions = {
--#region Server
StartFramework = function()
-- Keine Änderung nötig, da TGIANN mit ESX und QBCore funktioniert
if GetResourceState("es_extended") ~= "missing" then
ESX = exports["es_extended"]:getSharedObject()
elseif GetResourceState("qb-core") ~= "missing" then
QBCore = exports["qb-core"]:GetCoreObject()
end
end,
GiveItem = function(source, itemName, count)
-- TGIANN Inventory Version
exports["tgiann-inventory"]:AddItem(source, itemName, count)
end,
HaveMoney = function(source, type, amount)
if amount == 0 then return true end
-- TGIANN Inventory Version für Geldprüfung
local money = exports["tgiann-inventory"]:GetItemByName(source, "money")
if money and money.amount >= amount then
return true
end
return false
end,
RemoveMoney = function(source, type, amount)
if amount <= 0 then return end
-- TGIANN Inventory Version für Geldentfernung
exports["tgiann-inventory"]:RemoveItem(source, "money", amount)
end,
--#endregion
--#region Client
TryToBuy = function(self, selection, dbId, success)
if Server.CanBuySnackFromVending(self.name, selection) then
Server.SetVendingUsed(dbId, true)
success()
Server.SetVendingUsed(dbId, false)
if not Config.NoFramework then
Server.BuySnackFromVending(self.name, selection)
end
else
ButtonFor(Config.Translations["not_enough_money"], 2000)
Server.SetVendingUsed(dbId, false)
end
end,
}