I would advise using ACS with decorate for more flexibility, but here is a decorate-only basic example that should give you some idea.
Code:
ACTOR NC_Pistol : Pistol
{
Weapon.SlotNumber 8
States
{
Fire:
PISG A 4
PISG B 6 A_FirePistol
TNT1 A 0 A_JumpIfInventory("Clip", 50, 4)
TNT1 A 0 A_JumpIfInventory("Clip", 49, 5)
TNT1 A 0 A_JumpIfInventory("Clip", 1, 2)
TNT1 A 0 A_PlaySound("misc/w_pkup", CHAN_VOICE) // No ammo sound
PISG C 4
PISG B 5 A_ReFire
Goto Ready
TNT1 A 0 A_PlaySound("misc/p_pkup", CHAN_VOICE) // Low ammo sound
Goto Fire+6
}
}
This is a pistol that when it gets low on ammo it plays a sound (low ammo sound) and when it runs out of ammo it plays a different sound (no ammo sound). In other words, when you have 49 bullets after the last shot you shot, the
low ammo sound will be played and when you have zero bullets after the last shot you shot, the
no ammo sound will be played in this case.
If you are interested why I chose 49 as "low", that is because of ZDoom's alternative hud displaying the ammo counter in red if you have 49 bullets or less and no backpack.