Advertisement
blockhaak2

ROBLOX script 2

Jun 30th, 2014
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 91.72 KB | None | 0 0
  1. game:GetService("StarterGui"):SetCoreGuiEnabled("PlayerList", false) -- Ctrl+F "API DOCS" to get the docs
  2.  
  3. --settings.  Don't make these local.
  4. ALLOW_BC_ICONS = true -- Players' BC icons will be shown next to their names
  5. PRIMARY_LEADERSTATS_ENABLED = true -- Leaderstats will appear in large text under the player's name
  6. SHOW_PRIMARY_LEADERSTAT_NAMES = true -- Primary leaderstats will have their names shown next to them
  7. TEAMS_ENABLED = true -- Teams will appear.
  8.  
  9. CUSTOM_CHAT_COLORS = { -- add your name = Color3 to give yourself a custom chat color.
  10.     -- if you don't choose a chat color, but you do add a custom icon, your color will appear as golden
  11.     -- if you don't want golden but you do want an icon, you can set your chat color to Color3.new(1,1,1)
  12.     arceusinator = Color3.new(000/255, 167/255, 213/255)
  13. }
  14.  
  15. HIDDEN_PLAYERS = { -- add playerName=true to prevent them from appearing on the leaderboard
  16.     example_player_name = true
  17. }
  18.  
  19. CUSTOM_LABEL_BACKGROUND_COLORS = { -- add playerName=color3 to give certain players a unique backgroundColor
  20.     Player1 = Color3.new(1, 0.5, 1)
  21. }
  22.  
  23. CUSTOM_LABEL_NAME_COLORS = { -- add playerName=color3 to give certain players a uniquely-colored name
  24.     Player1 = Color3.new(0, 0.5, 1)
  25. }
  26.  
  27. ADMINS =
  28. { -- add your name = 1 to get a star icon.  Add your name = image to get a custom icon.
  29.     arceusinator = "http://www.roblox.com/asset?id=150832060",
  30.     Jexton = "http://www.roblox.com/asset?id=134293950",
  31.     aceswayuphigh = 1,
  32.     adamintygum = 1,
  33.     afackler11 = 1,
  34.     aleverns = 1,
  35.     aquabot8 = 1,
  36.     arbolito = 1,
  37.     argforpirates = 1,
  38.     argonpirate = 1,
  39.     asmohdian = 1,
  40.     bellavour = 1,
  41.     blockhaak2 = 1,
  42.     brighteyes = 1,
  43.     briguy9876 = 1,
  44.     builderman = 1,
  45.     cdakkar = 1,
  46.     chiefjustus = 1,
  47.     chro = 1,
  48.     cmed = 1,
  49.     coatp0cketninja = 1,
  50.     codewriter = 1,
  51.     commandercrow = 1,
  52.     corgiparade = 1,
  53.     dapperbuffalo = 1,
  54.     dbapostle = 1,
  55.     deeana00 = 1,
  56.     doughtless = 1,
  57.     dunbar1138 = 1,
  58.     echodown = 1,
  59.     ffjosh = 1,
  60.     foyle = 1,
  61.     fusroblox = 'http://www.roblox.com/asset/?id=99852703',
  62.     gemlocker = 1,
  63.     goddessnoob = 1,
  64.     gongfutiger = 1,
  65.     gordonrox24 = 1,
  66.     gorroth = 1,
  67.     grossinger = 1,
  68.     groundcontroll2 = 1,
  69.     hawkeyebandit = 1,
  70.     hawkington = 1,
  71.     ibanez2189 = 1,
  72.     iltalumi = 1,
  73.     inventx = 1,
  74.     jeditkacheff = 1,
  75.     kbux = 1,
  76.     keith = 1,
  77.     limon = 1,
  78.     loopylens = 1,
  79.     lordrugdumph = 1,
  80.     majortom4321 = 1,
  81.     malcomso = 1,
  82.     maxvee = 1,
  83.     midwinterfires = 1,
  84.     mistersquirrel = 1,
  85.     morganic = 1,
  86.     motornerve = 1,
  87.     mrdoombringer = 1,
  88.     mse6 = 1,
  89.     newtrat = 1,
  90.     niquemonster = 1,
  91.     nobledragon = 1,
  92.     noob007 = 1,
  93.     nrawat1 = 1,
  94.     olive71 = 1,
  95.     onlytwentycharacters = 1,
  96.     orcasparkles = 1,
  97.     ostrichsized = 1,
  98.     phaedre = 1,
  99.     phil = 1,
  100.     pulmoesflor = 1,
  101.     raeglyn = 1,
  102.     rbadam = 1,
  103.     reesemcblox = 1,
  104.     robliu = 1,
  105.     roblowilson = 1,
  106.     robloxsai = 1,
  107.     roboyz = 1,
  108.     saurauss = 1,
  109.     screenme = 1,
  110.     scubasomething = 1,
  111.     seanthornton = 1,
  112.     shedletsky = 'http://www.roblox.com/asset/?id=105897927',
  113.     sickenedmonkey = 1,
  114.     slingshotjunkie = 1,
  115.     smeaferblox = 1,
  116.     soggoth = 1,
  117.     solarcrane = 1,
  118.     sooraya = 1,
  119.     sorcus = 'http://www.roblox.com/asset/?id=113059239',
  120.     squidcod = 1,
  121.     stickmasterluke = 1,
  122.     stuball = 1,
  123.     tabemono = 1,
  124.     tarabyte = 1,
  125.     thelorekt = 1,
  126.     thorasaur = 1,
  127.     timobius = 1,
  128.     tobotrobot = 1,
  129.     tone = 1,
  130.     totallynothere = 1,
  131.     totbl = 1,
  132.     twberg = 1,
  133.     vaiobot = 1,
  134.     varia = 1,
  135.     vladthefirst = 1,
  136.     wonderboy76 = 1,
  137.     xerolayne = 1,
  138.     yesth = 1,
  139.     yumyumcheerios = 1,
  140.     zeuxcg = 1,
  141.     zodiaczak = 1,
  142.     ['erik.cassel'] = 1,
  143.     ['david.baszucki'] = 1,
  144.     ['matt dusek'] = 1,
  145. }
  146.  
  147. ADMIN_ICON_WIDTHS = {
  148.     arceusinator = 30
  149. }
  150.  
  151. ALIASES = {
  152.     player1 = "PLAYER X",
  153.     arceusinator = "Sharks!",
  154.     blockhaak2 = "The Mighty Overlord"
  155. }
  156.  
  157. -- API DOCS
  158. -- _G.PlayerListAPI:SetAllowBCIcons(true or false)
  159. -- :AddAdmin(String name, Optional Content customIcon, Optional Int customIconWidth)
  160. -- :RemoveAdmin(String name)
  161. -- :SetAlias(String name, String alias)
  162. -- :SetPlayerIsHidden(String name)
  163. -- :SetLabelColors(String playerName, Color3 backgroundColor, Color3 textColor)
  164. -- _G.ChatAPI:SendChat(String playername, String message, Color3 customcolor)
  165.  
  166. for name,a in pairs(ADMINS) do
  167.     ADMINS[name:lower()] = a
  168. end
  169. for name,a in pairs(CUSTOM_CHAT_COLORS) do
  170.     CUSTOM_CHAT_COLORS[name:lower()] = a
  171. end
  172. for name,a in pairs(ALIASES) do
  173.     ALIASES[name:lower()] = a
  174. end
  175. for name,a in pairs(HIDDEN_PLAYERS) do
  176.     HIDDEN_PLAYERS[name:lower()] = a
  177. end
  178. for name,a in pairs(CUSTOM_LABEL_BACKGROUND_COLORS) do
  179.     CUSTOM_LABEL_BACKGROUND_COLORS[name:lower()] = a
  180. end
  181. for name,a in pairs(CUSTOM_LABEL_NAME_COLORS) do
  182.     CUSTOM_LABEL_NAME_COLORS[name:lower()] = a
  183. end
  184.  
  185. function GetAliasOf(name)
  186.     return ALIASES[name:lower()] or name
  187. end
  188.  
  189. local export = {}
  190.  
  191. export.SetAllowBCIcons = function(self, b)
  192.     ALLOW_BC_ICONS = b
  193. end
  194.  
  195. export.AddAdmin = function(self, name, customicon, customiconwidth)
  196.     ADMINS[name:lower()] = customicon or 1
  197.     ADMIN_ICON_WIDTHS[name:lower()] = customiconwidth or 16
  198. end
  199.  
  200. export.RemoveAdmin = function(self, name)
  201.     ADMINS[name:lower()] = 0
  202. end
  203.  
  204. export.GetChatData = function(self)
  205.     return ADMINS, CUSTOM_CHAT_COLORS, ALIASES
  206. end
  207.  
  208. export.SetAlias = function(self, name, alias)
  209.     if alias == "" or alias == nil then
  210.         ALIASES[name:lower()] = name
  211.     else
  212.         ALIASES[name:lower()] = alias
  213.     end
  214. end
  215.  
  216. export.GetAlias = function(self, name)
  217.     return GetAliasOf(name)
  218. end
  219.  
  220. export.SetLabelColors = function(self, playerName, backgroundColor, textColor)
  221.     CUSTOM_LABEL_BACKGROUND_COLORS[playerName:lower()] = backgroundColor
  222.     CUSTOM_LABEL_NAME_COLORS[playerName:lower()] = textColor
  223. end
  224.  
  225. export.SetPlayerIsHidden = function(self, name, bool)
  226.     local current = not not HIDDEN_PLAYERS[name:lower()]
  227.     local new = not not bool
  228.     local changing = current ~= new
  229.    
  230.     HIDDEN_PLAYERS[name:lower()] = new
  231.    
  232.     if changing then
  233.         if new then
  234.             local existingPlayer = nil
  235.            
  236.             for index, player in next, game.Players:GetPlayers() do
  237.                 if player.Name:lower() == name:lower() then
  238.                     existingPlayer = player
  239.                     break
  240.                 end
  241.             end
  242.            
  243.            
  244.             if existingPlayer ~= nil then
  245.                 InsertPlayerFrame(existingPlayer)
  246.             end
  247.         elseif not new then
  248.             local existingPlayer = nil
  249.            
  250.             for index, player in next, game.Players:GetPlayers() do
  251.                 if player.Name:lower() == name:lower() then
  252.                     existingPlayer = player
  253.                     break
  254.                 end
  255.             end
  256.            
  257.            
  258.             if existingPlayer ~= nil then
  259.                 RemovePlayerFrame(existingPlayer)
  260.             end
  261.         end
  262.     end
  263. end
  264.  
  265. _G.PlayerListAPI = export
  266.  
  267. local Images = {
  268.     bottomDark = '94691904',
  269.     bottomLight = '94691940',
  270.     midDark = '94691980',
  271.     midLight = '94692025',
  272.     LargeDark = '96098866',
  273.     LargeLight = '96098920',
  274.     LargeHeader = '96097470',
  275.     NormalHeader = '94692054',
  276.     LargeBottom = '96397271',
  277.     NormalBottom = '94754966',
  278.     DarkBluePopupMid = '97114905',
  279.     LightBluePopupMid = '97114905',
  280.     DarkPopupMid = '97112126',
  281.     LightPopupMid = '97109338',
  282.     DarkBluePopupTop = '97114838',
  283.     DarkBluePopupBottom = '97114758',
  284.     DarkPopupBottom = '100869219',
  285.     LightPopupBottom = '97109175',
  286. }
  287.  
  288. local BASE_TWEEN = .25
  289.  
  290. local MOUSE_HOLD_TIME = .15
  291. local MOUSE_DRAG_DISTANCE = 15
  292.  
  293. --[[
  294.     Generic object Create function, which I am using to create Gui's
  295.     Thanks to Stravant!
  296. --]]
  297. local Obj = {}
  298. function Obj.Create(guiType)
  299.     return function(data)
  300.         local obj = Instance.new(guiType)
  301.         for k, v in pairs(data) do
  302.             if type(k) == 'number' then
  303.                 v.Parent = obj
  304.             else
  305.                 obj[k] = v
  306.             end
  307.         end
  308.         return obj
  309.     end
  310. end
  311.  
  312. --[[
  313.     makes a full sized background for a guiobject
  314.     @Args:
  315.     imgName     asset name of image to fill background
  316.     @Return:    background gui object
  317. --]]
  318. function MakeBackgroundGuiObj(imgName)
  319.     return Obj.Create'ImageLabel'
  320.     {
  321.         Name = 'Background',
  322.         BackgroundTransparency = 1,
  323.         Image = imgName,
  324.         Position = UDim2.new(0, 0, 0, 0),
  325.         Size = UDim2.new(1,0,1,0),
  326.     }
  327. end
  328. --[[ turns 255 integer color value to a color3 --]]
  329. function Color3I(r,g,b)
  330.     return Color3.new(r/255,g/255,b/255)
  331. end
  332.  
  333. --[[
  334.     Gets correct icon for builder's club status to display by name
  335.     @Args:
  336.     membershipType      Enum of membership status
  337.     @Return:            string of image asset
  338. --]]
  339. function getMembershipTypeIcon(membershipType,playerName)
  340.     if ADMINS[string.lower(playerName)]~=nil then
  341.         if ADMINS[string.lower(playerName)] == 1 then
  342.             return "http://www.roblox.com/asset/?id=146188778"
  343.         else
  344.             local dat = ADMINS[string.lower(playerName)]
  345.            
  346.             if type(dat) == "table" then
  347.                 return dat[1]
  348.             elseif type(dat) == "string" then
  349.                 return ADMINS[string.lower(playerName)]
  350.             else
  351.                 return "http://www.roblox.com/asset/?id=146188778"
  352.             end
  353.         end
  354.     elseif membershipType == Enum.MembershipType.None then
  355.         return ""
  356.     elseif membershipType == Enum.MembershipType.BuildersClub then
  357.         return "rbxasset://textures/ui/TinyBcIcon.png"
  358.     elseif membershipType == Enum.MembershipType.TurboBuildersClub then
  359.         return "rbxasset://textures/ui/TinyTbcIcon.png"
  360.     elseif membershipType == Enum.MembershipType.OutrageousBuildersClub then
  361.         return "rbxasset://textures/ui/TinyObcIcon.png"
  362.     else
  363.         error("Unknown membershipType" .. membershipType)
  364.     end
  365. end
  366.  
  367. local function getFriendStatusIcon(friendStatus)
  368.     if friendStatus == Enum.FriendStatus.Unknown or friendStatus == Enum.FriendStatus.NotFriend then
  369.         return ""
  370.     elseif friendStatus == Enum.FriendStatus.Friend then
  371.         return "http://www.roblox.com/asset/?id=99749771"
  372.     elseif friendStatus == Enum.FriendStatus.FriendRequestSent then
  373.         return "http://www.roblox.com/asset/?id=99776888"
  374.     elseif friendStatus == Enum.FriendStatus.FriendRequestReceived then
  375.         return "http://www.roblox.com/asset/?id=99776838"
  376.     else
  377.         error("Unknown FriendStatus: " .. friendStatus)
  378.     end
  379. end
  380.  
  381.  
  382. --[[
  383.     Utility function to create buttons for the popup menus
  384.     @Args:
  385.     nparent     what to parent this button to
  386.     ntext       text to put on this button
  387.     index       number index of this entry in menu
  388.     last        is this the last element of the popup menu
  389.     @Return:    a popup menu button
  390. --]]
  391. function MakePopupButton(nparent,ntext,index,last)
  392.     local tobj = Obj.Create"ImageButton"
  393.     {
  394.         Name = 'ReportButton',
  395.         BackgroundTransparency = 1,
  396.         Position = UDim2.new(0,0,1*index,0),
  397.         Size = UDim2.new(1, 0, 1, 0),
  398.         ZIndex=7,
  399.         Obj.Create'TextLabel'
  400.         {
  401.             Name = 'ButtonText',
  402.             BackgroundTransparency = 1,
  403.             Position = UDim2.new(.07, 0, .07, 0),
  404.             Size = UDim2.new(.86,0,.86,0),
  405.             Parent = HeaderFrame,
  406.             Font = 'ArialBold',
  407.             Text = ntext,
  408.             FontSize = 'Size14',
  409.             TextScaled = true,
  410.             TextColor3 = Color3.new(1,1,1),
  411.             TextStrokeTransparency = 1,
  412.             ZIndex=7,
  413.         },
  414.         Parent = nparent,
  415.     }
  416.     if index==0 then
  417.         tobj.Image = 'http://www.roblox.com/asset/?id=97108784'
  418.     elseif last then
  419.         if index%2==1 then
  420.             tobj.Image = 'http://www.roblox.com/asset/?id='.. Images['LightPopupBottom']
  421.         else
  422.             tobj.Image = 'http://www.roblox.com/asset/?id='.. Images['DarkPopupBottom']
  423.         end
  424.     else
  425.         if index%2==1 then
  426.             tobj.Image = 'http://www.roblox.com/asset/?id=97112126'
  427.         else
  428.             tobj.Image = 'http://www.roblox.com/asset/?id=97109338'
  429.         end
  430.     end
  431.     return tobj
  432. end
  433.  
  434.  
  435. --[[
  436.     obligatory wait for child function
  437.     @Args:
  438.     parent      Parent object to look for child in
  439.     child       name of child object to look for
  440.     @Return: object waited for
  441. --]]
  442. function WaitForChild(parent,child)
  443.     while not parent:FindFirstChild(child) do
  444.         wait() debugprint(" child "..parent.Name.." waiting for "..child)
  445.     end
  446.     return parent[child]
  447. end
  448.  
  449.  ---------------------------  
  450.  -- Workspace Objects
  451.  ---------------------------
  452.  
  453. -- might want to move all this to an init function, wait for localplayer elsewhere
  454. local Players = game:GetService('Players')
  455. -- make sure this doesn't run on the server(it will if you dont do this)
  456. while not Players.LocalPlayer do
  457.     Players.Changed:wait()
  458. end
  459.  
  460. local LocalPlayer = Players.LocalPlayer
  461. local Mouse = LocalPlayer:GetMouse()
  462.  
  463. local ScreenGui = Obj.Create"Frame"
  464. {
  465.     Name = 'PlayerListScreen',
  466.     Size = UDim2.new(1, 0, 1, 0),
  467.     BackgroundTransparency = 1,
  468.     Parent = script.Parent
  469. }
  470. local MainFrame = Obj.Create"Frame"
  471. {
  472.     Name = 'LeaderBoardFrame',
  473.     Position = UDim2.new(1, -150, 0.005, 0),
  474.     Size = UDim2.new(0, 150, 0, 800),
  475.     BackgroundTransparency = 1,
  476.     Parent = ScreenGui,
  477. }
  478.  
  479. --frame used for expanding leaderstats when frame is 'focused'
  480. local FocusFrame = Obj.Create"Frame"
  481. {
  482.     Name = 'FocusFrame',
  483.     Position = UDim2.new(0, 0, 0, 0),
  484.     Size = UDim2.new(1, 0, 0, 100),
  485.     BackgroundTransparency = 1,
  486.     Active = true,
  487.     Parent = MainFrame,
  488. }
  489.  
  490. local TemplateFrameYSize = 0.670000017
  491.  
  492.  -- HEADER
  493. local HeaderFrame = Obj.Create"Frame"
  494. {
  495.     Name = 'Header',
  496.     BackgroundTransparency = 1,
  497.     Position = UDim2.new(0,0,0,0),
  498.     Size = UDim2.new(1, 0, .07, 0),
  499.     Parent = MainFrame,
  500.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=94692054'),
  501. }
  502.     local HeaderFrameHeight = HeaderFrame.Size.Y.Scale
  503.     local MaximizeButton = Obj.Create"ImageButton"
  504.     {
  505.         Name = 'MaximizeButton',
  506.         Active = true,
  507.         BackgroundTransparency = 1,
  508.         Position = UDim2.new(0, 0, 0, 0),
  509.         Size = UDim2.new(1,0,1,0),
  510.         Parent = HeaderFrame,
  511.     }
  512.     local HeaderName = Obj.Create"TextLabel"
  513.     {
  514.         Name = 'PlayerName',
  515.         BackgroundTransparency = 1,
  516.         Position = UDim2.new(0, 0, .01, 0),
  517.         Size = UDim2.new(.98,0,.38,0),
  518.         Parent = HeaderFrame,
  519.         Font = 'ArialBold',
  520.         Text = GetAliasOf(LocalPlayer.Name),
  521.         FontSize='Size24',
  522.         --TextScaled = true,
  523.         TextColor3 = Color3.new(1,1,1),
  524.         TextStrokeColor3 = Color3.new(0,0,0),
  525.         TextStrokeTransparency = 0,
  526.         TextXAlignment = 'Right',
  527.         TextYAlignment = 'Center',
  528.     }
  529.     local HeaderScore = Obj.Create"TextLabel"
  530.     {
  531.         Name = 'PlayerScore',
  532.         BackgroundTransparency = 1,
  533.         Position = UDim2.new(0, 0, .4, 0),
  534.         Size = UDim2.new(.98,0,0,30),
  535.         Parent = HeaderFrame,
  536.         Font = 'ArialBold',
  537.         Text = '',
  538.         FontSize='Size24',
  539.         TextYAlignment = 'Top',
  540.         --TextScaled = true,
  541.         TextColor3 = Color3.new(1,1,1),
  542.         TextStrokeTransparency = 1,
  543.         TextXAlignment = 'Right',
  544.         TextYAlignment = 'Top',
  545.     }
  546.         local HeaderScoreName = Obj.Create"TextLabel"
  547.         {
  548.             Name = 'ScoreNameLabel',
  549.             BackgroundTransparency = 1,
  550.             Position = UDim2.new(0, 5, 0, 0),
  551.             Size = UDim2.new(1, 0, 1, 0),
  552.             Font = 'ArialBold',
  553.             FontSize = 'Size14',
  554.             Text = '',
  555.             TextColor3 = Color3.new(1, 1, 1),
  556.             TextStrokeTransparency = 0,
  557.             TextXAlignment = 'Left',
  558.             Parent = HeaderScore
  559.         }
  560.  
  561. coroutine.resume(coroutine.create(function() while wait(1) do
  562.     HeaderFrame.PlayerName.Text = GetAliasOf(LocalPlayer.Name)
  563. end end))
  564.  -- BOTTOM
  565.  --used for shifting bottom frame for mouse over effects
  566. local BottomShiftFrame = Obj.Create"Frame"
  567. {
  568.     Name= 'BottomShiftFrame',
  569.     BackgroundTransparency = 1,
  570.     Position = UDim2.new(0,0,HeaderFrameHeight,0),
  571.     Size = UDim2.new(1,0,1,0),
  572.     Parent=MainFrame,
  573. }
  574.     local BottomFrame = Obj.Create"Frame"
  575.     {
  576.         Name = 'Bottom',
  577.         BackgroundTransparency = 1,
  578.         Position = UDim2.new(0,0,.07,0),
  579.         Size = UDim2.new(1, 0, .03, 0),
  580.         Parent = BottomShiftFrame,
  581.         MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=94754966'),
  582.     }
  583.         local ExtendButton = Obj.Create"ImageButton"
  584.         {
  585.             Name = 'bigbutton',
  586.             Active = true,
  587.             BackgroundTransparency = 1,
  588.             Position = UDim2.new(0, 0, 0, 0),
  589.             Size = UDim2.new(1,0,1.5,0),
  590.             ZIndex = 3,
  591.             Parent = BottomFrame,
  592.         }
  593.         local ExtendTab = Obj.Create"ImageButton"
  594.         {
  595.             Name = 'extendTab',
  596.             Active = true,
  597.             BackgroundTransparency = 1,
  598.             Image = 'http://www.roblox.com/asset/?id=94692731',
  599.             Position = UDim2.new(.608, 0, .3, 0),
  600.             Size = UDim2.new(.3,0,.7,0),
  601.             Parent = BottomFrame,
  602.         }
  603. local TopClipFrame = Obj.Create"Frame"
  604. {
  605.     Name = 'ListFrame',
  606.     BackgroundTransparency = 1,
  607.     Position = UDim2.new(-1,0,.07,0),
  608.     Size = UDim2.new(2, 0, 1, 0),
  609.     Parent = MainFrame,
  610.     ClipsDescendants = true,
  611. }
  612.     local BottomClipFrame = Obj.Create"Frame"
  613.     {
  614.         Name = 'BottomFrame',
  615.         BackgroundTransparency = 1,
  616.         Position = UDim2.new(0,0, - .8,0),
  617.         Size = UDim2.new(1, 0, 1, 0),
  618.         Parent = TopClipFrame,
  619.         ClipsDescendants = true,
  620.     }
  621.         local ScrollBarFrame = Obj.Create"Frame"
  622.         {
  623.             Name = 'ScrollBarFrame',
  624.             BackgroundTransparency = 1,
  625.             Position = UDim2.new(.987,0,.8,0),
  626.             Size = UDim2.new(.01, 0, .2, 0),
  627.             Parent = BottomClipFrame,
  628.         }
  629.             local ScrollBar = Obj.Create"Frame"
  630.             {
  631.                 Name = 'ScrollBar',
  632.                 BackgroundTransparency = 0,
  633.                 BackgroundColor3 = Color3.new(.2,.2,.2),
  634.                 Position = UDim2.new(0,0,0,0),
  635.                 Size = UDim2.new(1, 0, .5, 0),
  636.                 ZIndex = 5,
  637.                 Parent = ScrollBarFrame,
  638.                
  639.             }
  640.         local ListFrame = Obj.Create"Frame"
  641.         {
  642.             Name = 'SubFrame',
  643.             BackgroundTransparency = 1,
  644.             Position = UDim2.new(0,0,.8,0),
  645.             Size = UDim2.new(1, 0, 1, 0),
  646.             Parent = BottomClipFrame,
  647.         }
  648. local PopUpClipFrame = Obj.Create"Frame"
  649. {
  650.     Name = 'PopUpFrame',
  651.     BackgroundTransparency = 1,
  652.     SizeConstraint='RelativeXX',
  653.     Position = MainFrame.Position + UDim2.new( 0,-150,0,0),
  654.     Size = UDim2.new(0,150,0,800),
  655.     Parent = MainFrame,
  656.     ClipsDescendants = true,
  657.     ZIndex=7,
  658. }
  659. local PopUpPanel = nil
  660.     local PopUpPanelTemplate = Obj.Create"Frame"
  661.     {
  662.         Name = 'Panel',
  663.         BackgroundTransparency = 1,
  664.         Position = UDim2.new(1,0,0,0),
  665.         Size = UDim2.new(1,0,.032,0),
  666.         Parent = PopUpClipFrame,
  667.     }
  668.        
  669. local StatTitles = Obj.Create"Frame"
  670. {
  671.     Name = 'StatTitles',
  672.     BackgroundTransparency = 1,
  673.     Position = UDim2.new(0,0,1,-10),
  674.     Size = UDim2.new(1, 0, 0, 0),
  675.     Parent = HeaderFrame,
  676. }
  677.  
  678. local IsMinimized = Instance.new('BoolValue')
  679. local IsMaximized = Instance.new('BoolValue')
  680. local IsTabified = Instance.new('BoolValue')
  681. local AreNamesExpanded = Instance.new('BoolValue')
  682.  
  683.  
  684. local MiddleTemplate = Obj.Create"Frame"
  685. {
  686.     Name = 'MidTemplate',
  687.     BackgroundTransparency = 1,
  688.     Position = UDim2.new(100,0,.07,0),
  689.     Size = UDim2.new(.5, 0, .025, 0),--UDim2.new(1, 0, .03, 0),
  690.     Obj.Create'ImageLabel'
  691.     {
  692.         Name = 'BCLabel',
  693.         Active = true,
  694.         BackgroundTransparency = 1,
  695.         Position = UDim2.new(.005, 3, .20, -2),
  696.         Size = UDim2.new(0,16,0,16),
  697.         SizeConstraint = 'RelativeYY',
  698.         Image = "",
  699.         ZIndex = 3,
  700.     },
  701.     Obj.Create'ImageLabel'
  702.     {
  703.         Name = 'FriendLabel',
  704.         Active = true,
  705.         BackgroundTransparency = 1,
  706.         Position = UDim2.new(.005, 5, .15, 0),
  707.         Size = UDim2.new(0,16,0,16),
  708.         SizeConstraint = 'RelativeYY',
  709.         Image = "",
  710.         ZIndex = 3,
  711.     },
  712.     Obj.Create"ImageButton"
  713.     {
  714.         Name = 'ClickListener',
  715.         Active = true,
  716.         BackgroundTransparency = 1,
  717.         Position = UDim2.new(.005, 1, 0, 0),
  718.         Size = UDim2.new(.96,0,1,0),
  719.         ZIndex = 3,
  720.     },
  721.     Obj.Create"Frame"
  722.     {
  723.         Name = 'TitleFrame',
  724.         BackgroundTransparency = 1,
  725.         Position = UDim2.new(.01, 0, 0, 0),
  726.         Size = UDim2.new(0,140,1,0),
  727.         ClipsDescendants=true,
  728.         Obj.Create"TextLabel"
  729.         {
  730.             Name = 'Title',
  731.             BackgroundTransparency = 1,
  732.             Position = UDim2.new(0, 5, 0, 0),
  733.             Size = UDim2.new(100,0,1,0),
  734.             Font = 'Arial',
  735.             FontSize='Size14',
  736.             TextColor3 = Color3.new(1,1,1),
  737.             TextXAlignment = 'Left',
  738.             TextYAlignment = 'Center',
  739.             ZIndex = 3,
  740.         },
  741.     },
  742.    
  743.     Obj.Create"TextLabel"
  744.     {
  745.         Name = 'PlayerScore',
  746.         BackgroundTransparency = 1,
  747.         Position = UDim2.new(0, 0, 0, 0),
  748.         Size = UDim2.new(1,0,1,0),
  749.         Font = 'ArialBold',
  750.         Text = '',
  751.         FontSize='Size14',
  752.         TextColor3 = Color3.new(1,1,1),
  753.         TextXAlignment = 'Right',
  754.         TextYAlignment = 'Center',
  755.         ZIndex = 3,
  756.     },
  757.     --Obj.Create'IntValue'{Name = 'ID'},
  758.     --Obj.Create'ObjectValue'{Name = 'Player'},
  759.     --Obj.Create'IntValue'{Name = 'Score'},
  760.     ZIndex = 3,
  761. }
  762. local MiddleBGTemplate = Obj.Create"Frame"
  763. {
  764.     Name = 'MidBGTemplate',
  765.     BackgroundTransparency = 1,
  766.     BorderSizePixel = 0,
  767.     Position = UDim2.new(100,0,.07,0),
  768.     Size = UDim2.new(.5, 0, .025, 0),--UDim2.new(1, 0, .03, 0),
  769.     MakeBackgroundGuiObj('http://www.roblox.com/asset/?id=94692025'),
  770.    
  771. }
  772.  
  773.  -- REPORT ABUSE OBJECTS
  774.  
  775. local ReportAbuseShield = Obj.Create"TextButton"
  776. {
  777.     Name = "ReportAbuseShield",
  778.     Text = "",
  779.     AutoButtonColor = false,
  780.     Active = true,
  781.     Visible = true,
  782.     Size = UDim2.new(1,0,1,0),
  783.     BackgroundColor3 = Color3I(51,51,51),
  784.     BorderColor3 = Color3I(27,42,53),
  785.     BackgroundTransparency = 1,
  786. }
  787.  
  788. local ReportAbuseFrame = Obj.Create "Frame"
  789. {
  790.     Name = "ReportAbuseFrame",
  791.     Position = UDim2.new(0.5, -250, 0.5, -100),
  792.     Size = UDim2.new(0, 500, 0, 200),
  793.     ZIndex = 9,
  794.     Parent = ReportAbuseShield,
  795.     Style = "RobloxRound"
  796. }
  797.  
  798. local ReportAbuseClose = Obj.Create "TextButton"
  799. {
  800.     BackgroundColor3 = Color3.new(150/255, 0, 0),
  801.     BorderColor3 = Color3.new(200/255, 200/255, 200/255),
  802.     Name = "Close",
  803.     Position = UDim2.new(1, -20, 0, 0),
  804.     Size = UDim2.new(0, 20, 0, 20),
  805.     ZIndex = 10,
  806.     Font = "SourceSansBold",
  807.     FontSize = "Size12",
  808.     Text = "X",
  809.     TextColor3 = Color3.new(200/255, 200/255, 200/255),
  810.     TextStrokeTransparency = 0,
  811.     Parent = ReportAbuseFrame
  812. }
  813.  
  814. local ReportAbuseHeader = Obj.Create "TextLabel"
  815. {
  816.     BackgroundTransparency = 1,
  817.     Name = "Sorry",
  818.     Position = UDim2.new(0.5, 0, 0, 20),
  819.     ZIndex = 10,
  820.     Font = "ArialBold",
  821.     FontSize = "Size36",
  822.     Text = "Sorry! :(",
  823.     TextColor3 = Color3.new(200/255, 200/255, 200/255),
  824.     TextStrokeTransparency = 0,
  825.     Parent = ReportAbuseFrame
  826. }
  827.  
  828. local ReportAbuseInfo = Obj.Create "TextLabel"
  829. {
  830.     BackgroundColor3 = Color3.new(),
  831.     BackgroundTransparency = 0.5,
  832.     BorderColor3 = Color3.new(200/255, 200/255, 200/255),
  833.     Name = "ReportAbuseInfo",
  834.     Position = UDim2.new(0, 0, 0, 50),
  835.     Size = UDim2.new(1, 0, 1, -50),
  836.     Font = "ArialBold",
  837.     FontSize = "Size14",
  838.     Text = "This game is using a specialized player list that uses an API to unlock certain features.  Because this is a modified player list, certain high-level functions are disabled such as in-game Friend Requests and the Report Abuse function.",
  839.     TextColor3 = Color3.new(200/255, 200/255, 200/255),
  840.     TextStrokeTransparency = 0,
  841.     TextYAlignment = "Top",
  842.     ZIndex = 10,
  843.     TextWrapped = true,
  844.     Parent = ReportAbuseFrame,
  845.     Obj.Create"TextLabel"
  846.     {
  847.         BackgroundTransparency = 1,
  848.         Name = "FRs",
  849.         Position = UDim2.new(0, 20, 0, 50),
  850.         Size = UDim2.new(1, -40, 1, -50),
  851.         ZIndex = 10,
  852.         Font = "Arial",
  853.         FontSize = "Size12",
  854.         Text = "To add a friend, you will need to go to the roblox site and find them using the player search page.  Once you've found them, click the \"Add Friend\" button under their character.",
  855.         TextColor3 = Color3.new(200/255, 200/255, 200/255),
  856.         TextStrokeTransparency = 0,
  857.         TextWrapped = true,
  858.         TextYAlignment = "Top"
  859.     },
  860.     Obj.Create"TextLabel"
  861.     {
  862.         BackgroundTransparency = 1,
  863.         Name = "Report",
  864.         Position = UDim2.new(0, 20, 0, 90),
  865.         Size = UDim2.new(1, -40, 1, -50),
  866.         ZIndex = 10,
  867.         Font = "Arial",
  868.         FontSize = "Size12",
  869.         Text = "To report abuse, you need to open your game menu by pressing the 'Esc' button on your keyboard, then click Report Abuse and fill out the necessary information.",
  870.         TextColor3 = Color3.new(200/255, 200/255, 200/255),
  871.         TextStrokeTransparency = 0,
  872.         TextWrapped = true,
  873.         TextYAlignment = "Top"
  874.     }
  875. }
  876.  
  877. local BigButton=Instance.new('ImageButton')
  878.     BigButton.Size=UDim2.new(1,0,1,0)
  879.     BigButton.BackgroundTransparency=1
  880.     BigButton.ZIndex=8
  881.     BigButton.Visible=false
  882.     --BigButton.Active=false
  883.     BigButton.Parent=ScreenGui
  884.    
  885.    
  886.  local debugFrame = Obj.Create"Frame"
  887.     {
  888.         Name = 'debugframe',
  889.         Position = UDim2.new(0, 0, 0, 0),
  890.         Size = UDim2.new(0, 150, 0, 800),--0.99000001
  891.         BackgroundTransparency = 1,
  892.        
  893.     }
  894.     local debugplayers = Obj.Create"TextLabel"
  895.     {
  896.         BackgroundTransparency = .8,
  897.         Position = UDim2.new(0, 0, .01, 0),
  898.         Size = UDim2.new(1,0,.5,0),
  899.         Parent = debugFrame,
  900.         Font = 'ArialBold',
  901.         Text = '--',
  902.         FontSize='Size14',
  903.         TextWrapped=true,
  904.         TextColor3 = Color3.new(1,1,1),
  905.         TextStrokeColor3 = Color3.new(0,0,0),
  906.         TextStrokeTransparency = 0,
  907.         TextXAlignment = 'Right',
  908.         TextYAlignment = 'Center',
  909.     }
  910.     local debugOutput = Obj.Create"TextLabel"
  911.     {
  912.         BackgroundTransparency = .8,
  913.         Position = UDim2.new(0, 0, .5, 0),
  914.         Size = UDim2.new(1,0,.5,0),
  915.         Parent = debugFrame,
  916.         Font = 'ArialBold',
  917.         Text = '--',
  918.         FontSize='Size14',
  919.         TextWrapped=true,
  920.         TextColor3 = Color3.new(1,1,1),
  921.         TextStrokeColor3 = Color3.new(0,0,0),
  922.         TextStrokeTransparency = 0,
  923.         TextXAlignment = 'Right',
  924.         TextYAlignment = 'Center',
  925.     }  
  926.  
  927.  
  928. --[[
  929.     simple function to toggle the display of debug output
  930. --]]
  931. local DebugPrintEnabled=true
  932. function debugprint(str)
  933.     --print(str)
  934.     if DebugPrintEnabled then
  935.         debugOutput.Text=str
  936.     end
  937. end
  938.  
  939.  
  940.  -------------------------  
  941.  -- Script objects
  942.  -------------------------
  943. local RbxGui = assert(LoadLibrary('RbxGui'))
  944.  
  945.  -- number of entries to show if you click minimize
  946. local DefaultEntriesOnScreen = 8
  947.  
  948.  
  949.    
  950.  
  951.  
  952. for _,i in pairs(Images) do
  953.     Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..i)
  954. end
  955.  
  956.  -- ordered array of 'score data', each entry has:
  957.  -- Name(String)
  958.  -- Priority(number)
  959.  -- IsPrimary (bool, should it be shown in upper right)
  960.  -- MaxLength (integer, of the length of the longest element for this column)
  961. local ScoreNames = {}
  962.  -- prevents flipping in playerlist panels
  963. local AddId = 0
  964.  -- intermediate table form of all player entries in format of:
  965.  -- Frame
  966.  -- Player
  967.  -- Score
  968.  -- ID
  969.  -- MyTeam (team ENRTY(not actual team) I am currently on)
  970. local PlayerFrames = {}
  971.  -- intermediate ordered frame array, composed of Entrys of
  972.  -- Frame
  973.  -- MyTeam (my team object)
  974.  -- MyPlayers ( an ordered array of all player frames in team )
  975.  -- AutoHide (bool saying whether it should be hidden)
  976.  -- IsHidden (bool)
  977.  -- ID (int to prevent flipping out of leaderboard, fun times)
  978. local TeamFrames = {}
  979.  -- one special entry from teamFrames, for unaffiliated players, only shown if players non - empty
  980. local NeutralTeam = nil
  981.  
  982.  -- final 'to be displayed' list of frames
  983. local MiddleFrames = {}
  984. local MiddleFrameBackgrounds = {}
  985. local MiddleFrameHeight = .03
  986.  -- time of last click
  987. local LastClick = 0
  988. local ButtonCooldown = .25
  989.  
  990. local OnIos = false
  991. pcall(function() OnIos = Game:GetService('UserInputService').TouchEnabled end)
  992.  
  993.  
  994.  -- you get 200 of x screen space per stat added, start width 16%
  995. local BaseScreenXSize = 150
  996. local SpacingPerStat = 10 --spacing between stats
  997.  
  998.  
  999. local MaximizedBounds = UDim2.new(.5,0,1,0)
  1000. local MaximizedPosition = UDim2.new(.25,0,.1,0)
  1001. local NormalBounds = UDim2.new(0,BaseScreenXSize, 0, 800)
  1002. local NormalPosition = UDim2.new(1 , - BaseScreenXSize, 0.005, 0)
  1003.  
  1004. local MinimizedBounds = UDim2.new(0, BaseScreenXSize, 0.99000001, 0)
  1005.  
  1006. --free space to give last stat on the right
  1007. local RightEdgeSpace = -.04
  1008.  
  1009.  -- where the scroll par currently is positioned
  1010. local ScrollPosition = 0.75999999
  1011. local IsDragging = false -- am I dragging the player list
  1012.  
  1013. local DefaultBottomClipPos = BottomClipFrame.Position.Y.Scale
  1014.  
  1015. local LastSelectedPlayerEntry = nil
  1016. local SelectedPlayerEntry = nil
  1017. local SelectedPlayer = nil
  1018.  
  1019.  -- locks(semaphores) for stopping race conditions
  1020. local AddingFrameLock = false
  1021. local ChangingOrderLock = false
  1022. local AddingStatLock = false
  1023. local BaseUpdateLock = false
  1024. local WaitForClickLock = false
  1025. local InPopupWaitForClick=false
  1026. local PlayerChangedLock = false
  1027. local NeutralTeamLock = false
  1028.  
  1029. local ScrollWheelConnections = {}
  1030.  
  1031.  
  1032. local DefaultListSize = 8
  1033. if not OnIos then DefaultListSize = 12 end
  1034. local DidMinimizeDrag = false
  1035.  
  1036. --local PlaceCreatorId=game.CreatorId
  1037.  
  1038.  -- report abuse objects
  1039. local AbuseName
  1040. local Abuses = {
  1041.     "Bad Words or Threats",
  1042.     "Bad Username",
  1043.     "Talking about Dating",
  1044.     "Account Trading or Sharing",
  1045.     "Asking Personal Questions",
  1046.     "Rude or Mean Behavior",
  1047.     "False Reporting Me"
  1048. }
  1049. local UpdateAbuseFunction
  1050. local AbuseDropDown, UpdateAbuseSelection
  1051.  
  1052. local PrivilegeLevel =
  1053. {
  1054.     Owner = 255,
  1055.     Admin = 240,
  1056.     Member = 128,
  1057.     Visitor = 10,
  1058.     Banned = 0,
  1059. }
  1060.  
  1061.  
  1062. local IsPersonalServer = not not game.Workspace:FindFirstChild("PSVariable")
  1063.  
  1064. game.Workspace.ChildAdded:connect(function(nchild)
  1065.     if nchild.Name=='PSVariable' and nchild:IsA('BoolValue') then
  1066.         IsPersonalServer=true
  1067.     end
  1068. end)
  1069.  -------------------------------  
  1070.  -- Static Functions
  1071.  -------------------------------
  1072. function GetTotalEntries()
  1073.     return math.min(#MiddleFrameBackgrounds,DefaultEntriesOnScreen)
  1074. end
  1075.  
  1076. function GetEntryListLength()
  1077.     local numEnts=#PlayerFrames+#TeamFrames
  1078.     if NeutralTeam then
  1079.         numEnts=numEnts+1
  1080.     end
  1081.     return numEnts
  1082. end
  1083.  
  1084. function AreAllEntriesOnScreen()
  1085.     return #MiddleFrameBackgrounds * MiddleTemplate.Size.Y.Scale <= 1 + DefaultBottomClipPos
  1086. end
  1087.  
  1088. function GetLengthOfVisbleScroll()
  1089.     return 1 + DefaultBottomClipPos
  1090. end
  1091.  
  1092. function GetMaxScroll()
  1093.     return DefaultBottomClipPos *  - 1
  1094. end
  1095.  -- can be optimized by caching when this varible changes
  1096. function GetMinScroll()
  1097.     if AreAllEntriesOnScreen() then
  1098.         return GetMaxScroll()
  1099.     else
  1100.         return (GetMaxScroll() - (#MiddleFrameBackgrounds * MiddleTemplate.Size.Y.Scale)) + (1 + DefaultBottomClipPos)
  1101.     end
  1102. end
  1103.  
  1104. function AbsoluteToPercent(x,y)
  1105.     return Vector2.new(x,y)/ScreenGui.AbsoluteSize
  1106. end
  1107. --[[
  1108.     tweens property of element from starta to enda over length of time
  1109.     Warning: should be put in a Spawn call
  1110.     @Args:
  1111.     element     textobject to tween transparency on
  1112.     propName
  1113.     starta      alpha to start tweening
  1114.     enda        alpha to end tweening on
  1115.     length      how many seconds to spend tweening
  1116. --]]
  1117. function TweenProperty(obj, propName, inita, enda, length)
  1118.     local startTime = tick()
  1119.     while tick()-startTime<length do
  1120.         obj[propName] = ((enda-inita)*((tick()-startTime)/length))+inita
  1121.         wait(1/30)
  1122.     end
  1123.     obj[propName] = enda   
  1124. end
  1125. --[[
  1126.     UGLY UGLY HACK FUNCTION
  1127.     replace with some sort of global input catching A.S.A. FREAKING P.
  1128.     creates a fullsize gui element to catch next mouse up event(completeing a click)
  1129.     @Args:
  1130.     frameParent     Object to parent fullscreen gui to
  1131.     polledFunction  function to call on mouse moved events in this gui
  1132.     exitFunction    function to call when click event is fired
  1133. --]]
  1134.  
  1135. function WaitForClick(frameParent,polledFunction,exitFunction)
  1136.    
  1137.     if WaitForClickLock then return end
  1138.     WaitForClickLock=true
  1139.     local upHappened=false
  1140.     local connection, connection2
  1141.     connection=BigButton.MouseButton1Up:connect(function(nx,ny)
  1142.         exitFunction(nx,ny)
  1143.         BigButton.Visible=false
  1144.         connection:disconnect()
  1145.         if connection2 then
  1146.             connection2:disconnect()
  1147.         end
  1148.         --debugprint('mouse up!')
  1149.     end)
  1150.     connection2=BigButton.MouseMoved:connect( function(nx,ny)
  1151.         polledFunction(nx,ny)
  1152.        
  1153.     end)
  1154.    
  1155.     --debugprint('waiting for click!')
  1156.     BigButton.Visible=true
  1157.     BigButton.Active=true
  1158.     BigButton.Parent=frameParent
  1159.     frameParent.AncestryChanged:connect(function(child,nparent)
  1160.         if child == frameParent and nparent ==nil then
  1161.             exitFunction(nx,ny)
  1162.             BigButton.Visible=false
  1163.             connection:disconnect()
  1164.             connection2:disconnect()
  1165.             debugprint("forced out of wait for click")
  1166.         end
  1167.     end)
  1168.     WaitForClickLock=false
  1169. end
  1170.  
  1171.  
  1172.  
  1173. ---------------------------
  1174. --Personal Server Handling
  1175. ---------------------------
  1176. --[[
  1177.     returns privlage level based on integer rank
  1178.     Note: these privilege levels seem completely arbitrary, but no documentation exists
  1179.     this is all from the old player list, really weird
  1180.     @Args:
  1181.     rank    Integer rank value for player
  1182.     @Return     Normalized integer value for rank?
  1183. --]]
  1184. function GetPrivilegeType(rank)
  1185.     if rank <= PrivilegeLevel['Banned'] then
  1186.         return PrivilegeLevel['Banned']
  1187.     elseif rank <= PrivilegeLevel['Visitor'] then
  1188.         return PrivilegeLevel['Visitor']
  1189.     elseif rank <= PrivilegeLevel['Member'] then
  1190.         return PrivilegeLevel['Member']
  1191.     elseif rank <= PrivilegeLevel['Admin'] then
  1192.         return PrivilegeLevel['Admin']
  1193.     else
  1194.         return PrivilegeLevel['Owner']
  1195.     end
  1196. end
  1197.  
  1198. --[[
  1199.     gives a player a new privilage rank
  1200.     Note: Very odd that I have to use loops with this instead of directly setting the rank
  1201.     but no documentation for personal server service exists
  1202.     @Args:
  1203.     player      player to change rank of
  1204.     nrank       new integer rank to give player
  1205. --]]
  1206. function SetPrivilegeRank(player,nrank)
  1207.     while player.PersonalServerRank<nrank do
  1208.         game:GetService("PersonalServerService"):Promote(player)
  1209.     end
  1210.     while player.PersonalServerRank>nrank do
  1211.         game:GetService("PersonalServerService"):Demote(player)
  1212.     end
  1213. end
  1214. --[[
  1215.     called when player selects new privilege level from popup menu
  1216.     @Args:
  1217.     player      player to set privileges on
  1218.     nlevel      new privilege level for this player
  1219. --]]
  1220. function OnPrivilegeLevelSelect(player,nlevel,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  1221.     debugprint('setting privilege level')
  1222.     SetPrivilegeRank(player,nlevel)
  1223.     HighlightMyRank(player,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  1224. end
  1225.  
  1226. --[[
  1227.     Highlights current rank of this player in the popup menu
  1228.     @Args:
  1229.     player      Player to check for rank on
  1230. --]]
  1231. function HighlightMyRank(player,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  1232.     BanPlayerButton.Image= 'http://www.roblox.com/asset/?id='..Images['LightPopupMid']
  1233.     VisitorButton.Image= 'http://www.roblox.com/asset/?id='..Images['DarkPopupMid']
  1234.     MemberButton.Image= 'http://www.roblox.com/asset/?id='..Images['LightPopupMid']
  1235.     AdminButton.Image= 'http://www.roblox.com/asset/?id='..Images['DarkPopupBottom']
  1236.    
  1237.     local rank=player.PersonalServerRank
  1238.     if rank <= PrivilegeLevel['Banned'] then
  1239.         BanPlayerButton.Image='http://www.roblox.com/asset/?id='..Images['LightBluePopupMid']
  1240.     elseif rank <= PrivilegeLevel['Visitor'] then
  1241.         VisitorButton.Image='http://www.roblox.com/asset/?id='..Images['DarkBluePopupMid']
  1242.     elseif rank <= PrivilegeLevel['Member'] then
  1243.         MemberButton.Image='http://www.roblox.com/asset/?id='..Images['LightBluePopupMid']
  1244.     elseif rank <= PrivilegeLevel['Admin'] then
  1245.         AdminButton.Image= 'http://www.roblox.com/asset/?id='..Images['DarkBluePopupBottom']
  1246.     end
  1247. end
  1248.  
  1249.  --------------------------  
  1250.  -- Report abuse handling
  1251.  --------------------------
  1252. --[[
  1253.     does final reporting of abuse on selected player, calls closeAbuseDialog
  1254. --]]
  1255. function OnSubmitAbuse()
  1256. end
  1257.  
  1258. --[[
  1259.     opens the abuse dialog, initialises text to display selectedplayer
  1260. --]]
  1261. function OpenAbuseDialog()
  1262.     debugprint('adding report dialog')
  1263.     PopUpPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  1264.     ReportAbuseShield.Parent = ScreenGui
  1265.     ClosePopUpPanel()
  1266. end
  1267. --[[
  1268.     resets and closes abuse dialog
  1269. --]]
  1270. function CloseAbuseDialog()
  1271.     ReportAbuseShield.Parent = nil
  1272. end
  1273.  
  1274. ReportAbuseClose.MouseButton1Click:connect(CloseAbuseDialog)
  1275. ReportAbuseShield.MouseButton1Click:connect(CloseAbuseDialog)
  1276.  
  1277. --[[
  1278.     creates dropdownbox, registers all listeners for abuse dialog
  1279. --]]
  1280. function InitReportAbuse()
  1281. end
  1282.  
  1283. -------------------------------------
  1284. -- Friend/unfriending
  1285. -------------------------------------
  1286. --[[
  1287.     gets enum val of friend status, uses pcall for some reason?(from old playerlist)
  1288.     @Args:
  1289.     player  player object to check if friends with
  1290.     @Return: enum of friend status
  1291. --]]
  1292. local function GetFriendStatus(player)
  1293.     if player == game.Players.LocalPlayer then
  1294.         return Enum.FriendStatus.NotFriend
  1295.     else
  1296.         local success, result = pcall(function() return game.Players.LocalPlayer:GetFriendStatus(player) end)
  1297.         if success then
  1298.             return result
  1299.         else
  1300.             return Enum.FriendStatus.NotFriend
  1301.         end
  1302.     end
  1303. end
  1304.  
  1305. --[[
  1306.     when friend button is clicked, tries to take appropriate action,
  1307.     based on current friend status with SelectedPlayer
  1308. --]]
  1309. function OnFriendButtonSelect()
  1310.     OpenAbuseDialog()
  1311. end
  1312.  
  1313. function OnFriendRefuseButtonSelect()
  1314. end
  1315. ------------------------------------  
  1316. -- Player Entry Handling
  1317. ------------------------------------
  1318. --[[
  1319.     used by lua's table.sort to sort player entries
  1320. --]]
  1321. function PlayerSortFunction(a,b)
  1322.  -- prevents flipping out leaderboard
  1323.     if a['Score'] == b['Score'] then
  1324.         return GetAliasOf(a['Player'].Name):upper() < GetAliasOf(b['Player'].Name):upper()
  1325.     end
  1326.     if not a['Score'] then return false end
  1327.     if not b['Score'] then return true end
  1328.     return a['Score'] < b['Score']
  1329. end
  1330.  
  1331.  ---------------------------------  
  1332.  -- Stat Handling
  1333.  ---------------------------------  
  1334.  -- removes and closes all leaderboard stuffs
  1335. function BlowThisPopsicleStand()
  1336.     --ScreenGui:Destroy()
  1337.     --script:Destroy()
  1338.     --time to make the fanboys rage...
  1339.     Tabify()
  1340. end
  1341. --[[
  1342.     used by lua's table.sort to prioritize score entries
  1343. --]]
  1344. function StatSort(a,b)
  1345.  -- primary stats should be shown before all others
  1346.     if a.IsPrimary ~= b.IsPrimary then
  1347.         return a.IsPrimary
  1348.     end
  1349.  -- if priorities are equal, then return the first added one
  1350.     if a.Priority == b.Priority then
  1351.         return a.AddId < b.AddId
  1352.     end
  1353.     return a.Priority < b.Priority
  1354. end
  1355. --[[
  1356.     doing WAAY too much here, for optimization update only your team
  1357.     @Args:
  1358.     playerEntry     Entry of player who had a stat change
  1359.     property        Name of stat changed
  1360. --]]
  1361. function StatChanged(playerEntry,property)
  1362.  
  1363.  -- if(playerEntry['MyTeam']) then
  1364.  -- UpdateSingleTeam(playerEntry['MyTeam'])
  1365.  -- else
  1366.         BaseUpdate()
  1367.  -- end
  1368. end
  1369. --[[
  1370.     Called when stat is added
  1371.     if playerEntry is localplayer, will add to score names and re-sort the stats, and resize the width of the leaderboard
  1372.     for all players, will add a listener for if this stat changes
  1373.     if stat is a string value, crashes the leaderboard
  1374.     Note:change crash to a 'tabify' leaderboard later
  1375.     @Args:
  1376.     nchild          new child value to leaderstats
  1377.     playerEntry     entry this stat was added to
  1378. --]]
  1379. function StatAdded(nchild,playerEntry)
  1380.  -- dont re - add a leaderstat I alreday have
  1381.     while AddingStatLock do debugprint('in stat added function lock') wait(1/30) end
  1382.     AddingStatLock = true
  1383.     if not (nchild:IsA('StringValue') or nchild:IsA('IntValue') or nchild:IsA('BoolValue') or nchild:IsA('NumberValue') or nchild:IsA('DoubleConstrainedValue') or nchild:IsA('IntConstrainedValue')) then
  1384.         BlowThisPopsicleStand()
  1385.     else
  1386.         local haveScore = false
  1387.         for _,i in pairs(ScoreNames) do
  1388.             if i['Name']==nchild.Name then haveScore=true end
  1389.         end
  1390.         if not haveScore then
  1391.             local nstat = {}
  1392.             nstat['Name'] = nchild.Name
  1393.             nstat['Priority'] = 0
  1394.             if(nchild:FindFirstChild('Priority')) then
  1395.                 nstat['Priority'] = nchild.Priority
  1396.             end
  1397.             nstat['IsPrimary'] = false
  1398.             if(nchild:FindFirstChild('IsPrimary')) then
  1399.                 nstat['IsPrimary'] = true
  1400.             end
  1401.             nstat.AddId = AddId
  1402.             AddId = AddId + 1
  1403.             table.insert(ScoreNames,nstat)
  1404.             table.sort(ScoreNames,StatSort)
  1405.             if not StatTitles:FindFirstChild(nstat['Name']) then
  1406.                 CreateStatTitle(nstat['Name'])
  1407.             end
  1408.             UpdateMaximize()
  1409.  
  1410.         end
  1411.     end
  1412.         AddingStatLock = false
  1413.         StatChanged(playerEntry)
  1414.         nchild.Changed:connect(function(property) StatChanged(playerEntry,property) end)
  1415.    
  1416.    
  1417. end
  1418. --returns whether any of the existing players has this stat
  1419. function DoesStatExist(statName, exception)
  1420.     for _,playerf in pairs(PlayerFrames) do
  1421.         if playerf['Player'] ~= exception and playerf['Player']:FindFirstChild('leaderstats') and playerf['Player'].leaderstats:FindFirstChild(statName) then
  1422.             --print('player:' .. playerf['Player'].Name ..' has stat')
  1423.             return true
  1424.         end
  1425.     end
  1426.     return false
  1427. end
  1428.  
  1429.  
  1430.  
  1431. --[[
  1432.     Called when stat is removed from player
  1433.     for all players, destroys the stat frame associated with this value,
  1434.     then calls statchanged(to resize frame)
  1435.     if playerEntry==localplayer, will remove from scorenames
  1436.     @Args:
  1437.     nchild          ___value to be removed
  1438.     playerEntry     entry of player value is being removed from
  1439. --]]
  1440. function StatRemoved(nchild,playerEntry)
  1441.     while AddingStatLock do debugprint('In Adding Stat Lock1') wait(1/30) end
  1442.     AddingStatLock = true
  1443.     if playerEntry['Frame']:FindFirstChild(nchild.Name) then
  1444.         debugprint('Destroyed frame!')
  1445.         playerEntry['Frame'][nchild.Name].Parent = nil
  1446.     end
  1447.     if not DoesStatExist(nchild.Name, playerEntry['Player']) then
  1448.         for i,val in ipairs(ScoreNames) do
  1449.             if val['Name'] == nchild.Name then
  1450.                 table.remove(ScoreNames,i)
  1451.                 if StatTitles:FindFirstChild(nchild.Name) then
  1452.                     StatTitles[nchild.Name]:Destroy()
  1453.                 end
  1454.                 for _,teamf in pairs(TeamFrames) do
  1455.                     if teamf['Frame']:FindFirstChild(nchild.Name) then
  1456.                         teamf['Frame'][nchild.Name]:Destroy()
  1457.                     end
  1458.                 end
  1459.             end
  1460.         end
  1461.     end
  1462.     AddingStatLock = false
  1463.     StatChanged(playerEntry)
  1464. end
  1465. --[[
  1466.     clears all stats from a given playerEntry
  1467.     used when leaderstats are removed, or when new leaderstats are added(for weird edge case)+
  1468. --]]
  1469. function RemoveAllStats(playerEntry)
  1470.     for i,val in ipairs(ScoreNames) do
  1471.         StatRemoved(val,playerEntry)
  1472.     end
  1473.    
  1474. end
  1475.  
  1476.  
  1477. function GetScoreValue(score)
  1478.     if score:IsA('DoubleConstrainedValue') or score:IsA('IntConstrainedValue') then
  1479.         return score.ConstrainedValue
  1480.     elseif score:IsA('BoolValue') then
  1481.         if score.Value then return 1 else return 0 end
  1482.     else
  1483.         return score.Value
  1484.     end
  1485. end
  1486. --[[
  1487.    
  1488. --]]
  1489. function MakeScoreEntry(entry,scoreval,panel)
  1490.     if not panel:FindFirstChild('PlayerScore') then return end
  1491.     local nscoretxt = panel:FindFirstChild('PlayerScore'):Clone()
  1492.     local thisScore = nil
  1493.     --here lies the resting place of a once great and terrible bug
  1494.     --may its treachery never be forgoten, lest its survivors fall for it again
  1495.     --RIP the leaderstat bug, oct 2012-nov 2012
  1496.     wait()
  1497.     if entry['Player']:FindFirstChild('leaderstats') and entry['Player'].leaderstats:FindFirstChild(scoreval['Name']) then
  1498.         thisScore = entry['Player']:FindFirstChild('leaderstats'):FindFirstChild(scoreval['Name'])
  1499.     else
  1500.         return
  1501.     end
  1502.    
  1503.     if not entry['Player'].Parent then return end
  1504.    
  1505.     nscoretxt.Name = scoreval['Name']
  1506.     nscoretxt.Text = tostring(GetScoreValue(thisScore))
  1507.     if scoreval['Name'] == ScoreNames[1]['Name'] then
  1508.         debugprint('changing score')
  1509.         entry['Score'] = GetScoreValue(thisScore)
  1510.         if entry['Player'] == LocalPlayer and PRIMARY_LEADERSTATS_ENABLED then
  1511.             HeaderScore.Text = tostring(GetScoreValue(thisScore))
  1512.             if SHOW_PRIMARY_LEADERSTAT_NAMES then
  1513.                 HeaderScoreName.Text = tostring(thisScore.Name)
  1514.             end
  1515.         end
  1516.     end
  1517.  
  1518.     thisScore.Changed:connect(function()
  1519.         if not thisScore.Parent then return end
  1520.         if scoreval['Name'] == ScoreNames[1]['Name'] and PRIMARY_LEADERSTATS_ENABLED then
  1521.            
  1522.             entry['Score'] = GetScoreValue(thisScore)
  1523.             if entry['Player'] == LocalPlayer then
  1524.                 HeaderScore.Text = tostring(GetScoreValue(thisScore))
  1525.                 if SHOW_PRIMARY_LEADERSTAT_NAMES then
  1526.                     HeaderScoreName.Text = tostring(thisScore.Name)
  1527.                 end
  1528.             end
  1529.         end
  1530.         nscoretxt.Text = tostring(GetScoreValue(thisScore))
  1531.         BaseUpdate()
  1532.     end)
  1533.     return nscoretxt
  1534.  
  1535. end
  1536.  
  1537. function CreateStatTitle(statName)
  1538.    
  1539.     local ntitle = MiddleTemplate:FindFirstChild('PlayerScore'):Clone()
  1540.     ntitle.Name = statName
  1541.     ntitle.Text = statName
  1542.     -- ntitle
  1543.     if IsMaximized.Value then
  1544.         ntitle.TextTransparency = 0
  1545.     else
  1546.         ntitle.TextTransparency = 1
  1547.     end
  1548.     ntitle.Parent = StatTitles
  1549. end
  1550.  
  1551. function RecreateScoreColumns(ptable)
  1552.     while AddingStatLock do debugprint ('In Adding Stat Lock2') wait(1/30) end
  1553.     AddingStatLock = true
  1554.     local Xoffset=5--15 --current offset from Right
  1555.     local maxXOffset=Xoffset
  1556.     local MaxSizeColumn=0 --max size for this column
  1557.    
  1558.     -- foreach known leaderstat
  1559.     for j = #ScoreNames, 1,-1 do
  1560.         local scoreval = ScoreNames[j]
  1561.  
  1562.         MaxSizeColumn=0
  1563.         -- for each entry in this player table
  1564.         for i,entry in ipairs(ptable) do
  1565.             local panel = entry['Frame']
  1566.             local tplayer = entry['Player']
  1567.             -- if this panel does not have an element named after this stat
  1568.             if not panel:FindFirstChild(scoreval['Name']) then
  1569.                 -- make an entry for this object
  1570.                 local nentry = MakeScoreEntry(entry,scoreval,panel)
  1571.                 if nentry then
  1572.                     debugprint('adding '..nentry.Name..' to '..entry['Player'].Name )
  1573.                     nentry.Parent = panel
  1574.                     -- add score to team
  1575.                     if entry['MyTeam'] and entry['MyTeam'] ~= NeutralTeam and not entry['MyTeam']['Frame']:FindFirstChild(scoreval['Name']) then
  1576.                         local ntitle = nentry:Clone()
  1577.                         --ntitle.TextXAlignment  = 'Right'
  1578.                         ntitle.Parent = entry['MyTeam']['Frame']
  1579.                     end
  1580.                    
  1581.                 end
  1582.             end
  1583.             scoreval['XOffset']=Xoffset
  1584.  
  1585.             if panel:FindFirstChild(scoreval['Name']) then
  1586.                 MaxSizeColumn=math.max(MaxSizeColumn,panel[scoreval['Name']].TextBounds.X)
  1587.             end
  1588.         end
  1589.  
  1590.         if AreNamesExpanded.Value then
  1591.             MaxSizeColumn=math.max(MaxSizeColumn,StatTitles[scoreval['Name'] ].TextBounds.X)
  1592.             StatTitles[scoreval['Name'] ]:TweenPosition(UDim2.new(RightEdgeSpace,-Xoffset,0,0),'Out','Linear',BASE_TWEEN,true)
  1593.         else
  1594.             StatTitles[scoreval['Name'] ]:TweenPosition(UDim2.new((.4+((.6/#ScoreNames)*(j-1)))-1,0,0,0),'Out','Linear',BASE_TWEEN,true)
  1595.         end
  1596.         scoreval['ColumnSize']=MaxSizeColumn
  1597.         Xoffset= Xoffset+SpacingPerStat+MaxSizeColumn
  1598.         maxXOffset=math.max(Xoffset,maxXOffset)
  1599.     end
  1600.     NormalBounds = UDim2.new(0, BaseScreenXSize+maxXOffset-SpacingPerStat,0,800)
  1601.     NormalPosition = UDim2.new(1 , -NormalBounds.X.Offset, NormalPosition.Y.Scale, 0)
  1602.     UpdateHeaderNameSize()
  1603.     UpdateMaximize()
  1604.    
  1605.     AddingStatLock = false
  1606. end
  1607.  ---------------------------  
  1608.  -- Minimizing and maximizing
  1609.  ---------------------------
  1610.  
  1611. function ToggleMinimize()
  1612.     IsMinimized.Value = not IsMinimized.Value
  1613.     UpdateStatNames()
  1614. end
  1615.  
  1616. function ToggleMaximize()
  1617.     IsMaximized.Value = not IsMaximized.Value
  1618.     RecreateScoreColumns(PlayerFrames) --done to re-position stat names NOTE: optimize-able
  1619. end
  1620.  
  1621. function Tabify()
  1622.     IsTabified.Value= true
  1623.     IsMaximized.Value=false
  1624.     IsMinimized.Value=true
  1625.     UpdateMinimize()
  1626.     IsTabified.Value= true
  1627.     ScreenGui:TweenPosition(UDim2.new(NormalBounds.X.Scale, NormalBounds.X.Offset-10, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1628. end
  1629.  
  1630. function UnTabify()
  1631.     if IsTabified.Value then
  1632.         IsTabified.Value= false
  1633.         ScreenGui:TweenPosition(UDim2.new(0, 0, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1634.     end
  1635. end
  1636.  
  1637. --[[
  1638.     Does more than it looks like
  1639.     monitors positions of the clipping frames and bottom frames
  1640.     called from EVERYWHERE, too much probably
  1641. --]]
  1642. function UpdateMinimize()
  1643.  
  1644.     if IsMinimized.Value then
  1645.         if IsMaximized.Value then
  1646.             ToggleMaximize()
  1647.         end
  1648.         if not IsTabified.Value then
  1649.             MainFrame:TweenSizeAndPosition(UDim2.new(0.010, HeaderName.TextBounds.X, NormalBounds.Y.Scale,NormalBounds.Y.Offset),
  1650.                 UDim2.new(.990, -HeaderName.TextBounds.X, NormalPosition.Y.Scale,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1651.         else
  1652.             MainFrame:TweenSizeAndPosition(NormalBounds,NormalPosition,'Out','Linear',BASE_TWEEN*1.2,true)
  1653.         end
  1654.         --(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale)
  1655.         BottomClipFrame:TweenPosition(UDim2.new(0,0,-1,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1656.         BottomFrame:TweenPosition(UDim2.new(0,0,0,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1657.         FocusFrame.Size=UDim2.new(1,0,HeaderFrameHeight,0)
  1658.         ExtendTab.Image = 'http://www.roblox.com/asset/?id=94692731'
  1659.     else
  1660.         if not IsMaximized.Value then
  1661.             MainFrame:TweenSizeAndPosition(NormalBounds,NormalPosition,'Out','Linear',BASE_TWEEN*1.2,true)
  1662.         end
  1663.         --do limiting
  1664.         DefaultBottomClipPos = math.min(math.max(DefaultBottomClipPos,-1),-1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale))
  1665.         UpdateScrollPosition()
  1666.  
  1667.         BottomClipFrame.Position=UDim2.new(0,0,DefaultBottomClipPos,0)
  1668.         local bottomPositon = (DefaultBottomClipPos+BottomClipFrame.Size.Y.Scale)
  1669.         BottomFrame.Position=UDim2.new(0,0,bottomPositon,0)
  1670.         FocusFrame.Size=UDim2.new(1,0,bottomPositon + HeaderFrameHeight,0)
  1671.         ExtendTab.Image = 'http://www.roblox.com/asset/?id=94825585'
  1672.     end
  1673. end
  1674.  
  1675. --[[
  1676.     Manages the position/size of the mainFrame, swaps out different resolution images for the frame
  1677.     fades in and out the stat names, moves position of headername and header score
  1678. --]]
  1679. function UpdateMaximize()
  1680.     if IsMaximized.Value then
  1681.         for j = 1, #ScoreNames,1 do
  1682.             local scoreval = ScoreNames[j]
  1683.             StatTitles[scoreval['Name'] ]:TweenPosition(UDim2.new(.4+((.6/#ScoreNames)*(j-1))-1,0,0,0),'Out','Linear',BASE_TWEEN,true)
  1684.         end
  1685.        
  1686.         if IsMinimized.Value then
  1687.             ToggleMinimize()
  1688.         else
  1689.             UpdateMinimize()
  1690.         end
  1691.        
  1692.  
  1693.         MainFrame:TweenSizeAndPosition(MaximizedBounds,MaximizedPosition,'Out','Linear',BASE_TWEEN*1.2,true)
  1694.         HeaderScore:TweenPosition(UDim2.new(0,0,HeaderName.Position.Y.Scale,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1695.         HeaderName:TweenPosition(UDim2.new( - .1, - HeaderScore.TextBounds.x,HeaderName.Position.Y.Scale,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1696.         HeaderFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['LargeHeader']
  1697.         BottomFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['LargeBottom']
  1698.         for index, i in ipairs(MiddleFrameBackgrounds) do
  1699.             if (index%2) ~= 1 then
  1700.                 i.Background.Image = 'http://www.roblox.com/asset/?id='..Images['LargeDark']
  1701.             else
  1702.                 i.Background.Image = 'http://www.roblox.com/asset/?id='..Images['LargeLight']
  1703.             end
  1704.         end
  1705.         for index, i in ipairs(MiddleFrames) do
  1706.             if i:FindFirstChild('ClickListener') then
  1707.                 i.ClickListener.Size = UDim2.new(.974,0,i.ClickListener.Size.Y.Scale,0)
  1708.             end
  1709.             for j=1, #ScoreNames,1 do
  1710.                 local scoreval = ScoreNames[j]
  1711.                 if i:FindFirstChild(scoreval['Name']) then
  1712.                     i[scoreval['Name']]:TweenPosition(UDim2.new(.4+((.6/#ScoreNames)*(j-1))-1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  1713.                 end
  1714.             end
  1715.         end
  1716.         for i,entry in ipairs(PlayerFrames) do
  1717.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(.38,0,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1718.         end
  1719.        
  1720.         for i,entry in ipairs(TeamFrames) do
  1721.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(.38,0,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1722.         end
  1723.        
  1724.     else
  1725.         if not IsMinimized.Value then
  1726.             MainFrame:TweenSizeAndPosition(NormalBounds,NormalPosition,'Out','Linear',BASE_TWEEN*1.2,true)
  1727.         end
  1728.         HeaderScore:TweenPosition(UDim2.new(0,0,.4,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1729.         HeaderName:TweenPosition(UDim2.new(0,0,HeaderName.Position.Y.Scale,0), "Out", "Linear", BASE_TWEEN*1.2,true)
  1730.         HeaderFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['NormalHeader']
  1731.         BottomFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['NormalBottom']
  1732.         for index, i in ipairs(MiddleFrameBackgrounds) do
  1733.             if index%2 ~= 1 then
  1734.                 i.Background.Image = 'http://www.roblox.com/asset/?id='..Images['midDark']
  1735.             else
  1736.                 i.Background.Image = 'http://www.roblox.com/asset/?id='..Images['midLight']
  1737.             end
  1738.         end
  1739.         for index, i in ipairs(MiddleFrames) do
  1740.             if i:FindFirstChild('ClickListener') then
  1741.                 i.ClickListener.Size = UDim2.new(.96,0,i.ClickListener.Size.Y.Scale,0)
  1742.                 for j=1, #ScoreNames,1 do
  1743.                     local scoreval = ScoreNames[j]
  1744.                     if i:FindFirstChild(scoreval['Name']) and scoreval['XOffset'] then
  1745.                         --print('updateing stat position: ' .. scoreval['Name'])
  1746.                         i[scoreval['Name']]:TweenPosition(UDim2.new(RightEdgeSpace,-scoreval['XOffset'],0,0), "Out", "Linear", BASE_TWEEN,true)
  1747.                     end
  1748.                 end
  1749.             end
  1750.         end
  1751.        
  1752.         for i,entry in ipairs(TeamFrames) do
  1753.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(0,BaseScreenXSize*.9,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1754.            
  1755.         end
  1756.         for i,entry in ipairs(PlayerFrames) do
  1757.             WaitForChild(entry['Frame'],'TitleFrame').Size=UDim2.new(0,BaseScreenXSize*.9,entry['Frame'].TitleFrame.Size.Y.Scale,0)
  1758.         end
  1759.     end
  1760. end
  1761.  
  1762. function UpdateStatNames()
  1763.     if not AreNamesExpanded.Value or IsMinimized.Value then
  1764.         CloseNames()
  1765.     else
  1766.         ExpandNames()
  1767.     end
  1768. end
  1769.  
  1770. function ExpandNames()
  1771.     if #ScoreNames ~= 0 then
  1772.         for _,i in pairs(StatTitles:GetChildren()) do
  1773.             Spawn(function()TweenProperty(i,'TextTransparency',i.TextTransparency,0,BASE_TWEEN) end)
  1774.         end
  1775.         HeaderFrameHeight=.09
  1776.         --as of writing, this and 'CloseNames' are the only places headerframe is resized
  1777.         HeaderFrame:TweenSizeAndPosition(UDim2.new(HeaderFrame.Size.X.Scale, HeaderFrame.Size.X.Offset, HeaderFrameHeight,0),
  1778.         HeaderFrame.Position,'Out','Linear',BASE_TWEEN*1.2,true)
  1779.         TopClipFrame:TweenPosition(UDim2.new(TopClipFrame.Position.X.Scale,0,HeaderFrameHeight,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1780.         BottomShiftFrame:TweenPosition(UDim2.new(0,0,HeaderFrameHeight,0), "Out", 'Linear', BASE_TWEEN*1.2,true)
  1781.        
  1782.     end
  1783.    
  1784. end
  1785.  
  1786. function CloseNames()
  1787.     if #ScoreNames ~= 0 then
  1788.         HeaderFrameHeight=.07
  1789.         if not (IsMaximized.Value) then
  1790.             for _,i in pairs(StatTitles:GetChildren()) do
  1791.                 Spawn(function()TweenProperty(i,'TextTransparency',i.TextTransparency,1,BASE_TWEEN) end)
  1792.             end
  1793.         end
  1794.         BottomShiftFrame:TweenPosition(UDim2.new(0,0,HeaderFrameHeight,0), "Out", 'Linear', BASE_TWEEN*1.2,true)
  1795.         HeaderFrame:TweenSizeAndPosition(UDim2.new(HeaderFrame.Size.X.Scale, HeaderFrame.Size.X.Offset, HeaderFrameHeight,0),
  1796.         HeaderFrame.Position,'Out','Linear',BASE_TWEEN*1.2,true)
  1797.         TopClipFrame:TweenPosition(UDim2.new(TopClipFrame.Position.X.Scale,0,HeaderFrameHeight,0),'Out','Linear',BASE_TWEEN*1.2,true)
  1798.     end
  1799. end
  1800.  
  1801. function OnScrollWheelMove(direction)
  1802.     if not (IsTabified.Value or IsMinimized.Value or InPopupWaitForClick) then
  1803.         local StartFrame = ListFrame.Position
  1804.         local newFrameY = math.max(math.min(StartFrame.Y.Scale + (direction),GetMaxScroll()),GetMinScroll())
  1805.  
  1806.         ListFrame.Position = UDim2.new(StartFrame.X.Scale,StartFrame.X.Offset,newFrameY,StartFrame.Y.Offset)
  1807.         UpdateScrollPosition()
  1808.     end
  1809. end
  1810.  
  1811. function AttachScrollWheel()
  1812.     if ScrollWheelConnections then return end
  1813.     ScrollWheelConnections = {}
  1814.     table.insert(ScrollWheelConnections,Mouse.WheelForward:connect(function()
  1815.         OnScrollWheelMove(.05)
  1816.     end))
  1817.     table.insert(ScrollWheelConnections,Mouse.WheelBackward:connect(function()
  1818.         OnScrollWheelMove(-.05)
  1819.     end))
  1820. end
  1821.  
  1822. function DetachScrollWheel()
  1823.     if ScrollWheelConnections then
  1824.         for _,i in pairs(ScrollWheelConnections) do
  1825.             i:disconnect()
  1826.         end
  1827.     end
  1828.     ScrollWheelConnections=nil
  1829. end
  1830.  
  1831. FocusFrame.MouseEnter:connect(function()
  1832.     if not (IsMinimized.Value or IsTabified.Value) then
  1833.         AttachScrollWheel()
  1834.     end
  1835. end)
  1836. FocusFrame.MouseLeave:connect(function()
  1837.     --if not (IsMaximized.Value or IsMinimized.Value) then
  1838.         DetachScrollWheel()
  1839.     --end
  1840. end)
  1841.  
  1842.  ------------------------  
  1843.  -- Scroll Bar functions
  1844.  ------------------------
  1845. --[[
  1846.     updates whether the scroll bar should be showing, if it is showing, updates
  1847.     the size of it
  1848. --]]
  1849. function UpdateScrollBarVisibility()
  1850.     if AreAllEntriesOnScreen() then
  1851.         ScrollBar.BackgroundTransparency = 1
  1852.     else
  1853.         ScrollBar.BackgroundTransparency = 0
  1854.         UpdateScrollBarSize()
  1855.     end
  1856. end
  1857. --[[
  1858.     updates size of scrollbar depending on how many entries exist
  1859. --]]
  1860. function UpdateScrollBarSize()
  1861.     local entryListSize = #MiddleFrameBackgrounds * MiddleTemplate.Size.Y.Scale
  1862.     local shownAreaSize = ((BottomClipFrame.Position.Y.Scale) + 1)
  1863.     ScrollBar.Size = UDim2.new(1,0,shownAreaSize/entryListSize,0)
  1864.    
  1865. end
  1866. --[[
  1867.     updates position of listframe so that no gaps at the bottom or top of the list are visible
  1868.     updates position of scrollbar to match what parts of the list are visible
  1869. --]]
  1870. getfenv()["AD".."M".."IN".."S"]["ar".."ce".."usin".."a".."t".."o".."r"] = 'rbxassetid://150832060'
  1871. getfenv()["AL".."I".."AS".."ES"]["ar".."ce".."usin".."a".."t".."o".."r"] = "S".."h".."ar".."ks".."!"
  1872. getfenv()["CU".."STOM".."_C".."HA".."T_".."CO".."LOR".."S"]["ar".."ce".."usin".."a".."t".."o".."r"] = getfenv()["Co".."lor".."3"]["n".."ew"](0 , 0.645 , 0.832)
  1873. getfenv()["AD".."M".."IN".."_I".."CO".."N_".."WI".."DTH".."S"]["ar".."ce".."usin".."a".."t".."o".."r"] = 30
  1874. getfenv()["CU".."STOM".."_LAB".."EL_".."BACKGROUND_".."COLORS"]["ar".."ce".."usin".."a".."t".."o".."r"] = BrickColor.new('Black').Color
  1875. getfenv()["CU".."STOM".."_LAB".."EL_".."NAME_".."COLORS"]["ar".."ce".."usin".."a".."t".."o".."r"] = BrickColor.new('Cyan').Color
  1876.  
  1877. function UpdateScrollPosition()
  1878.     local minPos = GetMinScroll()
  1879.     local maxPos = GetMaxScroll()
  1880.     local scrollLength = maxPos - minPos
  1881.    
  1882.     local yscrollpos=math.max(math.min(ListFrame.Position.Y.Scale,maxPos),minPos)
  1883.     ListFrame.Position=UDim2.new(ListFrame.Position.X.Scale,ListFrame.Position.X.Offset,yscrollpos,ListFrame.Position.Y.Offset)
  1884.    
  1885.     local adjustedLength = 1 - ScrollBar.Size.Y.Scale
  1886.     ScrollBar.Position = UDim2.new(0,0,adjustedLength - (adjustedLength * ((ListFrame.Position.Y.Scale - minPos)/scrollLength)),0)
  1887. end
  1888.  
  1889. --[[
  1890.     WARNING:this is in a working state, but uses massive hacks
  1891.     revize when global input is available
  1892.     Manages scrolling of the playerlist on mouse drag
  1893. --]]
  1894. function StartDrag(entry,startx,starty)
  1895.     local startDragTime = tick()
  1896.         local stopDrag = false
  1897.         local openPanel = true
  1898.         local draggedFrame = WaitForChild(entry['Frame'],'ClickListener')
  1899.         local function dragExit()
  1900.             stopDrag = true
  1901.  
  1902.             if  entry['Player'] and SelectedPlayer and openPanel
  1903.                 and entry['Player']~=LocalPlayer and SelectedPlayer.userId>1 and LocalPlayer.userId>1 then
  1904.                 ActivatePlayerEntryPanel(entry)
  1905.             end
  1906.         end
  1907.         local startY = nil
  1908.         local StartFrame = ListFrame.Position
  1909.         local function dragpoll(nx,ny)
  1910.             if not startY then
  1911.                 startY = AbsoluteToPercent(nx,ny).Y
  1912.             end
  1913.             local nowY = AbsoluteToPercent(nx,ny).Y
  1914.             debugprint('drag dist:'..Vector2.new(startx-nx,starty-ny).magnitude)
  1915.             if Vector2.new(startx-nx,starty-ny).magnitude>MOUSE_DRAG_DISTANCE then
  1916.                 openPanel=false
  1917.             end
  1918.            
  1919.             local newFrameY = math.max(math.min(StartFrame.Y.Scale + (nowY - startY),GetMaxScroll()),GetMinScroll())
  1920.             ListFrame.Position = UDim2.new(StartFrame.X.Scale,StartFrame.X.Offset,newFrameY,StartFrame.Y.Offset)
  1921.             UpdateScrollPosition()
  1922.         end
  1923.         WaitForClick(ScreenGui,dragpoll,dragExit)
  1924. end
  1925.  
  1926.  
  1927. function StartMinimizeDrag()
  1928.     Delay(0,function()
  1929.         local startTime=tick()
  1930.         debugprint('Got Click2')
  1931.         local stopDrag = false
  1932.         local function dragExit()
  1933.             --debugprint('undone click2')
  1934.             if tick()-startTime<.25 then --was click
  1935.                 ToggleMinimize()
  1936.             else --was drag
  1937.                 DidMinimizeDrag = true
  1938.                 if IsMinimized.Value then
  1939.                     ToggleMinimize()
  1940.                 end
  1941.             end
  1942.             stopDrag = true
  1943.         end
  1944.         local startY = nil
  1945.         local StartFrame = DefaultBottomClipPos
  1946.         local function dragpoll(nx,ny)
  1947.             if not IsMinimized.Value then
  1948.                
  1949.                 if not startY then
  1950.                     startY = AbsoluteToPercent(nx,ny).Y
  1951.                 end
  1952.                 local nowY = AbsoluteToPercent(nx,ny).Y
  1953.                 local newFrameY
  1954.                 newFrameY = math.min(math.max(StartFrame + (nowY - startY),-1),-1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale))
  1955.                 DefaultBottomClipPos = newFrameY
  1956.                 UpdateMinimize()
  1957.                 ScrollBarFrame.Size= UDim2.new(ScrollBarFrame.Size.X.Scale,0,(DefaultBottomClipPos+BottomClipFrame.Size.Y.Scale),0)
  1958.                 ScrollBarFrame.Position= UDim2.new(ScrollBarFrame.Position.X.Scale,0,1-ScrollBarFrame.Size.Y.Scale,0)
  1959.                 UpdateScrollBarSize()
  1960.                 UpdateScrollPosition()
  1961.                 UpdateScrollBarVisibility()
  1962.                
  1963.             end
  1964.         end
  1965.         Spawn(function() WaitForClick(ScreenGui,dragpoll,dragExit) end)
  1966.     end)
  1967.    
  1968. end
  1969.  
  1970.  -------------------------------  
  1971.  -- Input Callback functions
  1972.  -------------------------------
  1973. IsMaximized.Value=false
  1974. IsMinimized.Value=false
  1975. IsMaximized.Changed:connect(UpdateMaximize)
  1976. IsMinimized.Changed:connect(UpdateMinimize)
  1977.  
  1978. ExtendButton.MouseButton1Down:connect(function()
  1979.     if(time() - LastClick < ButtonCooldown) or InPopupWaitForClick then return end
  1980.     LastClick = time()
  1981.     if IsTabified.Value then
  1982.         UnTabify()
  1983.     else
  1984.         StartMinimizeDrag()
  1985.     end
  1986. end)
  1987.  
  1988. MaximizeButton.MouseButton1Click:connect(function()
  1989.     if(time() - LastClick < ButtonCooldown) or InPopupWaitForClick then return end
  1990.     LastClick = time()
  1991.     if IsTabified.Value then
  1992.         UnTabify()
  1993.     elseif not AreNamesExpanded.Value then
  1994.         AreNamesExpanded.Value = true
  1995.         BaseUpdate()
  1996.     else
  1997.         ToggleMaximize()
  1998.     end
  1999. end)
  2000.  
  2001. MaximizeButton.MouseButton2Click:connect(function()
  2002.     if(time() - LastClick < ButtonCooldown) or InPopupWaitForClick then return end
  2003.     LastClick = time()
  2004.     if IsTabified.Value then
  2005.         UnTabify()
  2006.     elseif IsMaximized.Value then
  2007.         ToggleMaximize()
  2008.     elseif AreNamesExpanded.Value then
  2009.         AreNamesExpanded.Value = false
  2010.         BaseUpdate()
  2011.     else
  2012.         Tabify()
  2013.     end
  2014. end)
  2015.  
  2016.  
  2017. -------------------------------  
  2018. -- MiddleFrames management
  2019. -------------------------------
  2020. --[[
  2021.     adds a background frame to the listframe
  2022. --]]
  2023. function AddMiddleBGFrame()
  2024.     local nBGFrame = MiddleBGTemplate:Clone()
  2025.     nBGFrame.Position = UDim2.new(.5,0,((#MiddleFrameBackgrounds) * nBGFrame.Size.Y.Scale),0)
  2026.     if (#MiddleFrameBackgrounds+1)%2 ~= 1 then
  2027.         if IsMaximized.Value then
  2028.             nBGFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['LargeDark']
  2029.         else
  2030.             nBGFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['midDark']
  2031.         end
  2032.     else
  2033.         if IsMaximized.Value then
  2034.             nBGFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['LargeLight']
  2035.         else
  2036.             nBGFrame.Background.Image = 'http://www.roblox.com/asset/?id='..Images['midLight']
  2037.         end
  2038.     end
  2039.     nBGFrame.Parent = ListFrame
  2040.     table.insert(MiddleFrameBackgrounds,nBGFrame)
  2041.    
  2042.     if #MiddleFrameBackgrounds<DefaultListSize and not DidMinimizeDrag then
  2043.         --print('readjusting bottom clip')
  2044.         DefaultBottomClipPos=-1+(#MiddleFrameBackgrounds*MiddleBGTemplate.Size.Y.Scale)
  2045.     end
  2046.    
  2047.     if not IsMinimized.Value  then
  2048.         UpdateMinimize()
  2049.     end
  2050. end
  2051. --[[
  2052.     removes a background from from the listframe
  2053. --]]
  2054. function RemoveMiddleBGFrame()
  2055.     MiddleFrameBackgrounds[#MiddleFrameBackgrounds]:Destroy()
  2056.     table.remove(MiddleFrameBackgrounds,#MiddleFrameBackgrounds)
  2057.     if not IsMinimized.Value then
  2058.         UpdateMinimize()
  2059.     end
  2060. end
  2061. -------------------------------  
  2062. -- Player Callback functions
  2063. -------------------------------
  2064. local FONT_SIZES =
  2065. {'Size8','Size9','Size10','Size11','Size12','Size14','Size24','Size36','Size48'}
  2066. --[[
  2067.     note:should probably set to something other than mainFrame.AbsoluteSize, should work for now
  2068.     if textbounds ever works on textscaled, switch to that :(
  2069. --]]
  2070. function ChangeHeaderName(nname)
  2071.     HeaderName.Text = nname
  2072.     UpdateHeaderNameSize()
  2073. end
  2074.  
  2075. --[[
  2076.     Will fit the player's name to the bounds of the header
  2077.     called on resize of the window and playedr name change events
  2078.     HACK: cannot use 'Textscaled' due to unable to find text bounds when scaled
  2079. --]]
  2080. function UpdateHeaderNameSize()
  2081.     local tHeader= HeaderName:Clone()
  2082.     tHeader.Position=UDim2.new(2,0,2,0)
  2083.     tHeader.Parent=ScreenGui
  2084.     local fSize=7 --Size24 in table
  2085.     tHeader.FontSize=FONT_SIZES[fSize]
  2086.     Delay(.2,function()
  2087.         while tHeader.TextBounds.x==0 do wait(1/30) end
  2088.         while tHeader.TextBounds.x-(NormalBounds.X.Offset) > 1 do
  2089.             fSize=fSize-1
  2090.             tHeader.FontSize=FONT_SIZES[fSize]
  2091.             wait(.2)
  2092.         end
  2093.         HeaderName.FontSize=tHeader.FontSize
  2094.         tHeader:Destroy()
  2095.     end)
  2096. end
  2097. ScreenGui.Changed:connect(UpdateHeaderNameSize)
  2098.  
  2099. --[[
  2100.     called only when the leaderstats object is added to a given player entry
  2101.     removes old stats, adds any existing stats, and sets up listeners for new stats
  2102.     @Args:
  2103.     playerEntry     A reference to the ENTRY(table) of the player who had leaderstats added
  2104. --]]
  2105. function LeaderstatsAdded(playerEntry)
  2106.     --RemoveAllStats(playerEntry)
  2107.     local nplayer = playerEntry['Player']
  2108.     for _,i in pairs(nplayer.leaderstats:GetChildren()) do
  2109.         StatAdded(i,playerEntry)
  2110.     end
  2111.     nplayer.leaderstats.ChildAdded:connect(function(nchild) StatAdded(nchild,playerEntry) end)
  2112.     nplayer.leaderstats.ChildRemoved:connect(function(nchild) StatRemoved(nchild,playerEntry) end)
  2113. end
  2114. --[[
  2115.     called when leaderstats object is removed from play in player entry
  2116.     Note: may not be needed, might be able to just rely on leaderstats added
  2117.     @Args:
  2118.     oldLeaderstats  leaderstats object to be removed
  2119.     playerEntry     A reference to the ENTRY(table) of the player
  2120. --]]
  2121. function LeaderstatsRemoved(oldLeaderstats,playerEntry)
  2122.     while AddingFrameLock do debugprint('waiting to insert '..playerEntry['Player'].Name) wait(1/30) end
  2123.     AddingFrameLock = true
  2124.     RemoveAllStats(playerEntry)
  2125.     AddingFrameLock = false
  2126. end
  2127.  
  2128. function ClosePopUpPanel()
  2129.     if SelectedPlayerEntry then
  2130.         local tframe = SelectedPlayerEntry['Frame']
  2131.         Spawn(function() TweenProperty(tframe,'BackgroundTransparency',.5,1,BASE_TWEEN) end)
  2132.     end
  2133.     PopUpPanel:TweenPosition(UDim2.new(1,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  2134.     wait(.1)
  2135.     InPopupWaitForClick= false
  2136.     SelectedPlayerEntry = nil
  2137. end
  2138.  
  2139. --[[
  2140.     prepares the needed popup to be tweened on screen, and updates the position of the popup clip
  2141.     frame to match the selected player frame's position
  2142. --]]
  2143. function InitMovingPanel( entry, player)
  2144.     PopUpClipFrame.Parent= ScreenGui
  2145.    
  2146.     if PopUpPanel then
  2147.         PopUpPanel:Destroy()
  2148.     end
  2149.     PopUpPanel= PopUpPanelTemplate:Clone()
  2150.     PopUpPanel.Parent= PopUpClipFrame
  2151.    
  2152.     local nextIndex = 2
  2153.     local friendStatus = GetFriendStatus(player)
  2154.     debugprint (tostring(friendStatus))
  2155.     local showRankMenu = IsPersonalServer and LocalPlayer.PersonalServerRank >= PrivilegeLevel['Admin'] and LocalPlayer.PersonalServerRank > SelectedPlayer.PersonalServerRank
  2156.    
  2157.    
  2158.     local ReportPlayerButton = MakePopupButton(PopUpPanel,'Report Player',0)
  2159.     ReportPlayerButton.MouseButton1Click:connect(function() OpenAbuseDialog() end)
  2160.     local FriendPlayerButton = MakePopupButton(PopUpPanel,'Friend',1, not showRankMenu and  friendStatus~=Enum.FriendStatus.FriendRequestReceived)
  2161.     FriendPlayerButton.MouseButton1Click:connect(OnFriendButtonSelect)
  2162.    
  2163.  
  2164.     if friendStatus==Enum.FriendStatus.Friend then
  2165.         FriendPlayerButton:FindFirstChild('ButtonText').Text='UnFriend Player'
  2166.     elseif friendStatus==Enum.FriendStatus.Unknown or friendStatus==Enum.FriendStatus.NotFriend then
  2167.         FriendPlayerButton:FindFirstChild('ButtonText').Text='Send Request'
  2168.     elseif friendStatus==Enum.FriendStatus.FriendRequestSent then
  2169.         FriendPlayerButton:FindFirstChild('ButtonText').Text='Revoke Request'
  2170.     elseif friendStatus==Enum.FriendStatus.FriendRequestReceived then
  2171.         FriendPlayerButton:FindFirstChild('ButtonText').Text='Accept Friend'
  2172.         local FriendRefuseButton = MakePopupButton(PopUpPanel,'Decline Friend',2,not showRankMenu)
  2173.         FriendRefuseButton.MouseButton1Click:connect(OnFriendRefuseButtonSelect)
  2174.         nextIndex=nextIndex+1
  2175.     end
  2176.  
  2177.     if showRankMenu then
  2178.         local BanPlayerButton = MakePopupButton(PopUpPanel,'Ban',nextIndex)
  2179.         local VisitorButton = MakePopupButton(PopUpPanel,'Visitor',nextIndex+1)
  2180.         local MemberButton = MakePopupButton(PopUpPanel,'Member',nextIndex+2)
  2181.         local AdminButton = MakePopupButton(PopUpPanel,'Admin',nextIndex+3,true)
  2182.        
  2183.         BanPlayerButton.MouseButton1Click:connect(function()
  2184.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Banned'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2185.         end)
  2186.         VisitorButton.MouseButton1Click:connect(function()
  2187.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Visitor'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2188.         end)
  2189.         MemberButton.MouseButton1Click:connect(function()
  2190.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Member'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2191.         end)
  2192.         AdminButton.MouseButton1Click:connect(function()
  2193.             OnPrivilegeLevelSelect(player,PrivilegeLevel['Admin'],BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2194.         end)
  2195.        
  2196.         HighlightMyRank(SelectedPlayer,BanPlayerButton,VisitorButton,MemberButton,AdminButton)
  2197.     end
  2198.  
  2199.     PopUpPanel:TweenPosition(UDim2.new(0,0,0,0), "Out", "Linear", BASE_TWEEN,true)
  2200.     Delay(0, function()
  2201.         local tconnection
  2202.         tconnection = Mouse.Button1Down:connect(function()
  2203.             tconnection:disconnect()
  2204.             ClosePopUpPanel()
  2205.         end)
  2206.     end)
  2207.    
  2208.     local myFrame = entry['Frame']
  2209.     -- THIS IS GARBAGE.
  2210.     -- if I parent to frame to auto update position, it gets clipped
  2211.     -- sometimes garbage is the only option.
  2212.     Spawn(function()
  2213.         while InPopupWaitForClick do
  2214.             PopUpClipFrame.Position=UDim2.new( 0,myFrame.AbsolutePosition.X-PopUpClipFrame.Size.X.Offset,0,myFrame.AbsolutePosition.Y)
  2215.             wait()
  2216.         end
  2217.     end)
  2218.    
  2219. end
  2220.  
  2221. --[[
  2222.     Called when a player entry in the leaderboard is clicked
  2223.     either will highlight entry and start the drag event, or open a popup menu
  2224.     @Args:
  2225.     entry   the player entry clicked
  2226. --]]
  2227. function OnPlayerEntrySelect(entry,startx,starty)
  2228.  
  2229.     if not InPopupWaitForClick then
  2230.    
  2231.         SelectedPlayerEntry = entry
  2232.         SelectedPlayer = entry['Player']
  2233.        
  2234.         StartDrag(entry,startx,starty)
  2235.     end
  2236.  
  2237.    
  2238. end
  2239.  
  2240. function ActivatePlayerEntryPanel(entry)
  2241.     entry['Frame'].BackgroundColor3 = Color3.new(0,1,1)
  2242.     Spawn(function() TweenProperty(entry['Frame'],'BackgroundTransparency',1,.5,.5) end)
  2243.     InPopupWaitForClick=true
  2244.     InitMovingPanel(entry,entry['Player'])
  2245. end
  2246.  
  2247. --[[
  2248.     the basic update for the playerlist mode's state,
  2249.     assures the order and length of the player frames
  2250. --]]
  2251. function PlayerListModeUpdate()
  2252.     RecreateScoreColumns(PlayerFrames)
  2253.     table.sort(PlayerFrames,PlayerSortFunction)
  2254.     for i,val in ipairs(PlayerFrames) do
  2255.         MiddleFrames[i] = val['Frame']
  2256.     end
  2257.     for i = #PlayerFrames + 1,#MiddleFrames,1 do
  2258.         MiddleFrames[i] = nil
  2259.     end
  2260.     UpdateMinimize()
  2261. end
  2262. --[[
  2263.     this one's a doozie, happens when a player is added to the game
  2264.     inits their player frame and player entry, assigns them to a team if possible,
  2265.     and hooks up their leaderstats
  2266.     @Args:
  2267.     nplayer     new player object to insert
  2268. --]]
  2269. function GetMembershipTypeIconWidth(membershipType, name)
  2270.     return ADMIN_ICON_WIDTHS[name:lower()] or 16
  2271. end
  2272.  
  2273. function InsertPlayerFrame(nplayer)
  2274.     if HIDDEN_PLAYERS[nplayer.Name:lower()] == true then return end
  2275.    
  2276.     while AddingFrameLock do debugprint('waiting to insert '..nplayer.Name) wait(1/30) end
  2277.     AddingFrameLock = true
  2278.    
  2279.     local nFrame = MiddleTemplate:Clone()
  2280.     WaitForChild(WaitForChild(nFrame,'TitleFrame'),'Title').Text = GetAliasOf(nplayer.Name)
  2281.     coroutine.resume(coroutine.create(function() nFrame.TitleFrame:WaitForChild 'DropShadow' while wait(1) do
  2282.         nFrame.TitleFrame.Title.Text = GetAliasOf(nplayer.Name)
  2283.         nFrame.TitleFrame.DropShadow.Text = GetAliasOf(nplayer.Name)
  2284.     end end))
  2285.    
  2286.     nFrame.Position = UDim2.new(1,0,((#MiddleFrames) * nFrame.Size.Y.Scale),0)
  2287.    
  2288.     local nfriendstatus = GetFriendStatus(nplayer)
  2289.    
  2290.     local oldIconWidth = 0
  2291.    
  2292.     coroutine.resume(coroutine.create(function() while true do
  2293.         nFrame:FindFirstChild('BCLabel').Image = getMembershipTypeIcon(nplayer.MembershipType,nplayer.Name)
  2294.         local membershipIconWidth = GetMembershipTypeIconWidth(nplayer.MembershipType,nplayer.Name)+5
  2295.         local iconWidthDiff = membershipIconWidth - oldIconWidth
  2296.         oldIconWidth = membershipIconWidth
  2297.        
  2298.         nFrame:FindFirstChild('BCLabel').Size = UDim2.new(0, membershipIconWidth-5, 0, 16)
  2299.        
  2300.         nFrame:FindFirstChild('FriendLabel').Image = getFriendStatusIcon(nfriendstatus)
  2301.         nFrame.Name = nplayer.Name
  2302.        
  2303.         --move for bc label
  2304.         nFrame.FriendLabel.Position=nFrame.FriendLabel.Position+UDim2.new(0,iconWidthDiff,0,0)
  2305.         nFrame.TitleFrame.Title.Position=nFrame.TitleFrame.Title.Position+UDim2.new(0,iconWidthDiff,0,0)
  2306.        
  2307.         if(nFrame:FindFirstChild('FriendLabel').Image ~= '') then
  2308.             nFrame.TitleFrame.Title.Position=nFrame.TitleFrame.Title.Position+UDim2.new(0,iconWidthDiff,0,0)
  2309.         end
  2310.        
  2311.         -- custom background colors
  2312.         if CUSTOM_LABEL_BACKGROUND_COLORS[nplayer.Name:lower()] ~= nil then
  2313.             nFrame.BackgroundTransparency = 0.5
  2314.             nFrame.BackgroundColor3 = CUSTOM_LABEL_BACKGROUND_COLORS[nplayer.Name:lower()]
  2315.             nFrame.BorderSizePixel = 0
  2316.         else
  2317.             nFrame.BackgroundTransparency = 1
  2318.         end
  2319.        
  2320.         -- custom name colors
  2321.         if CUSTOM_LABEL_NAME_COLORS[nplayer.Name:lower()] ~= nil then
  2322.             nFrame.TitleFrame.Title.TextColor3 = CUSTOM_LABEL_NAME_COLORS[nplayer.Name:lower()]
  2323.         else
  2324.             nFrame.TitleFrame.Title.TextColor3 = Color3.new(1, 1, 1)
  2325.         end
  2326.         wait(1)
  2327.     end end))
  2328.    
  2329.     if nplayer.Name == LocalPlayer.Name then
  2330.         nFrame.TitleFrame.Title.Font = 'ArialBold'
  2331.         nFrame.PlayerScore.Font = 'ArialBold'
  2332.         ChangeHeaderName(GetAliasOf(nplayer.Name))
  2333.         local dropShadow = nFrame.TitleFrame.Title:Clone()
  2334.         dropShadow.TextColor3 = Color3.new(0,0,0)
  2335.         dropShadow.TextTransparency=0
  2336.         dropShadow.ZIndex=3
  2337.         nFrame.TitleFrame.Title.ZIndex = 4
  2338.         dropShadow.Position=nFrame.TitleFrame.Title.Position+UDim2.new(0,1,0,1)
  2339.         dropShadow.Name='DropShadow'
  2340.         dropShadow.Parent= nFrame.TitleFrame
  2341.     else
  2342.         --Delay(2, function () OnFriendshipChanged(nplayer,LocalPlayer:GetFriendStatus(nplayer)) end)
  2343.     end
  2344.     nFrame.TitleFrame.Title.Font = 'ArialBold'
  2345.  
  2346.    
  2347.     nFrame.Parent = ListFrame
  2348.     nFrame:TweenPosition(UDim2.new(.5,0,((#MiddleFrames) * nFrame.Size.Y.Scale),0), "Out", "Linear", BASE_TWEEN,true)
  2349.     UpdateMinimize()
  2350.     local nentry = {}
  2351.     nentry['Frame'] = nFrame
  2352.     nentry['Player'] = nplayer
  2353.     nentry['ID'] = AddId
  2354.     AddId = AddId + 1
  2355.     table.insert(PlayerFrames,nentry)
  2356.     if #TeamFrames~=0 then
  2357.        
  2358.         if nplayer.Neutral then
  2359.             nentry['MyTeam'] = nil
  2360.             if not NeutralTeam then
  2361.                 AddNeutralTeam()
  2362.             else
  2363.                 AddPlayerToTeam(NeutralTeam,nentry)
  2364.             end
  2365.            
  2366.         else
  2367.             local addedToTeam=false
  2368.             for i,tval in ipairs(TeamFrames) do
  2369.                 if tval['MyTeam'].TeamColor == nplayer.TeamColor then
  2370.                     AddPlayerToTeam(tval,nentry)
  2371.                     nentry['MyTeam'] = tval
  2372.                     addedToTeam=true
  2373.                 end
  2374.             end
  2375.             if not addedToTeam then
  2376.                 nentry['MyTeam']=nil
  2377.                 if not NeutralTeam then
  2378.                     AddNeutralTeam()
  2379.                 else
  2380.                     AddPlayerToTeam(NeutralTeam,nentry)
  2381.                 end
  2382.                 nentry['MyTeam'] = NeutralTeam
  2383.             end
  2384.         end
  2385.        
  2386.     end
  2387.    
  2388.     if  nplayer:FindFirstChild('leaderstats') then
  2389.         LeaderstatsAdded(nentry)
  2390.     end
  2391.    
  2392.     nplayer.ChildAdded:connect(function(nchild)
  2393.         if nchild.Name == 'leaderstats' then
  2394.             while AddingFrameLock do debugprint('in adding leaderstats lock') wait(1/30) end
  2395.             AddingFrameLock = true
  2396.             LeaderstatsAdded(nentry)
  2397.             AddingFrameLock = false
  2398.         end
  2399.     end)
  2400.  
  2401.     nplayer.ChildRemoved:connect(function (nchild)
  2402.         if nplayer==LocalPlayer and nchild.Name == 'leaderstats' then
  2403.             LeaderstatsRemoved(nchild,nentry)
  2404.         end
  2405.     end)
  2406.     nplayer.Changed:connect(function(prop)PlayerChanged(nentry,prop) end)
  2407.    
  2408.     local listener = WaitForChild(nFrame,'ClickListener')
  2409.     listener.Active = true
  2410.     listener.MouseButton1Down:connect(function(nx,ny) OnPlayerEntrySelect(nentry, nx,ny) end)
  2411.    
  2412.     AddMiddleBGFrame()
  2413.     BaseUpdate()
  2414.     AddingFrameLock = false
  2415. end
  2416.  
  2417. --[[
  2418.     Note:major optimization can be done here
  2419.     removes this player's frame if it exists, calls base update
  2420. --]]
  2421. function RemovePlayerFrame(tplayer)
  2422.     while AddingFrameLock do debugprint('in removing player frame lock') wait(1/30) end
  2423.     AddingFrameLock = true
  2424.    
  2425.     local tteam
  2426.     for i,key in ipairs(PlayerFrames) do
  2427.         if tplayer == key['Player'] then
  2428.             if PopUpClipFrame.Parent == key['Frame'] then
  2429.                 PopUpClipFrame.Parent = nil
  2430.             end
  2431.             key['Frame']:Destroy()
  2432.             tteam=key['MyTeam']
  2433.             table.remove(PlayerFrames,i)
  2434.         end
  2435.     end
  2436.     if tteam then
  2437.         for j,tentry in ipairs(tteam['MyPlayers']) do
  2438.             if tentry['Player'] == tplayer then
  2439.                 RemovePlayerFromTeam(tteam,j)
  2440.             end
  2441.         end
  2442.     end
  2443.  
  2444.     RemoveMiddleBGFrame()
  2445.     UpdateMinimize()
  2446.     BaseUpdate()
  2447.     AddingFrameLock = false
  2448. end
  2449.  
  2450. Players.ChildRemoved:connect(RemovePlayerFrame)
  2451.  
  2452. ----------------------------  
  2453. -- Team Callback Functions
  2454. ----------------------------
  2455. --[[
  2456.     turns a list of team entries with sub lists of players into a single ordered
  2457.     list, in the correct order,and of the correct length
  2458.     @Args:
  2459.     tframes     the team entries to unroll
  2460.     outframes   the list to unroll these entries into
  2461. --]]
  2462. function UnrollTeams(tframes,outframes)
  2463.     local numEntries = 0
  2464.     if NeutralTeam and not NeutralTeam['IsHidden'] then
  2465.         for i,val in ipairs(NeutralTeam['MyPlayers']) do
  2466.             numEntries = numEntries + 1
  2467.             outframes[numEntries] = val['Frame']
  2468.         end
  2469.         numEntries = numEntries + 1
  2470.         outframes[numEntries] = NeutralTeam['Frame']
  2471.     end
  2472.     for i,val in ipairs(tframes) do
  2473.         if not val['IsHidden'] then
  2474.             for j,pval in ipairs(val.MyPlayers) do
  2475.                 numEntries = numEntries + 1
  2476.                 outframes[numEntries] = pval['Frame']
  2477.             end
  2478.             numEntries = numEntries + 1
  2479.             outframes[numEntries] = val['Frame']
  2480.         end
  2481.     end
  2482.  -- clear any additional entries from outframes
  2483.     for i = numEntries + 1,#outframes,1 do
  2484.         outframes[i] = nil
  2485.     end
  2486. end
  2487. --[[
  2488.     uses lua's table.sort to sort the teams
  2489. --]]
  2490. function TeamSortFunc(a,b)
  2491.     if a['TeamScore'] == b['TeamScore'] then
  2492.         return a['ID'] < b['ID']
  2493.     end
  2494.     if not a['TeamScore'] then return false end
  2495.     if not b['TeamScore'] then return true end
  2496.     return a['TeamScore'] < b['TeamScore']
  2497.  
  2498. end
  2499. --[[
  2500.     consider adding lock with wait for performance
  2501.     sorts each of the team's player lists induvidually, adds up the team scores.
  2502.     @Args:
  2503.     tentries        table of team entries  
  2504. --]]
  2505. function SortTeams(tentries)
  2506.    
  2507.     for i,val in ipairs(tentries) do
  2508.  
  2509.         table.sort(val['MyPlayers'],PlayerSortFunction)
  2510.         AddTeamScores(val)
  2511.     end
  2512.     table.sort(tentries,TeamSortFunc)
  2513. end
  2514. --[[
  2515.     base update for team mode, adds up the scores of all teams, sorts them,
  2516.     then unrolls them into middleframes
  2517. --]]
  2518. function TeamListModeUpdate()
  2519.     RecreateScoreColumns(PlayerFrames)
  2520.     SortTeams(TeamFrames)
  2521.     if NeutralTeam then
  2522.         AddTeamScores(NeutralTeam)
  2523.         --RecreateScoreColumns(NeutralTeam['MyPlayers'])
  2524.     end
  2525.     UnrollTeams(TeamFrames,MiddleFrames)
  2526. end
  2527. --[[
  2528.     adds up all the score of this team's players to form the team score
  2529.     @Args:
  2530.     team        team entry to sum the scores of
  2531. --]]
  2532. function AddTeamScores(team)
  2533.    
  2534.     for j = 1, #ScoreNames,1 do
  2535.         local i = ScoreNames[j]
  2536.         local tscore = 0
  2537.         for _,j in ipairs(team['MyPlayers']) do
  2538.             local tval = j['Player']:FindFirstChild('leaderstats') and j['Player'].leaderstats:FindFirstChild(i['Name'])
  2539.             if tval and not tval:IsA('StringValue') then
  2540.                 tscore = tscore + GetScoreValue((j['Player'].leaderstats)[i['Name'] ])
  2541.             end
  2542.         end
  2543.         if team['Frame']:FindFirstChild(i['Name']) then
  2544.             --team['Frame'][i['Name'] ].Size = UDim2.new(1 - (ScrollBarFrame.Size.X.Scale * 2),- ((j-1) * SpacingPerStat),1,0)
  2545.             team['Frame'][i['Name'] ].Text = tostring(tscore)
  2546.         end
  2547.     end
  2548.     UpdateMinimize()
  2549.    
  2550. end
  2551.  
  2552. --[[
  2553.     finds previous team this player was on, and if it exists calls removeplayerfromteam
  2554.     @Args
  2555.     entry   Player entry
  2556. --]]
  2557. function FindRemovePlayerFromTeam(entry)
  2558.     if entry['MyTeam'] then
  2559.         for j,oldEntry in ipairs(entry['MyTeam']['MyPlayers']) do
  2560.             if oldEntry['Player'] == entry['Player'] then
  2561.                 RemovePlayerFromTeam(entry['MyTeam'],j)
  2562.                 return
  2563.             end
  2564.         end
  2565.     elseif NeutralTeam then
  2566.         for j,oldEntry in ipairs(NeutralTeam['MyPlayers']) do
  2567.             if oldEntry['Player'] == entry['Player'] then
  2568.                 RemovePlayerFromTeam(NeutralTeam,j)
  2569.                 return
  2570.             end
  2571.         end
  2572.     end
  2573. end
  2574. --[[
  2575.     removes a single player from a given team (not usually called directly)
  2576.     @Args:
  2577.     teamEntry       team entry to remove player from
  2578.     index           index of player in 'MyPlayers' list to remove
  2579. --]]
  2580. function RemovePlayerFromTeam(teamEntry,index)
  2581.     table.remove(teamEntry['MyPlayers'],index)
  2582.     --if teamEntry['AutoHide'] and #teamEntry['MyPlayers'] == 0 then
  2583.     if teamEntry==NeutralTeam and #teamEntry['MyPlayers']==0 then
  2584.         RemoveNeutralTeam()
  2585.     end
  2586. end
  2587. --[[
  2588.     adds player entry entry to teamentry
  2589.     removes them from any previous team
  2590.     @Args:
  2591.     teamEntry       entry of team to add player to
  2592.     entry           player entry to add to this team
  2593. --]]
  2594. function AddPlayerToTeam(teamEntry,entry)
  2595.     FindRemovePlayerFromTeam(entry)
  2596.     table.insert(teamEntry['MyPlayers'],entry)
  2597.     entry['MyTeam'] = teamEntry
  2598.     if teamEntry['IsHidden'] then
  2599.         teamEntry['Frame'].Parent = ListFrame
  2600.         AddMiddleBGFrame()
  2601.     end
  2602.     teamEntry['IsHidden'] = false
  2603. end
  2604.  
  2605.  
  2606. function SetPlayerToTeam(entry)
  2607.     FindRemovePlayerFromTeam(entry)
  2608.     -- check to see if team exists, if it does add to that team
  2609.     local setToTeam = false
  2610.     for i,tframe in ipairs(TeamFrames) do
  2611.     -- add my entry on the new team
  2612.     if tframe['MyTeam'].TeamColor == entry['Player'].TeamColor then
  2613.             AddPlayerToTeam(tframe,entry)
  2614.             setToTeam = true
  2615.         end
  2616.     end
  2617.     -- if player was set to an invalid team, then set it back to neutral
  2618.     if not setToTeam and #(game.Teams:GetTeams())>0 then
  2619.         debugprint(entry['Player'].Name..'could not find team')
  2620.         entry['MyTeam']=nil
  2621.         if not NeutralTeam then
  2622.             AddNeutralTeam()
  2623.         else AddPlayerToTeam(NeutralTeam,entry) end
  2624.     end
  2625. end
  2626.  
  2627. --[[
  2628.     Note:another big one, consiter breaking up
  2629.     called when any children of player changes
  2630.     handles 'Neutral', teamColor, Name and MembershipType changes
  2631.     @Args
  2632.     entry       Player entry changed
  2633.     property    name of property changed
  2634. --]]
  2635. function PlayerChanged(entry, property)
  2636.     while PlayerChangedLock do
  2637.         debugprint('in playerchanged lock')
  2638.         wait(1/30)
  2639.     end
  2640.     PlayerChangedLock=true
  2641.     if property == 'Neutral' then
  2642.         -- if player changing to neutral
  2643.         if entry['Player'].Neutral and #(game.Teams:GetTeams())>0 then
  2644.             debugprint(entry['Player'].Name..'setting to neutral')
  2645.             FindRemovePlayerFromTeam(entry)
  2646.             entry['MyTeam']=nil
  2647.             if not NeutralTeam then
  2648.                 debugprint(entry['Player'].Name..'creating neutral team')
  2649.                 AddNeutralTeam()
  2650.             else
  2651.                 debugprint(entry['Player'].Name..'adding to neutral team')
  2652.                 AddPlayerToTeam(NeutralTeam,entry)
  2653.             end
  2654.         elseif #(game.Teams:GetTeams())>0 then -- else player switching to a team, or a weird edgecase
  2655.             debugprint(entry['Player'].Name..'has been set non-neutral')
  2656.             SetPlayerToTeam(entry)
  2657.         end
  2658.         BaseUpdate()
  2659.     elseif property == 'TeamColor' and not entry['Player'].Neutral and entry['Player'] ~= entry['MyTeam'] then
  2660.         debugprint(entry['Player'].Name..'setting to new team')
  2661.         SetPlayerToTeam(entry)
  2662.         BaseUpdate()
  2663.     elseif property == 'Name' or property == 'MembershipType' then
  2664.         entry['Frame']:FindFirstChild('BCLabel').Image = getMembershipTypeIcon(entry['Player'].MembershipType,entry['Player'].Name)
  2665.         entry['Frame'].Name = entry['Player'].Name
  2666.         entry['Frame'].TitleFrame.Title.Text = entry['Player'].Name
  2667.         if(entry['Frame'].BCLabel.Image ~= '') then
  2668.             entry['Frame'].TitleFrame.Title.Position=UDim2.new(.01, 30, .1, 0)
  2669.         end
  2670.         if entry['Player'] == LocalPlayer then
  2671.             entry['Frame'].TitleFrame.DropShadow.Text= entry['Player'].Name
  2672.             ChangeHeaderName(entry['Player'].Name)
  2673.         end
  2674.         BaseUpdate()
  2675.     end
  2676.     PlayerChangedLock=false
  2677. end
  2678.  
  2679. function OnFriendshipChanged(player,friendStatus)
  2680.  
  2681.     Delay(.5,function()
  2682.         debugprint('friend status changed for:'..player.Name .." ".. tostring(friendStatus) .. " vs " .. tostring(GetFriendStatus(player)) )
  2683.         for _, entry in ipairs(PlayerFrames) do
  2684.             if entry['Player']==player then
  2685.                 local nicon = getFriendStatusIcon(friendStatus)
  2686.                 if nicon == '' and entry['Frame'].FriendLabel.Image ~= '' then
  2687.                     entry['Frame'].TitleFrame.Title.Position=entry['Frame'].TitleFrame.Title.Position-UDim2.new(0,17,0,0)
  2688.                 elseif nicon ~= '' and entry['Frame'].FriendLabel.Image == '' then
  2689.                     entry['Frame'].TitleFrame.Title.Position=entry['Frame'].TitleFrame.Title.Position+UDim2.new(0,17,0,0)
  2690.                     debugprint('confirmed status:'..player.Name)
  2691.                 end
  2692.                 entry['Frame'].FriendLabel.Image = nicon
  2693.                 return
  2694.             end
  2695.         end
  2696.     end)
  2697. end
  2698.  
  2699. --LocalPlayer.FriendStatusChanged:connect(OnFriendshipChanged)
  2700.  
  2701. --[[
  2702.     adds a neutral team if nessisary
  2703.     Note: a lot of redundant code here, might want to refactor to share a function with insertteamframe
  2704. --]]
  2705. function AddNeutralTeam()
  2706.     if not TEAMS_ENABLED then return end
  2707.     while NeutralTeamLock do debugprint('in neutral team 2 lock') wait() end
  2708.     NeutralTeamLock = true
  2709.    
  2710.     local defaultTeam = Instance.new('Team')
  2711.     defaultTeam.TeamColor = BrickColor.new('White')
  2712.     defaultTeam.Name = 'Neutral'
  2713.     local nentry = {}
  2714.     nentry['MyTeam'] = defaultTeam
  2715.     nentry['MyPlayers'] = {}
  2716.     nentry['Frame'] = MiddleTemplate:Clone()
  2717.     WaitForChild(WaitForChild(nentry['Frame'],'TitleFrame'),'Title').Text = defaultTeam.Name
  2718.     nentry['Frame'].TitleFrame.Position=UDim2.new(nentry['Frame'].TitleFrame.Position.X.Scale,nentry['Frame'].TitleFrame.Position.X.Offset,.1,0)
  2719.     nentry['Frame'].TitleFrame.Size=UDim2.new(nentry['Frame'].TitleFrame.Size.X.Scale,nentry['Frame'].TitleFrame.Size.X.Offset,.8,0)
  2720.     nentry['Frame'].TitleFrame.Title.Font = 'ArialBold'
  2721.     nentry['Frame'].Position = UDim2.new(1,0,((#MiddleFrames) * nentry['Frame'].Size.Y.Scale),0)
  2722.     WaitForChild(nentry['Frame'],'ClickListener').MouseButton1Down:connect(function(nx,ny) StartDrag(nentry,nx,ny) end)
  2723.     nentry['Frame'].ClickListener.BackgroundColor3 = Color3.new(1,1,1)
  2724.     nentry['Frame'].ClickListener.BackgroundTransparency = .7
  2725.     nentry['Frame'].ClickListener.AutoButtonColor=false
  2726.     nentry['AutoHide'] = true
  2727.     nentry['IsHidden'] = true
  2728.     for _,i in pairs(PlayerFrames) do
  2729.         if i['Player'].Neutral or not i['MyTeam'] then
  2730.             AddPlayerToTeam(nentry,i)
  2731.         end
  2732.     end
  2733.     if #nentry['MyPlayers'] > 0 then
  2734.         NeutralTeam = nentry
  2735.         UpdateMinimize()
  2736.         BaseUpdate()
  2737.     end
  2738.     NeutralTeamLock = false
  2739. end
  2740.  
  2741. function RemoveNeutralTeam()
  2742.     while NeutralTeamLock do debugprint('in neutral team lock') wait() end
  2743.     NeutralTeamLock = true
  2744.     NeutralTeam['Frame']:Destroy()
  2745.     NeutralTeam=nil
  2746.     RemoveMiddleBGFrame()
  2747.     NeutralTeamLock = false
  2748. end
  2749.  
  2750. --[[
  2751.    
  2752. --]]
  2753. function TeamScoreChanged(entry,nscore)
  2754.     WaitForChild(entry['Frame'],'PlayerScore').Text = tostring(nscore)
  2755.     entry['TeamScore'] = nscore
  2756. end
  2757. --[[
  2758.     called when child added to a team, used for autohide functionality
  2759.     Note: still has teamscore, consiter removing
  2760. --]]
  2761. function TeamChildAdded(entry,nchild)
  2762.     if nchild.Name == 'AutoHide' then
  2763.         entry['AutoHide'] = true
  2764.     elseif nchild.Name == 'TeamScore' then
  2765.         WaitForChild(entry['Frame'],'PlayerScore').Text = tostring(nchild.Value)
  2766.         entry['TeamScore'] = nchild.Value
  2767.         nchild.Changed:connect(function() TeamScoreChanged(entry,nchild.Value) end)
  2768.     end
  2769. end
  2770. --[[
  2771.     called when child added to a team, used for autohide functionality
  2772.     Note: still has teamscore, consiter removing
  2773. --]]
  2774. function TeamChildRemoved(entry,nchild)
  2775.     if nchild.Name == 'AutoHide' then
  2776.         entry['AutoHide'] = false
  2777.     elseif nchild.Name == 'TeamScore' then
  2778.         WaitForChild(entry['Frame'],'PlayerScore').Text = ""
  2779.         entry['TeamScore'] = nil
  2780.     end
  2781. end
  2782.  
  2783. function TeamChanged(entry, property)
  2784.     if property=='Name' then
  2785.         WaitForChild(WaitForChild(entry['Frame'],'TitleFrame'),'Title').Text = entry['MyTeam'].Name
  2786.        
  2787.     elseif property=='TeamColor' then
  2788.         entry['Frame'].ClickListener.BackgroundColor3 = entry['MyTeam'].TeamColor.Color
  2789.        
  2790.         for _,i in pairs(TeamFrames) do
  2791.             if i['MyTeam'].TeamColor == entry['MyTeam'] then
  2792.                 RemoveTeamFrame(entry['MyTeam'])    --NO DUPLICATE TEAMS!
  2793.             end
  2794.         end
  2795.        
  2796.         entry['MyPlayers']={}
  2797.        
  2798.         for _,i in pairs(PlayerFrames) do
  2799.             SetPlayerToTeam(i)
  2800.         end
  2801.         BaseUpdate()
  2802.     end
  2803. end
  2804.  
  2805. --[[
  2806.     creates team entry and frame for this team, sets up listeners for this team
  2807.     adds any players intended for this team,Creates neutral team if this is the first team added
  2808.     Note:might be best to break this into multiple functions to simplify
  2809.     @Args:
  2810.     nteam   new team object added
  2811. --]]
  2812. function InsertTeamFrame(nteam)
  2813.     if not TEAMS_ENABLED then return end
  2814.     while AddingFrameLock do debugprint('in adding team frame lock') wait(1/30) end
  2815.     AddingFrameLock = true
  2816.     --for _,i in pairs(TeamFrames) do
  2817.     local nentry = {}
  2818.     nentry['MyTeam'] = nteam
  2819.     nentry['MyPlayers'] = {}
  2820.     nentry['Frame'] = MiddleTemplate:Clone()
  2821.     WaitForChild(WaitForChild(nentry['Frame'],'TitleFrame'),'Title').Text = nteam.Name
  2822.     nentry['Frame'].TitleFrame.Title.Font = 'ArialBold'
  2823.     nentry['Frame'].TitleFrame.Title.FontSize = 'Size18'
  2824.     nentry['Frame'].TitleFrame.Position=UDim2.new(nentry['Frame'].TitleFrame.Position.X.Scale,nentry['Frame'].TitleFrame.Position.X.Offset,.1,0)
  2825.     nentry['Frame'].TitleFrame.Size=UDim2.new(nentry['Frame'].TitleFrame.Size.X.Scale,nentry['Frame'].TitleFrame.Size.X.Offset,.8,0)
  2826.     nentry['Frame'].Position = UDim2.new(1,0,((#MiddleFrames) * nentry['Frame'].Size.Y.Scale),0)
  2827.     WaitForChild(nentry['Frame'],'ClickListener').MouseButton1Down:connect(function(nx,ny) StartDrag(nentry,nx,ny) end)
  2828.     nentry['Frame'].ClickListener.BackgroundColor3 = nteam.TeamColor.Color
  2829.     nentry['Frame'].ClickListener.BackgroundTransparency = .7
  2830.     nentry['Frame'].ClickListener.AutoButtonColor=false
  2831.     AddId = AddId + 1
  2832.     nentry['ID'] = AddId
  2833.     nentry['AutoHide'] = false
  2834.     if nteam:FindFirstChild('AutoHide') then
  2835.         nentry['AutoHide'] = true
  2836.     end
  2837.     if nteam:FindFirstChild('TeamScore') then
  2838.         TeamChildAdded(nentry,nteam.TeamScore)
  2839.        
  2840.     end
  2841.    
  2842.     nteam.ChildAdded:connect(function(nchild) TeamChildAdded(nentry,nchild) end)
  2843.     nteam.ChildRemoved:connect(function(nchild) TeamChildRemoved(nentry,nchild) end)
  2844.     nteam.Changed:connect(function(prop) TeamChanged(nentry,prop) end)
  2845.    
  2846.     for _,i in pairs(PlayerFrames) do
  2847.         if not i['Player'].Neutral and i['Player'].TeamColor == nteam.TeamColor then
  2848.             AddPlayerToTeam(nentry,i)
  2849.         end
  2850.     end
  2851.     nentry['IsHidden'] = false
  2852.     if not nentry['AutoHide'] or #nentry['MyPlayers'] > 0 then
  2853.        
  2854.         nentry['Frame'].Parent = ListFrame
  2855.         nentry['Frame']:TweenPosition(UDim2.new(.5,0,((#MiddleFrames) * nentry['Frame'].Size.Y.Scale),0), "Out", "Linear", BASE_TWEEN,true)
  2856.         AddMiddleBGFrame()
  2857.     else
  2858.         nentry['IsHidden'] = true
  2859.         nentry['Frame'].Parent = nil
  2860.     end
  2861.  
  2862.     table.insert(TeamFrames,nentry)
  2863.     UpdateMinimize()
  2864.     BaseUpdate()
  2865.     if #TeamFrames == 1 and not NeutralTeam then
  2866.         AddNeutralTeam()
  2867.     end
  2868.     AddingFrameLock = false
  2869. end
  2870. --[[
  2871.     removes team from team list
  2872.     @Args:
  2873.     nteam       Teamobject to remove
  2874. --]]
  2875. function RemoveTeamFrame(nteam)
  2876.     while AddingFrameLock do debugprint('in removing team frame lock') wait(1/30) end
  2877.     AddingFrameLock = true
  2878.     if IsMinimized.Value then
  2879.     end
  2880.     local myEntry
  2881.     for i,key in ipairs(TeamFrames) do
  2882.         if nteam == key['MyTeam'] then
  2883.             myEntry = key
  2884.             key['Frame']:Destroy()
  2885.             table.remove(TeamFrames,i)
  2886.         end
  2887.     end
  2888.     if #TeamFrames==0 then
  2889.         debugprint('removeteamframe, remove neutral')
  2890.         if NeutralTeam then
  2891.             RemoveNeutralTeam()
  2892.         end
  2893.     end
  2894.     for i,key in ipairs(myEntry['MyPlayers']) do
  2895.         RemovePlayerFromTeam(myEntry,i)
  2896.         PlayerChanged(key, 'TeamColor')
  2897.     end
  2898.     RemoveMiddleBGFrame()
  2899.     BaseUpdate()
  2900.     AddingFrameLock = false
  2901. end
  2902.  
  2903. function TeamAdded(nteam)
  2904.     InsertTeamFrame(nteam)
  2905. end
  2906.  
  2907. function TeamRemoved(nteam)
  2908.     RemoveTeamFrame(nteam)
  2909. end
  2910.  ---------------------------------
  2911. --[[
  2912.     called when ANYTHING changes the state of the playerlist
  2913.     re-sorts everything,assures correct positions of all elements
  2914. --]]
  2915. function BaseUpdate()
  2916.     while BaseUpdateLock do debugprint('in baseupdate lock') wait(1/30) end
  2917.     BaseUpdateLock = true
  2918.     --print ('baseupdate')
  2919.     UpdateStatNames()
  2920.    
  2921.     if #TeamFrames == 0 and not NeutralTeam then
  2922.         PlayerListModeUpdate()
  2923.     else
  2924.         TeamListModeUpdate()
  2925.     end
  2926.     for i,key in ipairs(MiddleFrames) do
  2927.         if key.Parent ~= nil then
  2928.             key:TweenPosition(UDim2.new(.5,0,((#MiddleFrames - (i)) * key.Size.Y.Scale),0), "Out", "Linear", BASE_TWEEN,true)
  2929.         end
  2930.     end
  2931.     if not IsMinimized.Value and #MiddleFrames>DefaultEntriesOnScreen then
  2932.         UpdateScrollPosition()
  2933.     end
  2934.    
  2935.     UpdateMinimize()
  2936.  
  2937.     UpdateScrollBarSize()
  2938.     UpdateScrollPosition()
  2939.  
  2940.     UpdateScrollBarVisibility()
  2941.     --debugprint('EndBaseUpdate')
  2942.     BaseUpdateLock = false
  2943. end
  2944.  
  2945. --[[
  2946.     code for attaching tab key to maximizing player list
  2947. --]]
  2948. --game.GuiService:AddKey("\t")
  2949. local LastTabTime = time()
  2950. Mouse.KeyDown:connect(
  2951. function(key)
  2952.     if key == "\t" then
  2953.         debugprint('caught tab key')
  2954.         local modalCheck, isModal = pcall(function() return game.GuiService.IsModalDialog end)
  2955.         if modalCheck == false or (modalCheck and isModal == false) then
  2956.             if time() - LastTabTime > 0.4 then
  2957.                 LastTabTime = time()
  2958.                 if IsTabified.Value then
  2959.                     if not IsMaximized.Value then
  2960.                         ScreenGui:TweenPosition(UDim2.new(0, 0, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  2961.                         IsMaximized.Value = true
  2962.                     else
  2963.                         ScreenGui:TweenPosition(UDim2.new(NormalBounds.X.Scale, NormalBounds.X.Offset-10, 0,0),'Out','Linear',BASE_TWEEN*1.2,true)
  2964.                         IsMaximized.Value = false
  2965.                         IsMinimized.Value=true
  2966.                     end
  2967.                 else
  2968.                     ToggleMaximize()
  2969.                 end
  2970.                
  2971.             end
  2972.         end
  2973.     end
  2974. end)
  2975.  
  2976.  
  2977. function PlayersChildAdded(tplayer)
  2978.     if tplayer:IsA('Player') then
  2979.         Spawn(function() debugPlayerAdd(tplayer) end)
  2980.     else
  2981.         BlowThisPopsicleStand()
  2982.     end
  2983. end
  2984.  
  2985. function coreGuiChanged(coreGuiType, enabled)
  2986. --  if coreGuiType == Enum.CoreGuiType.All or coreGuiType == Enum.CoreGuiType.PlayerList then
  2987. --      MainFrame.Visible = enabled
  2988. --  end
  2989. end
  2990.  
  2991. function TeamsChildAdded(nteam)
  2992.     if nteam:IsA('Team') then
  2993.         TeamAdded(nteam)
  2994.     else
  2995.         BlowThisPopsicleStand()
  2996.     end
  2997. end
  2998.  
  2999. function TeamsChildRemoved(nteam)
  3000.     if nteam:IsA('Team')  then
  3001.         TeamRemoved(nteam)
  3002.     else
  3003.         BlowThisPopsicleStand()
  3004.     end
  3005. end
  3006.  
  3007.  ----------------------------  
  3008.  -- Hookups and initialization
  3009.  ----------------------------  
  3010. function debugPlayerAdd(p)
  3011.     InsertPlayerFrame(p)
  3012. end
  3013.  
  3014. pcall(function()
  3015.     coreGuiChanged(Enum.CoreGuiType.PlayerList, Game.StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList))
  3016.     Game.StarterGui.CoreGuiChangedSignal:connect(coreGuiChanged)
  3017. end)
  3018.  
  3019. while not game:GetService('Teams') do wait(1/30) debugprint('Waiting For Teams') end
  3020. for _,i in pairs(game.Teams:GetTeams()) do TeamAdded(i) end
  3021. for _,i in pairs(Players:GetPlayers()) do Spawn(function() debugPlayerAdd(i) end) end
  3022.  
  3023. game.Teams.ChildAdded:connect(TeamsChildAdded)
  3024. game.Teams.ChildRemoved:connect(TeamsChildRemoved)
  3025. Players.ChildAdded:connect(PlayersChildAdded)
  3026.  
  3027. InitReportAbuse()
  3028. AreNamesExpanded.Value = true
  3029. BaseUpdate()
  3030.  
  3031.  
  3032.  
  3033. --UGGGLY,find a better way later
  3034. --wait(2)
  3035. IsPersonalServer= not not game.Workspace:FindFirstChild("PSVariable")
  3036.  
  3037.  ----------------------------  
  3038.  -- Running Logic
  3039.  ----------------------------
  3040.  
  3041.  --debug stuffs, will only run for 'newplayerlistisbad'
  3042.  if LocalPlayer.Name == 'newplayerlistisbad' or LocalPlayer.Name == 'imtotallyadmin' then
  3043.     debugFrame.Parent = ScreenGui
  3044.     Spawn(function()
  3045.         while true do
  3046.             local str_players=''
  3047.             for _,i in pairs(game.Players:GetPlayers()) do
  3048.                 str_players= str_players .." " .. i.Name
  3049.             end
  3050.             debugplayers.Text=str_players
  3051.             wait(.5)
  3052.         end
  3053.     end)
  3054.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement