ULX

Author Topic: Problem with custom ttt_print_traitors command... Help?  (Read 1870 times)

0 Members and 1 Guest are viewing this topic.

Twistedwheelbarrow

  • Guest
Problem with custom ttt_print_traitors command... Help?
« on: August 16, 2013, 02:42:28 PM »
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)