From 93c68a707304a8849f061ccaca4b7c68934cd2d1 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Thu, 9 Jan 2020 20:28:33 +0100 Subject: [PATCH] Minor crafting progress --- gamemode/engine/lib/server/sv_crafting.lua | 9 +++++++-- gamemode/engine/lib/server/sv_inventory.lua | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gamemode/engine/lib/server/sv_crafting.lua b/gamemode/engine/lib/server/sv_crafting.lua index 889c60b..f6c4803 100644 --- a/gamemode/engine/lib/server/sv_crafting.lua +++ b/gamemode/engine/lib/server/sv_crafting.lua @@ -36,15 +36,20 @@ function Quantum.Server.Crafting.MakeItem( pl, itemid ) setPlayerIsCrafting( pl, true ) - timer.Create( "Quantum_Crafting_" ..pl:SteamID64(), recipe.delay, 1, function() + 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 diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index 9f762b2..bf2c91f 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -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 \ No newline at end of file