Custom
Explanation
Items with the Type = "Custom" will execute custom code when purchased.
Code Example
CH_NPC_Shops.Items["item_custom_explosive"] = { -- Unique name of the item
Name = "Boom Boom", -- Display name in the menu
Class = "Custom", -- Set as Custom for custom items.
Type = "Custom", -- Set as Custom for custom items.
Price = 15000, -- The price of the item
Description = "Buying this item executes a custom piece of code that will blow you up.", -- Description in menu
Model = "models/props_phx/ww2bomb.mdl", -- Model to display
Color = Color( 160, 0, 0 ), -- Color behind the model in menu
CanBuy = true, -- If the item can be bought from the store
ItemFunction = function( ply, npc ) -- The custom code that is executed
local bomb_pos = ply:GetPos()
local effectdata = EffectData()
effectdata:SetStart( v )
effectdata:SetOrigin( v )
effectdata:SetScale( 1 )
util.Effect( "c4_explosion", effectdata )
util.BlastDamage( ply, ply, bomb_pos, 1000, 85 )
end,
}