I added a kill log now. But I got a problem here.
[b]init.lua[/b]
[lua]
function playerDies( victim, inflictor, attacker )
if attacker == victim then
filex.Append("DPMod/logs/log.txt", attacker:Name() .. " suicided" .. "\n")
else
filex.Append("DPMod/logs/log.txt", attacker:Name().." killed "..victim:Name().. "\n")
end
end
hook.Add( "PlayerDeath", "playerDeathTest", playerDies )
[/lua]
[b]Now I'm running file.Read in a DListView:[/b]
[lua]
local DPModDListView6 = vgui.Create("DListView")
DPModDListView6:SetParent(Kill)
DPModDListView6:SetPos(3, 5)
DPModDListView6:SetSize(343, 400)
DPModDListView6:SetMultiSelect(false)
DPModDListView6:AddColumn("Attacker, Victim & Weapon")
DPModDListView6:AddLine( file.Read("DPMod/logs/log.txt") )
[/lua]
But it show's up like this:
[URL=http://img228.imageshack.us/i/40128526.png/][IMG]http://img228.imageshack.us/img228/8458/40128526.png[/IMG][/URL]
How can I get the text, that gets written by file.write to each line of the DListView?
[lua]for _,line in pairs(string.Explode("\n",file.Read("DPMod/logs/log.txt"))) do
DPModDListView6:AddLine(line);
end[/lua]
Read the file, and use the string.Explode function to break it up into a table of strings based on the newline.
Thanks.
[editline]11th January 2011[/editline]
The code worked.
Sorry, you need to Log In to post a reply to this thread.