TTT passive items

Recently started working on new weapons for the ttt server that I help run and I’ve been pushing myself to come up with decent ideas and have come up with the idea of some passive items (i.e. Items like the body armour that do not have to be “used” per se, just bought). Without giving anything away and asking everyone to do it for me I’m just having a little trouble figuring out how different they are to guns and similar weapons in terms of the coding.

I am in no way asking anyone to give me everything on a platter and don’t want that, however if anyone that has coded passive items before could give me an idea of how to make something a passive item without having to be manully “used” that’d be just awesome as I’m a little stuck.

I’ve created a passive item, here’s what you need:

[lua]
EQUIP_ITEMNAME = 8

local function Init()
local equipitem = {
id = EQUIP_ITEMNAME,
loadout = false,
type = “item_passive”,
material = “path/to/icon”,
name = “Equipment Item”,
desc = “Describe this”
}

  table.insert( EquipmentItems[ROLE_TRAITOR], equipitem )

end

hook.Add( “InitPostEntity”, “LoadEquipItem”, Init )
[/lua]

Where the ID is the bitflag of the item, should be power of two ( 2 and 4 are already taken for both roles )
Loadout means is it in the default loadout for the role it’s in
Type means is it passive or active
Material is the icon in the c store
Name is the name in the c store
Desc is the description in the c store

To check if a player has it:
[lua]
ply:HasEquipmentItem( EQUIP_ITEMNAME )
[/lua]

The function returns true or false, based on the state.
So you can do:
[lua]
hook.Add( “EntityTakeDamage”, “ScubaSet”, function( ply, dmginfo )
if ply:IsPlayer() and ply:HasEquipmentItem( EQUIP_SCUBASET ) and dmginfo:GetDamageType() == DMG_DROWN then
dmginfo:ScaleDamage( 0 )
end

 return dmginfo

end )
[/lua]

This would check if the player has a scuba set bought and if so, reduce all drowning damage to 0.

Ah that is actually exactly what I needed and is going to help me tonnes.

Cheers for that