Making an Item

When designing an item, impulse makes it fairly straight forward. Your best tool is the Reference Documentation. At it's core, Items are made through the ITEM table, provided to files loaded from a /items directory.

Example Item.

Here is an example item to see how everything works.

ITEM.UniqueID = "testitem"
ITEM.Name = "Nick's Test Item"
ITEM.Desc =  "A hidden item used to test the inventory system."
-- This data can be automatically generated with impulse_debug_icon
ITEM.Model = Model("models/props_lab/box01a.mdl")
ITEM.FOV = 20.392550143266
ITEM.CamPos = Vector(22.005731582642, 25, 9)
ITEM.Weight = 2

ITEM.Colour = Color(255, 0, 0)

ITEM.Droppable = true
ITEM.DropOnDeath = false

ITEM.DropIfRestricted = false
ITEM.DropOnDeathIfRestricted = false
ITEM.CraftIfRestricted = false

ITEM.Illegal = false
ITEM.Equipable = true
ITEM.EquipGroup = "hat"
ITEM.CanStack = true

ITEM.UseTime = 50
ITEM.FreezeOwnerOnUse = true

function ITEM:OnEquip(ply)
end

function ITEM:UnEquip(ply)
end

function ITEM:CanUse(owner, userEnt)
    -- Return either true or false here.
end

function ITEM:OnUse(ply)
    -- Write code that executes on successful pass of CanUse here, return true to remove item.
end

function ITEM:OnDrop(ply, ent)
end

function ITEM:OnReload(ply)
    -- Custom option!
end

ITEM.CustomActions = {}
ITEM.CustomActions["Reload"] = ITEM.OnReload

Designing a SWEP linked Item.

Items that give the player a SWEP have 1 property in the table to do this, WeaponClass.

This will give the player a Gravity Gun upon equipping the Item.

ITEM.WeaponClass = "weapon_physcannon`

The rest of the design is the same as any other Item.

Designing an Attachment linked Item (Longsword Weapon Base)

Items that give the player an Attachment have 1 property in the table to do this, AttachmentClass.

This will give the player a Hunting Scope (if the server is running the HL2RP schema) upon equipping the Item.

ITEM.AttachmentClass = "hunting_scope`

The rest of the design is the same as any other Item.