Temporarily Turn Off

I’m attempting to get this ulx revive command to work:


function ulx.respawn( calling_ply, target_ply )
	if target_ply:Team() == TEAM_GUARD_DEAD then
		target_ply:Spawn()
		target_ply:UnSpectate()
		target_ply:SetTeam( TEAM_GUARD )
		target_ply:Give( "weapon_fists" )
		ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )
	elseif target_ply:Team() == TEAM_PRISONER_DEAD then
		target_ply:Spawn()
        target_ply:UnSpectate()
		target_ply:SetTeam( TEAM_PRISONER )
		target_ply:Give( "weapon_fists" )
		ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )
	end
	
end
local respawn = ulx.command( "RespawnMe", "ulx respawn", ulx.respawn, "!respawn" )
respawn:addParam{ type=ULib.cmds.PlayerArg }
respawn:defaultAccess( ULib.ACCESS_ADMIN )
respawn:help( "Respawns a player" )

It spawns the player into the round, but they can not pick up weapons, be seen by other players, and can not be hurt by other players. It seems to be blocked by this:


function GM:ShouldPlayerSpectate(Player)
	return JB_ROUND_STATE == ROUND_DEAD or JB_ROUND_STATE == ROUND_END or JB_ROUND_STATE == ROUND_ACTIVE
	
 
end

When I delete JB_ROUND_STATE == ACTIVE, the command works, but it causes some other problems. Is there a way to temporarily disable this when the respawn command is called?

See how the gamemode handles spawning and do it the same way.

The command is still being blocked. Here’s how the gamemode handles spawning:


 for k, v in pairs( player.GetAll() ) do
			if (v:Team() == TEAM_GUARD_DEAD) then
				v:SetTeam(TEAM_GUARD);
			elseif (v:Team() == TEAM_PRISONER_DEAD) then
				v:SetTeam(TEAM_PRISONER);
			end;
		end;

		timer.Simple(0.01, function()
			self:BalanceTeams();
		end);

		timer.Simple(0.02, function()
			for k, v in pairs( player.GetAll() ) do			
				v:Spawn();
				v:Freeze(true);
			end;
		end); 

I tried to edit this to fit my command, but it ended up being similar to the command I had before. It would not work the way I wanted to.