I'm trying to make it so when you die it runs rp_citizen on the victim. The thing is when I die I spawn for a second and I can't move, And I don't have any weapons and the camera makes it look like I'm dead and when I click I re-spawn and I don't have any weapons and my model changed for some reason.I had this problem before so I tried to force spawn him with victim:Spawn() and that didn't work so I thought I was running the command to fast after there death or something so I made a timer.
[LUA]
function PlayerDies( victim, killer )
local rdoll = ents.Create( "prop_ragdoll" )
rdoll:SetModel( victim:GetModel( ) )
rdoll:SetPos( victim:GetPos( ) )
rdoll:Spawn( )
rdoll:Activate( )
timer.Create( "my_timer", 300, 1, function()
rdoll:Remove()
end )
if victim:Team() == 1 then
victim:Spawn()
timer.Create("timer3", 1, 1, victim.ConCommand, victim, "rp_citizen")
end
end
hook.Add( "PlayerDeath", "playerDeathTest", PlayerDies )
[/LUA]
If someone could help me that would be great.
[b][url=wiki.garrysmod.com/?title=Gamemode.DoPlayerDeath]Gamemode.DoPlayerDeath [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
And then, couldn't you just run the console command when the player spawns?
Call it on DoPlayerDeath so it happens before you finish dying.
[QUOTE=Dave_Parker]I think you're better off just calling the function rp_citizen calls. [/QUOTE]
I don't know what you mean by that. can you explain a little more?
When he dies just do:
victim:ConCommand("rp_citizen")
[LUA]
function GM:DoPlayerDeath( ply, attacker, dmginfo )
ply:ConCommand("rp_citzen")
end
[/LUA]
I tried doing that but It crashes my game. I also tried changing the Variables to victim, killer but that crashed it to. Any ideas?
Sorry, you need to Log In to post a reply to this thread.