you must call this function in a loop or add a loop to the function. From what you posted it is most probable that you are only calling the shoot function one time at the beginning of your program and that will just not work.
change your shoot function:
function shoot()
{
while(1)
{
while (mouse_left)
{
if ((gun[g_type][1] > 0))
{
[...]
}
wait(-5); // Trying to delay that while, thus when
// holding mouse_left I'd get intervals
// for about 5 seconds...
}
}
}