Quantum is a Garry's Mod RPG framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
quantum/gamemode/engine/lib/server/sv_inventory.lua

42 lines
1.1 KiB

-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Server.Inventory = {}
function Quantum.Server.Inventory.Create( char )
char.inventory = {}
for i = 1, Quantum.Inventory.Width do
char.inventory[i] = {}
end
for h, v in pairs( char.inventory ) do
for w = 1, Quantum.Inventory.Height do
char.inventory[h][w] = 0
end
end
return char.inventory
end
local function isEquippable( item )
return item.equipable || false
end
function Quantum.Server.Inventory.SetSlotItem( char, x, y, item, amount )
if( isEquippable( item ) ) then
amount = 1
char.inventory[x][y] = { item }
else
amount = amount || 1
char.inventory[x][y] = { item, amount }
end
Quantum.Debug( "Gave " .. char.name .. " " .. amount .. " [" .. item.name .. "]" )
return
end
function Quantum.Server.Inventory.GetSlotItem( char, x, y ) return char.inventory[x][y] end