you just need to create an item as weapon and a consumable item as bullet
using a trigger when the unit is wearing that weapon just make a boelan variable to true and if the unit disarm that weapon just make it false.
Using another trigger with event when the unit attack with condition if that boelan variable is true then do the action. In the action section use an integer variable to store the number of consumable item's charge, use if/then/else multiple function and fill the "if" with if integer variable greater than or equal to 0 and action, just use a math function to reduce the charge by one. And if the intger variable value is 0 just order the hero to stop, so he won't be attacking.
Sorry i can't make a trigger for you because for now i'm not in home
Edit:
I've just seen the link you gave, it's using an ability instead of ordinary attack
just change the event when that unit begin casting an ability and do the same thing. oh don't forget to make the ability has a casting time at least 0.1 second, so the unit can be stoped if the charge is 0