• Code not executing, but no lua errors?
    6 replies, posted
I want code to execute on TTT when you're a Traitor and another Traitor dies, but for some reason this code doesn't work. :/ [CODE]if SERVER then AddCSLuaFile() else if LocalPlayer():GetRole() == ROLE_TRAITOR then for k, ply in pairs(player.GetAll()) do function GM:PlayerDeath( ply, inflictor, attacker ) if ( ply:GetRole() == ROLE_TRAITOR()) then --code end end end end end[/CODE] Any and all help is appreciated.
No reason to define that hook for every player. That's not how hooks work. Also GM:PlayerDeath() is serverside only and you're trying to run it on the client.
[QUOTE=RealDope;49597085]No reason to define that hook for every player. That's not how hooks work. Also GM:PlayerDeath() is serverside only and you're trying to run it on the client.[/QUOTE] Hmm...would [CODE]hook.Add( "PlayerDeath", "playerDeathTest", playerDies )[/CODE] Work?
Not on the client.
Your indenting is cancerous
You can use entity_killed clientside: [url]https://wiki.garrysmod.com/page/Game_Events[/url]
That hook is serverside, so [CODE]if SERVER then AddCSLuaFile() else[/CODE] has no sense, it would be [CODE] hook.Add("PlayerDeath", "whatever" , function(ply, inflictor, attacker) --your code(ply is the victim who dies) end)[/CODE]
Sorry, you need to Log In to post a reply to this thread.