-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.lua
48 lines (40 loc) · 2.1 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
local ox_inventory = exports.ox_inventory
local combhook = ox_inventory:registerHook('swapItems', function(payload)
if payload.fromInventory == payload.source and payload.fromSlot ~= nil and type(payload.toSlot) == "table" and Config.Combinations[payload.fromSlot.name] ~= nil then
local combination = Config.Combinations[payload.fromSlot.name]
local neededItems = combination.needs
local hasAllItems = true
for _, neededItem in ipairs(neededItems) do
local neededItemName = neededItem.item
local neededAmount = neededItem.amount
local itemCount = exports.ox_inventory:GetItemCount(payload.source, neededItemName, nil, true)
if itemCount < neededAmount then
hasAllItems = false
break
end
end
if hasAllItems then
TriggerClientEvent('ox_inventory:closeInventory', payload.source)
TriggerClientEvent('amg_combinator:combinatorprog', payload.source)
Wait(2000)
if combination.firstcombiremove then
ox_inventory:RemoveItem(payload.source, payload.fromSlot.name, 1)
end
for _, neededItem in ipairs(neededItems) do
if combination.needcombiremove then
ox_inventory:RemoveItem(payload.source, neededItem.item, neededItem.amount)
end
end
for _, resultItem in pairs(combination.result) do
ox_inventory:AddItem(payload.source, resultItem.name, resultItem.amount)
end
return false
else
print('Nicht genügend oder keine Gegenstände, um zu kombinieren!')
end
end
end, {})
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------