Spectators on fire

Hello. I was wondering if there were any fixes for this.

Those on the dead team can be set on fire from multiple ways (such as dying from lava on some maps), damaging others who are alive. Searching didn’t bring anything up, so here I am. ;]

All help is appreciated.

Something like this, should work for TTT but not incredibly optimised.
[Lua]
hook.Add( “Think”, “CheckForSpecFire”, function()
for k,v in pairs( player.GetAll() ) do
if v:IsOnFire() and v:IsSpec() then
v:Extinguish()
end
end
end)
[/lua]

Put it in lua/autorun/server

Doing it on PlayerDeath would be better.


hook.Add( "PlayerDeath", "ExtinguishGhosts", function( _p, _inflictor, _attacker )
	if ( IsValid( _p ) && _p:IsOnFire( ) ) then
		_p:Extinguish( );
	end
end );

Is there any code like this for spectators holding weapons?

player:RemoveAllItems( )
But how did they get weapon in first place?

It seems as if i spawn into the server a second before the server starts, i get the gun in my hand. Or if i go into spectator mode 1 second before the game starts, it spawns in my hand.

are you using addon that gives player selected loadout or something similar that gives player guns?

Pointshop is the only thing i could think of

I’m pretty sure pointshop is removing all equipped items on death so it’s probably not pointshop.

Can’t seem to think of any addons that would mess with the load out.
Do you know if “player:RemoveAllItems( )” would override whatever that is?

you can try something like this:



hook.Add( "PlayerDeath", "ExtinguishGhosts", function( _p, _inflictor, _attacker )
	if IsValid( _p ) then
           _p:RemoveAllItems( )
           if _p:IsOnFire( ) then
		_p:Extinguish( );
           end
	end
end );


Or you can try this



hook.Add( "TTTBeginRound", "CheckForGunz", function() 
for k,ply in pairs( player.GetAll() ) do 
   if IsValid (ply) and ply:IsSpec() then 
       ply:RemoveAllItems()
   end 
end 
end)


Thank you :smiley: I’ll test this out.

Also is there a way to check for spectators in general? There are some fire weapons out that that can light spectators on fire if they are within in the general radius of the explosion.

You have to give us code of those weapons or use think hook instead playerdeath