Please explain!

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.


local ply = LocalPlayer()

function damage(ply, inflictor, attacker)
     if ( ply:SteamID() == attacker:SteamID() ) then
          suicide = ply:Name() .. " Killed His self!
"
     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 )


Ingame Error I get:

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

http://s24.postimg.org/80iy25k3p/Captur2e.png

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!
"
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: http://lua-users.org/wiki/ScopeTutorial

Feel stupid that I didn’t check the whole code lol