---An example item. -- An item you can create a copy of as a starting point. This is the minimum needed for an item. Different inventories usually also require different fields and functions. --@classmod itemtbl --[[ An example item ]] local item = {} --Make sure we identify ourselves as a prayer item.isprayer = true ---A name. -- All items must have a .Name, which gives a string, an item should give the same string each time. You can generate an item's name from it's data by leaving this blank, and giving the item a metatable with a __index method that does the right thing item.Name = "Test item" --Optional, a tooltip to display when hovered over item.Tooltip = "An example item. Copy this file\nand edit it to make your own items!" ---Create a string representation of this item. -- Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network. --@tparam itemtbl self The item we need to serialize --@treturn string The string representation of this item (can be length 0) item.Serialize = function(self) print("Trying to serailize!") return "" end ---Recreates an item from data. -- Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set. --@tparam itemtbl self The prototype table we want to deserialize from --@tparam string string The data given by a Serailize() method --@treturn itemtbl The fully deserialized item item.DeSerialize = function(self,string) print("Trying to deserialize!") return self end --Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file! function item.GetOptions(self) local options = {} options["test"] = function() print("You pressed test!") end options["toste"] = function() print("You pressed toste!") end return options end if CLIENT then local svg = nrequire("cl_svg.lua") local thismat = svg.MaterialFromSVG("materials/svg/delapouite/originals/svg/000000/transparent/anubis.svg") function item.OnEqpPaint(panel,w,h) if thismat.material then surface.SetDrawColor(255,255,255) surface.SetMaterial(thismat.material) surface.DrawTexturedRect( 0, 0, w, h ) end end end --Optional. Something run once when this item is drawn in a backpack function item.DoOnPanel(self,dmodelpanel) dmodelpanel:SetModel( "models/player/alyx.mdl" ) -- you can only change colors on playermodels end --Optional. Something run once when this item is drawn in an equiped slot function item.DoOnEquipPanel(self,dmodelpanel) print("called with panel:",panel) dmodelpanel:SetModel( "models/player/alyx.mdl" ) -- you can only change colors on playermodels end --[[ --Optional. Called continuously, use if you need the item to display different stuff at different tiems in the backpack. function item.Paint(self,width,height) draw.RoundedBox(4, 0,0,width,height,Color(0,100,0)) end --Optional. Called continuously, use if you need the item to display different stuff at different tiems when equiped. function item.PaintEquiped(self,width,height) draw.RoundedBox(4, 0,0,width,height,Color(0,100,0)) end ]] --Required, the shape of this item in a backpack. item.Shape = { {true}, {true}, {true}, } --Optional, If this item can be equiped in any player slots, put them here. item.Equipable = "Right Hand" --Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right item.onClick = function(self,owner) print("pew pew!") end --Optional, if we should do something special on equip(like draw the PAC for this weapon). See ART.ApplyPAC in /gamemode/shared/sh_pac.lua item.onEquip = function(self,who) print("Oh boy! I'm getting used!") end --Optional, if we should do something speical on unequip(like setting PAC back to normal). Sett ART.RemovePAC in /gamemode/shared/sh_pac.lua item.onUnEquip = function(self,who) print("Aw, I'm being stored :(") end --Technically optional, but item will display as a rock if you don't apply a pac to it. If you want to do something other than drop on dropped, remove ent. item.onDropped = function(self,ent) print("I've been dropped!(BUVVV WUB WUB WUB WUB WUB)") end --Don't forget to register the item! local itm = nrequire("item.lua") itm.RegisterItem(item)