I'm trying to figure out the code below so that when the command is used, it only prints the traitors. Once I have done this, I want to be able to print the traitors, showing their status... E.g, dead traitors appear a different colour to living?
local function TraitorSort(a,b)
if not IsValid(a) then return true end
if not IsValid(b) then return false end
if a:GetTraitor() and (not b:GetTraitor()) then return true end
if b:GetTraitor() and (not a:GetTraitor()) then return false end
return false
end
function PrintTraitors(ply)
if not IsValid(ply) or ply:IsSuperAdmin() then
ServerLog(Format("%s used ttt_print_traitors\n", IsValid(ply) and ply:Nick() or "console"))
local pr = GetPrintFn(ply)
local ps = player.GetAll()
table.sort(ps, TraitorSort)
for _, p in pairs(ps) do
if IsValid(p) then
pr(p:GetTraitor() and "TRAITOR" or "Innocent", ":", p:Nick())
end
end
end
end
concommand.Add("ttt_print_traitors", PrintTraitors)