Only allowed to buy entities if there is no certain job?

Hey, I’ve been trying for a while now to make it so you can buy fire extinguishers ONLY if there is no fireman job online? How would i do this? Please help thanks.

[lua]
function buyextinguisher(ply)
for k, v in pairs(player.GetAll()) do
if(v:IsFireman()) then
– someone is a fireman so we return false and disallow the function from running
return false
end
end
– spawn extinguisher here
end
[/lua]

for example.

Basically you loop through all players when someone wants to buy a extinguisher, and if anyone is a fireman then return the function to prevent it from running further. If noone is, then let it continue to run and spawn the extinguisher.