Problem with TTT_Stats (a Leaderboard) addon... Any help or thoughts welcome.
4 replies, posted
I recently found and installed 'ttt_stats', just a simple leaderboards addon, and while it is appearing in my server and 'F11' is working to access it, it's not collecting any data or kills or deaths from the rounds.
[IMG]http://gyazo.com/d2e518a2c70d2cef08c967cabab21f04.png[/IMG]
Only error i see in the console.
Any thoughts or suggestions or anything else I need to post for someone to figure out what's wrong?
Thanks in advance.
Edit:
There's only one file in the whole addon total.
it's called 'ttt_stats.lua'
Here's the code:
[CODE]TTTStats = {}
TTTStats.ChatTime = 0
--CONFIG SETTINGS--
TTTStats.StatsKey = "F11" -- Use whatever key you please (Best to use F1-F4) or none to assign a key for triggering the Stats Menu
TTTStats.ChatReminder = true -- Use false/true to toggle the chat reminder for the chat function (every X minutes it will say in the chat that you can use !stats to trigger it)
TTTStats.ChatReminderTime = 3 -- Minutes for each chat reminder
--CONFIG SETTINGS--
if SERVER then
AddCSLuaFile()
util.AddNetworkString("tttstats")
local ply = FindMetaTable("Player")
local testtab = {}
testtab["Name"] = ""
testtab["FirstJoin"] = ""
testtab["Kills"] = 0
testtab["Deaths"] = 0
testtab["Rounds"] = 0
testtab["Karma"] = 1000
testtab["Innocent"] = 0
testtab["Traitor"] = 0
testtab["Detective"] = 0
testtab["TKilled"] = 0
testtab["DKilled"] = 0
testtab["IKilled"] = 0
testtab["TRound"] = 0
function ply:UpdateStats( kill, dead, round, karma, inno, traitor, det, tkill, dkill, ikill, tround )
local tab = self:GetStats()
tab["Name"] = self:GetName()
tab["Kills"] = tab["Kills"] + (kill or 0)
tab["Deaths"] = tab["Deaths"] + (dead or 0)
tab["Rounds"] = tab["Rounds"] + (round or 0)
tab["Karma"] = tab["Karma"] + (karma or 0)
tab["Innocent"] = tab["Innocent"] + (inno or 0)
tab["Traitor"] = tab["Traitor"] + (traitor or 0)
tab["Detective"] = tab["Detective"] + (det or 0)
tab["TKilled"] = tab["TKilled"] + (tkill or 0)
tab["DKilled"] = tab["DKilled"] + (dkill or 0)
tab["IKilled"] = tab["IKilled"] + (ikill or 0)
if tround then tab["TRound"] = tround end
self:SetStats(tab)
end
function ply:SetStats( tab )
//FOLDER CHECK
local there = file.Exists("tttstats", "DATA")
if !there then file.CreateDir( "tttstats" ) end
file.Write("tttstats/"..self:UniqueID()..".txt", util.TableToJSON(tab) )
end
function ply:GetStats()
local read = file.Read("tttstats/"..self:UniqueID()..".txt","DATA")
if read == nil or read == "" then
testtab["FirstJoin"] = os.date()
testtab["Name"] = self:GetName()
self:SetStats( testtab )
return testtab
end
return util.JSONToTable( read )
end
hook.Add("TTTEndRound", "ttt_stats", function( win )
for k, v in pairs(player.GetAll()) do
if !v:IsBot() then
local inno, tr, det, tround, bestround
if v:GetRole() == 0 then
inno = 1
elseif v:GetRole() == 1 then
tr = 1
elseif v:GetRole() == 2 then
det = 1
end
local tround = v:GetStats()["TRound"] or 0
local bestround = v:GetNWInt("TraitorKills")
local dead = v:GetNWInt("STATS_Death")
local kill = v:GetNWInt("STATS_Kills")
local tkill = v:GetNWInt("STATS_TKilled")
local dkill = v:GetNWInt("STATS_DKilled")
local ikill = v:GetNWInt("STATS_IKilled")
if bestround > tround then
tround = bestround
end
v:UpdateStats( kill, dead, 1, v:GetBaseKarma(), inno, tr, det, tkill, dkill, ikill, tround )
v:SetNWInt("TraitorKills", 0)
v:SetNWInt("STATS_Death", 0)
v:SetNWInt("STATS_Kills", 0)
v:SetNWInt("STATS_TKilled", 0)
v:SetNWInt("STATS_DKilled", 0)
v:SetNWInt("STATS_IKilled", 0)
end
end
end)
hook.Add("PlayerDeath", "ttt_stats_death", function( vic, wep, kil )
if vic:IsPlayer() and !vic:IsBot() then
vic:SetNWInt("STATS_DEATH", vic:GetNWInt("STATS_DEATH") + 1)
end
if kil:IsPlayer() and !kil:IsBot() then
if kil:GetRole() == ROLE_TRAITOR and vic:GetRole() == ROLE_DETECTIVE then
kil:SetNWInt("TraitorKills", kil:GetNWInt("TraitorKills") + 1)
kil:SetNWInt("STATS_DKilled", kil:GetNWInt("STATS_DKilled") + 1)
elseif kil:GetRole() == ROLE_TRAITOR and vic:GetRole() == ROLE_INNOCENT then
kil:SetNWInt("TraitorKills", kil:GetNWInt("TraitorKills") + 1)
kil:SetNWInt("STATS_IKilled", kil:GetNWInt("STATS_IKilled") + 1)
elseif (kil:GetRole() == ROLE_INNOCENT or kil:GetRole() == ROLE_DETECTIVE) and vic:GetRole() == ROLE_TRAITOR then
kil:SetNWInt("STATS_TKilled", kil:GetNWInt("STATS_TKilled") + 1)
end
kil:SetNWInt("STATS_Kills", kil:GetNWInt("STATS_Kills") + 1)
end
end)
hook.Add("PlayerInitialSpawn", "ttt_stats_init", function( ply )
ply:GetStats()
end)
local cc = 200
local TimerDelay = 0.5
local TriggerFunc = "ShowSpare2"
local TF = {}
TF["F1"] = "ShowHelp"
TF["F2"] = "ShowTeam"
TF["F3"] = "ShowSpare1"
TF["F4"] = "ShowSpare2"
if TTTStats and TTTStats.StatsKey and TF and TF[TTTStats.StatsKey] then TriggerFunc = TF[TTTStats.StatsKey] end
function OpenMenu( ply, ply2 )
if ply.StatCheck == nil or CurTime() > ply.StatCheck then
local files = file.Find( "tttstats/*", "DATA")
local count = table.Count(files)
for k, v in pairs(player.GetAll()) do
v:GetStats()
end
net.Start( "tttstats" )
net.WriteString("STARTDATA;"..math.ceil(count/cc))
net.WriteString( tostring(ply2 and ply2:EntIndex() or 0) )
net.Send( ply )
timer.Create( "TTTStats_"..ply:SteamID(), TimerDelay, math.ceil(count/cc), function ()
local i = 0
local tab = {}
for k, v in pairs(files) do
if i >= cc then break end
i = i + 1
local f = file.Read("tttstats/"..v, "DATA")
tab[string.Left( v, string.len(v)-4 )] = f != nil and f != "" and util.JSONToTable(f) or testtab
files[k] = nil
end
net.Start( "tttstats" )
net.WriteString("")
net.WriteTable(tab)
net.Send( ply )
count = count - cc
end)
ply.StatCheck = CurTime() + math.min( (math.ceil(count/cc) * TimerDelay), 2 )
end
end
hook.Add("PlayerSay", "ttt_stats_say", function( ply, text, public )
local exp = string.Explode(" ", string.Trim(text))
if exp[1] == "!stats" then
exp[1] = ""
local name = string.Trim(string.Implode(" ", exp))
local ply2 = nil
if name != nil and name != "" then
for k, v in pairs(player.GetAll()) do
if v:GetName() == name then
ply2 = v
break
end
end
end
if name != nil and name != "" and ply2 == nil then
for k, v in pairs(player.GetAll()) do
if string.find(string.lower(v:GetName()), string.lower(name)) then
ply2 = v
break
end
end
end
OpenMenu(ply, ply2)
return ""
end
end)
net.Receive("tttstats", function( len, ply )
timer.Destroy("TTTStats_"..ply:SteamID())
OpenMenu(ply)
end)
else
TTTRankList = {}
TTTStatsMenu = nil
local tcol, icol, dcol, txcol, bcol = Color( 175, 20, 20, 255 ), Color( 20, 175, 20, 255 ), Color( 20, 20, 175, 255 ), Color( 240, 240, 240, 200 ), Color( 0, 0, 0, 240 )
surface.CreateFont( "CloseCaption_Bold", { font = "Tahoma", size = 16, weight = 600 } )
surface.CreateFont( "CloseCaption_Bold2", { font = "Tahoma", size = 36, weight = 600 } )
surface.CreateFont( "CloseCaption_Bold3", { font = "Tahoma", size = 24, weight = 600 } )
function BuildStatsMenu( ply )
TTTStatsMenu = vgui.Create( "DFrame" )
TTTStatsMenu:SetSize( 400, 640 )
TTTStatsMenu:Center()
TTTStatsMenu:SetTitle( "TTT Player Stats" )
TTTStatsMenu:SetVisible( true )
TTTStatsMenu:SetDraggable( false )
TTTStatsMenu:ShowCloseButton( true )
TTTStatsMenu:MakePopup()
TTTStatsMenu.Paint = function()
draw.RoundedBox(0, 0, 0, 400, 23, bcol)
end
TTTStatsMenu.MyInfoPanel = vgui.Create( "DPanel", TTTStatsMenu )
TTTStatsMenu.
Ask addon author first.
[QUOTE=Robotboy655;44656269]Ask addon author first.[/QUOTE]
No idea who it is.
I googled 'ttt leaderboard addon' clicked some links, downloaded some files, and added them and tried it out, no author listed.
Nor does the addon.txt.
;)
Dumb as it may be, but it doesn't change the facts.
Also, if anyone just wants to post. "I'm not going to help you, go somewhere else."
Just don't post. Thanks.
[QUOTE=Perfected;44656283]No idea who it is.
Got it from a leak site.
Leak site didnt say, nor does the addon.txt.
;)[/QUOTE]
go ask on the leak site then, you're not going to get help here
[QUOTE=rejax;44656291]go ask on the leak site then, you're not going to get help here[/QUOTE]
Oh sorry, was just kidding about the leak site.
Didn't mean leak site.
Just meant.
I googled 'ttt leaderboard addon' clicked some links, downloaded some files, and added them and tried it out.
Sorry for offending you?
Edit:
If you're just going to post saying you're not willing to help, don't post please.
Edit 2:
This is literally what I have, and it's free... and i think this one will work better.
So disregard my thread everyone, thanks.
[url]http://www.facepunch.com/showthread.php?t=1277865[/url]
Sorry, you need to Log In to post a reply to this thread.