Advertisement
CloneTrooper1019

Untitled

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