Minor crafting progress

master
AlmTech Software 5 years ago
parent e236c785a4
commit 93c68a7073
  1. 7
      gamemode/engine/lib/server/sv_crafting.lua
  2. 17
      gamemode/engine/lib/server/sv_inventory.lua

@ -38,13 +38,18 @@ function Quantum.Server.Crafting.MakeItem( pl, itemid )
timer.Create( "Quantum_Crafting_" .. pl:SteamID64(), recipe.delay, 1, function()
-- remove the ingridients from the players inv
Quantum.Server.Inventory.FindItemSlots( pl, itemid, inv )
for k, reqItem in pairs( recipe.recipe ) do
print( "##", k, reqItem.item )
end
-- create item
end)
else
-- Dont make the item
Quantum.Server.Notify.Deny( pl, "You don't have sufficient resources to create that item!" )
Quantum.Notify.Deny( pl, "You don't have sufficient resources to create that item!" )
end
end

@ -402,6 +402,19 @@ function Quantum.Server.Inventory.EatItem( pl, index )
end
function Quantum.Server.Inventory.FindItemSlots( pl, itemid )
return
function Quantum.Server.Inventory.FindItemSlots( pl, itemid, inv )
local char = Quantum.Server.Char.GetCurrentCharacter( pl )
inv = inv || Quantum.Server.Char.GetInventory( char )
local indexes = {}
for i, item in pairs( inv ) do
if( item != nil ) then
if( item[1] == itemid ) then
indexes[ #indexes + 1 ] = i
end
end
end
return indexes
end
Loading…
Cancel
Save