Advertisement
Ak8D

new playerlist

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