iiFlamez

Untitled

Mar 19th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.41 KB | None | 0 0
  1. wait(3)
  2. local connects = {}
  3. local gui = script.Parent
  4. function selection_sort(tab)
  5. --Go through every position in the table
  6. for i = 1, #tab do
  7. --start minimum at current position
  8. local minimum = i
  9. --Go through the remaining elements that need to be sorted
  10. for t = i + 1, #tab do
  11. --compare current element to minimum
  12. if tab[t][2] < tab[minimum][2] then
  13. --t is the new minimum
  14. minimum = t
  15. end
  16. end
  17. --switch minimum with current position
  18. tab[i], tab[minimum] = tab[minimum], tab[i]
  19. end
  20. end
  21.  
  22. function sortbounties(guis)
  23. local pirates = guis:GetChildren()
  24. local organize = {}
  25. local originals = {}
  26. for a,b in pairs(pirates) do
  27. if b:IsA("Frame") then
  28. organize[#organize+1] = {b,b.BountyValue.Value}
  29. end
  30. end
  31. selection_sort(organize)
  32. for i=1,#organize do
  33. local b = organize[#organize-(i-1)]
  34. local tag = b[1]
  35. tag.Position = UDim2.new(1, -250, 0, 20*i)
  36. end
  37. end
  38. --
  39. local players = {}
  40. for a,b in pairs(game.Players:GetPlayers()) do
  41. players[#players+1] = b
  42. end
  43. function Color4(r,g,b)
  44. r = r/255
  45. g = g/255
  46. b = b/255
  47. return Color3.new(r,g,b)
  48. end
  49.  
  50.  
  51. function teamupdate()
  52. local change = false
  53. for a,b in pairs(game.Players:GetPlayers()) do
  54. local tag = gui:findFirstChild(b.Name,true)
  55. if tag then
  56. local play = b
  57. local targparent = gui.Civilian
  58.  
  59. if play.Team == game.Teams.Marine or play.TeamColor == game.Teams.Marine.TeamColor then
  60. targparent = gui.Marines
  61. elseif play.Team == game.Teams.Pirate or play.TeamColor == game.Teams.Pirate.TeamColor then
  62. targparent = gui.Pirates
  63. elseif play.Team == game.Teams.Civilian or play.TeamColor == game.Teams.Civilian.TeamColor then
  64. targparent = gui.Civilian
  65. elseif play.Team == game.Teams.Revolutionary or play.TeamColor == game.Teams.Revolutionary.TeamColor then
  66. targparent = gui.Revolutionary
  67. end
  68. if tag.Parent ~= targparent then
  69. tag.Parent = targparent
  70. change = true
  71. end
  72. end
  73. end
  74. if change then
  75. updateguisize()
  76. for a,b in pairs(gui:GetChildren()) do
  77. sortbounties(b)
  78. end
  79. end
  80. end
  81.  
  82. function updateguisize()
  83. --number of players/team changes
  84. local pirates = gui.Pirates:GetChildren()
  85. gui.Marines.Position = UDim2.new(1,-250,0,25 + (20*(#pirates-2)))
  86. local marines = gui.Marines:GetChildren()
  87. gui.Revolutionary.Position = UDim2.new(1,-250,0,45 + (20*((#pirates+#marines-4))))
  88. local rebels = gui.Revolutionary:GetChildren()
  89. gui.Civilian.Position = UDim2.new(1,-250,0,65 + (20*((#pirates+#marines+#rebels-6))))
  90. local civs = gui.Civilian:GetChildren()
  91. end
  92.  
  93. function updatetag(tag)
  94. local play = game.Players:FindFirstChild(tag.Name)
  95. if play:WaitForChild("Crew").Value ~= "" then
  96. local info = game:GetService("GroupService"):GetGroupInfoAsync(play.Crew.Value)
  97. tag.ImageButton.Image = info.EmblemUrl
  98. tag.CrewName.Text = info.Name
  99. tag.CrewRank.Text = play:GetRoleInGroup(info.Id)
  100. tag.ImageButton.Visible = true
  101. else
  102. tag.ImageButton.Visible = false
  103. end
  104. tag.Bounty.TextLabel.Text = play.leaderstats.Bounty.Value
  105. tag.BountyValue.Value = string.gsub(play.leaderstats.Bounty.Value,",","")
  106. tag.TextLabel.Text = play.Name
  107. end
  108. local connections = {}
  109. local tags = {}
  110. function createplayer(play,b)
  111. local tag = script:WaitForChild("Player"):clone()
  112. tag.Name = play.Name
  113. tag.Bounty.TextLabel.Text = play:WaitForChild("leaderstats").Bounty.Value
  114. tag.BountyValue.Value = string.gsub(play.leaderstats.Bounty.Value,",","")
  115. tag.TextLabel.Text = play.Name
  116. if play:WaitForChild("Crew").Value ~= "" then
  117. local info = game:GetService("GroupService"):GetGroupInfoAsync(play.Crew.Value)
  118. tag.ImageButton.Image = info.EmblemUrl
  119. tag.CrewName.Text = info.Name
  120. tag.CrewRank.Text = play:GetRoleInGroup(info.Id)
  121. tag.TextLabel.MouseEnter:connect(function()
  122. tag.CrewRank.Visible = true
  123. end)
  124. tag.TextLabel.MouseLeave:connect(function()
  125. tag.CrewRank.Visible = false
  126. end)
  127. tag.ImageButton.MouseEnter:connect(function()
  128. tag.CrewName.Visible = true
  129. end)
  130. tag.ImageButton.MouseLeave:connect(function()
  131. tag.CrewName.Visible = false
  132. end)
  133. else
  134. tag.ImageButton.Visible = false
  135. end
  136. play.leaderstats.Bounty.Changed:connect(function()
  137. updatetag(tag)
  138. sortbounties(tag.Parent)
  139. end)
  140. play.Crew.Changed:connect(function()
  141. updatetag(tag)
  142. end)
  143. play.Changed:connect(function(chngd)
  144. --probably team changed
  145. if chngd == "TeamColor" or chngd == "Team" then
  146. teamupdate()
  147. end
  148. end)
  149. local rank = play:GetRankInGroup(3159910)
  150. if rank == 235 then
  151. --YONKO SPOTTED OMG :O
  152. tag.TextLabel.TextColor3 = Color4(255,58,58)
  153. elseif rank == 200 or rank == 255 then -- admiral
  154. tag.TextLabel.TextColor3 = Color4(102,168,255)
  155. elseif rank == 199 or rank == 190 then -- vice admiral
  156. tag.TextLabel.TextColor3 = Color4(84,238,255)
  157. elseif rank == 200 or rank == 160 then -- HR MARINE
  158. tag.TextLabel.TextColor3 = Color4(125,203,255)
  159. elseif rank == 220 then -- fleet admiral
  160. tag.TextLabel.TextColor3 = Color4(0,59,255)
  161. elseif rank == 225 then -- notable pirate
  162. tag.TextLabel.TextColor3 = Color4(255,252,140)
  163. elseif rank == 226 then -- Super Nova
  164. tag.TextLabel.TextColor3 = Color4(255,129,79)
  165. elseif rank == 230 then -- Shichi
  166. tag.TextLabel.TextColor3 = Color4(212,0,177)
  167. end
  168. if play.Team == game.Teams.Marine or play.TeamColor == game.Teams.Marine.TeamColor then
  169. tag.Parent = gui.Marines
  170. elseif play.Team == game.Teams.Pirate or play.TeamColor == game.Teams.Pirate.TeamColor then
  171. tag.Parent = gui.Pirates
  172. elseif play.Team == game.Teams.Revolutionary or play.TeamColor == game.Teams.Revolutionary.TeamColor then
  173. tag.Parent = gui.Revolutionary
  174. else
  175. tag.Parent = gui.Civilian
  176. end
  177. b = b or false
  178. if b == false then
  179. updateguisize()
  180. sortbounties(tag.Parent)
  181. end
  182. end
  183. for a,b in pairs(players) do
  184. createplayer(b,true)
  185. end
  186. updateguisize()
  187. for a,b in pairs(gui:GetChildren()) do
  188. sortbounties(b)
  189. end
  190. game.Players.PlayerAdded:connect(function(play)
  191. wait(1)
  192. if play then
  193. createplayer(play)
  194. end
  195. end)
  196. game.Players.PlayerRemoving:connect(function(play)
  197. if gui:findFirstChild(play.Name,true) then
  198. local tag = gui:findFirstChild(play.Name,true)
  199. local tagparent = tag.Parent
  200. tag:Destroy()
  201. updateguisize() --update bounty sizes
  202. sortbounties(tagparent) -- sort their bounties again SHO NAN DA
  203. end
  204. end)
Add Comment
Please, Sign In to add comment