• Please explain!
    4 replies, posted
Ok as some of you might know I'm having alot of trouble with my damage logs! I have no clue whats wrong with this one. [CODE]local ply = LocalPlayer() function damage(ply, inflictor, attacker) if ( ply:SteamID() == attacker:SteamID() ) then suicide = ply:Name() .. " Killed His self!\n" else killed = ply:Name(), " Was killed by " .. attacker:Name() .. "." end function damagelog(ply) if ply:GetNWString("usergroup") == "superadmin" then RunConsoleCommand( "say", killed ) end end end concommand.Add("print_dlog", damagelog) hook.Add( "PlayerDeath", "DamageLog", damage ) [/CODE] Ingame Error I get: [QUOTE]Unknown Command: 'print_dlog' [/QUOTE] Please say whats wrong, Also if you know how to make damage logs please add me on skype: PabloSky11400 I will be willing to pay for help but you please deliver the help first. Again. Post all what is wrong please Thanks [IMG]http://s24.postimg.org/80iy25k3p/Captur2e.png[/IMG]
Use lua bbcode tags next time you post instead of a quote. As for the error, it looks like you aren't properly ending the damage function. The trailing 'end' keyword in the third line from the bottom should be moved to before the damagelog function declaration.
Can you post the code please? I'll update the thing now
[lua]function damage(ply, inflictor, attacker) if ( ply:SteamID() == attacker:SteamID() ) then suicide = ply:Name() .. " Killed His self!\n" else killed = ply:Name(), " Was killed by " .. attacker:Name() .. "." end end hook.Add( "PlayerDeath", "DamageLog", damage ) function damagelog(ply) if ply:GetNWString("usergroup") == "superadmin" then RunConsoleCommand( "say", killed ) end end concommand.Add( "print_dlog", damagelog )[/lua] The variable 'ply' you defined at the top of your code wasn't necessary as that parameter is passed to the damagelog function from the concommand. This is also the case with the damage function except that the player is passed from the hook. [editline]4th December 2013[/editline] After examining the code again, it seems you don't quite understand Lua scopes. You may want to read up on them here: [url]http://lua-users.org/wiki/ScopeTutorial[/url]
Feel stupid that I didn't check the whole code lol
Sorry, you need to Log In to post a reply to this thread.