Making People die as prop_npc

Hi, I am currently configuring Excl’s Jailbreak for my server. But I want to make people turn into NPC bodys so other players can walk through when when there dead. And also custom models have dead bodys instead of black figures.
Here is the current verison of the lua script turning people into ragdolls:

sv_player_hooks.lua:


function JB:PlayerDeath( p, a, d )
	if p:Team() == TEAM_PRISONER then
		p:SetTeam(TEAM_PRISONER_DEAD);
		local e = ents.Create("prop_ragdoll");
		e:SetModel(p:GetModel());
		e:SetPos(p:GetPos());
		e:GetAngles(p:GetAngles());
		e:SetVelocity(p:GetVelocity());
		e:Spawn();
		e:Activate();
		p:EmitSound(table.Random(DeathSounds),300,100);
		if p:Alive() then
			p:KillSilent()
			p:Spawn();
		end
	elseif p:Team() == TEAM_GUARD then -- or we simply check it.
		p:SetTeam(TEAM_GUARD_DEAD);
		local e = ents.Create("prop_ragdoll");
		e:SetModel(p:GetModel());
		e:SetPos(p:GetPos());
		e:GetAngles(p:GetAngles());
		e:SetVelocity(p:GetVelocity());
		e:Spawn();
		e:Activate();
		p:EmitSound(table.Random(DeathSounds),300,100);
		if p:Alive() then
			p:KillSilent()
			p:Spawn();
		end
	end
	if JB:RoundStatus() ~= ROUND_END then
		JB:CheckRoundEnd();
	end
end

But I want it to do this:


function JB:PlayerDeath( p, a, d )
	if p:Team() == TEAM_PRISONER then
		p:SetTeam(TEAM_PRISONER_DEAD);
		local e = ents.Create("prop_npc");
		e:SetModel(p:GetModel());
		e:SetPos(p:GetPos());
		e:GetAngles(p:GetAngles());
		e:SetVelocity(p:GetVelocity());
		e:Spawn();
		e:Activate();
		p:EmitSound(table.Random(DeathSounds),300,100);
		if p:Alive() then
			p:KillSilent()
			p:Spawn();
		end
	elseif p:Team() == TEAM_GUARD then -- or we simply check it.
		p:SetTeam(TEAM_GUARD_DEAD);
		local e = ents.Create("prop_npc");
		e:SetModel(p:GetModel());
		e:SetPos(p:GetPos());
		e:GetAngles(p:GetAngles());
		e:SetVelocity(p:GetVelocity());
		e:Spawn();
		e:Activate();
		p:EmitSound(table.Random(DeathSounds),300,100);
		if p:Alive() then
			p:KillSilent()
			p:Spawn();
		end
	end
	if JB:RoundStatus() ~= ROUND_END then
		JB:CheckRoundEnd();
	end
end

The only problem I’m having is when players die they have to jump to turn into spectator and then the round never restarts. I am then able to slay my self as a spectator through ULX.

Are you trying to just put them into spectate mode?


function JB:PlayerDeath( p, a, d )
	if p:Team() == TEAM_PRISONER then
		p:SetTeam(TEAM_PRISONER_DEAD);
		local e = ents.Create("prop_ragdoll");
		e:SetModel(p:GetModel());
		e:SetPos(p:GetPos());
                e:SetCollisionGroup( 11 );
		e:GetAngles(p:GetAngles());
		e:SetVelocity(p:GetVelocity());
		e:Spawn();
		e:Activate();
		p:EmitSound(table.Random(DeathSounds),300,100);
		if p:Alive() then
			p:KillSilent()
			p:Spawn();
		end
	elseif p:Team() == TEAM_GUARD then -- or we simply check it.
		p:SetTeam(TEAM_GUARD_DEAD);
		local e = ents.Create("prop_ragdoll");
		e:SetModel(p:GetModel());
		e:SetPos(p:GetPos());
                e:SetCollisionGroup( 11 );
		e:GetAngles(p:GetAngles());
		e:SetVelocity(p:GetVelocity());
		e:Spawn();
		e:Activate();
		p:EmitSound(table.Random(DeathSounds),300,100);
		if p:Alive() then
			p:KillSilent()
			p:Spawn();
		end
	end
	if JB:RoundStatus() ~= ROUND_END then
		JB:CheckRoundEnd();
	end
end

Try this. I set the collision group of the ragdoll to COLLISION_GROUP_WEAPON, so it doesn’t collide with players, but collides with everything else.
Resources to use: http://wiki.garrysmod.com/page/Entity/SetCollisionGroup
http://wiki.garrysmod.com/page/Enums/COLLISION

Try to play with the collision settings, if you’re having problems look into the code of the nocolide tool, and see what it applies on the entity.