daily pastebin goal
59%
SHARE
TWEET

List Players

Chalwk77 Jan 18th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. --=====================================================================================================--
  3. Script Name: List Players (SAPP alternative), for SAPP (PC & CE)
  4. Description: An alternative player list mod. Overrides SAPP's built in /pl command.
  5.  
  6. Command Syntax: /pl
  7.                 /players
  8.                 /playerlist
  9.                 /playerslist
  10.      
  11. Copyright (c) 2016-2018, Jericho Crosby <jericho.crosby227@gmail.com>
  12. Notice: You can use this document subject to the following conditions:
  13. https://github.com/Chalwk77/Halo-Scripts-Phasor-V2-/blob/master/LICENSE
  14.  
  15. ~ Written by Jericho Crosby (Chalwk)
  16. --=====================================================================================================--
  17. ]]
  18.  
  19. api_version = '1.12.0.0'
  20.  
  21. -- Configuration [starts] --
  22. -- Min admin level required to use these commands...
  23. min_admin_level = 1
  24.  
  25. -- Custom command(s)
  26. base_command = { "pl", "players", "playerlist", "playerslist" }
  27.  
  28. -- Message Alignment:
  29. -- Left = l,    Right = r,    Center = c,    Tab: t
  30. Message_Alignment = "l"
  31. -- Configuration [ends] --
  32.  
  33. function OnScriptLoad()
  34.     register_callback(cb['EVENT_COMMAND'], "OnServerCommand")
  35. end
  36.  
  37. function OnScriptUnload()
  38.  
  39. end
  40.  
  41. function OnServerCommand(PlayerIndex, Command, Environment, Password)
  42.     local t = tokenizestring(Command)
  43.     local count = #t
  44.     for k, v in pairs(base_command) do
  45.         if v then
  46.             local cmds = tokenizestring(v, ",")
  47.             for i = 1, #cmds do
  48.                 if (t[1] == cmds[i]) then
  49.                     if isAdmin(PlayerIndex) then
  50.                         listPlayers(PlayerIndex, count)
  51.                     else
  52.                         rprint(PlayerIndex, "Insufficient Permission")
  53.                     end
  54.                     return false
  55.                 end
  56.             end
  57.         end
  58.     end
  59. end
  60.  
  61. function listPlayers(PlayerIndex, count)
  62.     if (count == 1) then
  63.         rprint(PlayerIndex, "|" .. Message_Alignment .. " [ ID.    -    Name.    -    Team.    -    IP. ]")
  64.         for i = 1, 16 do
  65.             if player_present(i) then
  66.                 local name = get_var(i, "$name")
  67.                 local id = get_var(i, "$n")
  68.                 local team = get_var(i, "$team")
  69.                 local ip = get_var(i, "$ip")
  70.                 local hash = get_var(i, "$hash")
  71.                 if get_var(0, "$ffa") == "0" then
  72.                     if team == "red" then
  73.                         team = "Red Team"
  74.                     elseif team == "blue" then
  75.                         team = "Blue Team"
  76.                     else
  77.                         team = "Hidden"
  78.                     end
  79.                 else
  80.                     team = "FFA"
  81.                 end
  82.                 rprint(PlayerIndex, "|" .. Message_Alignment .. id .. ".   " .. name .. "   |   " .. team .. "  -  IP: " .. ip)
  83.             end
  84.         end
  85.     else
  86.         rprint(PlayerIndex, "Invalid Syntax")
  87.         return false
  88.     end
  89. end
  90.  
  91. function isAdmin(PlayerIndex)
  92.     if (tonumber(get_var(PlayerIndex, "$lvl"))) >= min_admin_level then
  93.         return true
  94.     else
  95.         return false
  96.     end
  97. end
  98.  
  99. function tokenizestring(inputstr, sep)
  100.     if sep == nil then
  101.         sep = "%s"
  102.     end
  103.     local t = { };
  104.     i = 1
  105.     for str in string.gmatch(inputstr, '([^' .. sep .. ']+)') do
  106.         t[i] = str
  107.         i = i + 1
  108.     end
  109.     return t
  110. end
  111.  
  112. function OnError(Message)
  113.     print(debug.traceback())
  114. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top