You can also check the active weapon and compare the weapon index for specific things.
PHP Code:
new activeweapon = FindSendPropOffs("CTFPlayer", "m_hActiveWeapon");
for (new i = 1; i <= MaxClients; i++)
{
new weapon = GetEntDataEnt2(i, activeweapon);
if(IsValidEntity(weapon))
{
new weaponindex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
switch(weaponindex)
{
case 46:
{
//Dostuff if Bonk
}
case 163:
{
//Dostuff if Crit-a-Cola
}
case 42:
{
//Dostuff if Sandvich
}
case 311:
{
//DoStuff if Buffalo Steak
}
}
/*Or alternatively
switch(weaponindex)
{
case 46, 163, 42, 311:
{
//DoStuff for any of them
}
}
*/
}
}
Item Indexes(Can also be found in tf/scripts/items_game.txt)