I want that when the player's magazine reaches zero, he can no longer shoot even if he is pressing the shoot button, how could I cancel that function when the counter reaches zero?

if input.is_action_just_pressed:
shoot();
else:
if global.no_ammo <= 0:
(null function shoot)

Flip your condition.
Something like:

if input.is_action_just_pressed:
 if global.ammo > 0:
  shoot()
 else: 
  (what happens when player attempts shooting without ammo)
3 Likes