I am trying to remove all edits from the core TTT files and make the overrides in addon format. This last function is giving me some problems and I can't seem to come up with a solution. Any help would be very much appreciated!
[lua]
local function PrintDamageLog(ply)
local pr = GetPrintFn(ply)
if (not IsValid(ply)) or ply:IsSuperAdmin() or GetRoundState() != ROUND_ACTIVE or (ply:IsAdmin() and not ply:Alive()) then
-- ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console")) --Returns error, more concerned about line:12
pr("*** Damage log:\n")
if not dmglog_console:GetBool() then
pr("Damage logging for console disabled. Enable with ttt_log_damage_for_console 1.")
end
for k, txt in ipairs(GAMEMODE.DamageLog) do --Returns error here
pr(txt)
end
pr("*** Damage log end.")
else
if IsValid(ply) then
pr("You do not appear to be RCON or a superadmin, nor are we in the post-round phase!")
end
end
end
concommand.Add("ttt_print_damagelog", PrintDamageLog)
[/lua]
[ERROR] addons/Overrides/lua/autorun/client/cl_ttt_overrides.lua:12: bad argument #1 to 'ipairs' (table expected, got nil)
[QUOTE=Swiftone;45300903]I am trying to remove all edits from the core TTT files and make the overrides in addon format. This last function is giving me some problems and I can't seem to come up with a solution. Any help would be very much appreciated!
[lua]
local function PrintDamageLog(ply)
local pr = GetPrintFn(ply)
if (not IsValid(ply)) or ply:IsSuperAdmin() or GetRoundState() != ROUND_ACTIVE or (ply:IsAdmin() and not ply:Alive()) then
-- ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console")) --Returns error, more concerned about line:12
pr("*** Damage log:\n")
if not dmglog_console:GetBool() then
pr("Damage logging for console disabled. Enable with ttt_log_damage_for_console 1.")
end
for k, txt in ipairs(GAMEMODE.DamageLog) do --Returns error here
pr(txt)
end
pr("*** Damage log end.")
else
if IsValid(ply) then
pr("You do not appear to be RCON or a superadmin, nor are we in the post-round phase!")
end
end
end
concommand.Add("ttt_print_damagelog", PrintDamageLog)
[/lua]
[ERROR] addons/Overrides/lua/autorun/client/cl_ttt_overrides.lua:12: bad argument #1 to 'ipairs' (table expected, got nil)[/QUOTE]
From my quick glance at the code, GAMEMODE.DamageLog is a server side variable declared at line 189 of init.lua. From what I can tell you are trying to use a server variable in a client lua state.
[QUOTE=Mythikos;45302125]From my quick glance at the code, GAMEMODE.DamageLog is a server side variable declared at line 189 of init.lua. From what I can tell you are trying to use a server variable in a client lua state.[/QUOTE]
How embarrassing, for some reason I was thinking this was a client-side script for TTT. I ended up moving this function to a server side file and now it's telling me 'ttt_print_damagelogs is a unknown command'
Any ideas?
[QUOTE=Handsome Matt;45307861]Because the command is called ttt_print_damagelog maybe?[/QUOTE]
Thanks, but that was just a typo in my post.
[QUOTE=Swiftone;45307931]Thanks, but that was just a typo in my post.[/QUOTE]
*snip*
nvm
EDIT: Can you post the function?
Jesus Christ I woke up today and it seems to be working. I haven't done a god damn thing between yesterday and today. Looks like I wasted 3-4 hours for nothing =D
Sorry, you need to Log In to post a reply to this thread.