Advertisement
IayingDuck

code2

Jun 10th, 2023
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. -- Iaying
  2.  
  3. local DataStoreService = game:GetService("DataStoreService")
  4. local HttpService = game:GetService("HttpService")
  5. local Players = game:GetService("Players")
  6. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  7. local SoundService = game:GetService("SoundService")
  8. local StarterGui = game:GetService("StarterGui")
  9. local TextService = game:GetService("TextService")
  10.  
  11. local Commands = require(script:WaitForChild("Commands", nil))
  12.  
  13. local BanList = DataStoreService:GetDataStore("BanlistNew", "global")
  14. local TimedBanlist = DataStoreService:GetDataStore("TimedBanlist","global")
  15. local PlaceInfoStore = DataStoreService:GetOrderedDataStore("RetrobloxPlaceInfoStore")
  16. local WarnPlayerRemote = ReplicatedStorage.RemoteEvents.WarnPlayer
  17. local AdminNotifyRemote = ReplicatedStorage.RemoteEvents.AdminNotifyPlayer
  18. local ReportCooldown = true
  19.  
  20. local function AddPlayer(player)
  21. local success,info = pcall(function()
  22. return BanList:GetAsync(player.UserId)
  23. end)
  24.  
  25. --loops until it can successfully get data
  26. while not success do
  27. wait()
  28. success,info = pcall(function()
  29. return BanList:GetAsync(player.UserId)
  30. end)
  31. end
  32.  
  33. local Result
  34.  
  35. local Success, Err = pcall(function()
  36. Result = TimedBanlist:GetAsync(player.UserId)
  37. end)
  38.  
  39. while not Success do
  40. Success, Err = pcall(function()
  41. Result = TimedBanlist:GetAsync(player.UserId)
  42. end)
  43. end
  44. if Result then
  45. if Result.Expiry < os.time() then
  46. Success, Err = pcall(function()
  47. TimedBanlist:RemoveAsync(player.UserId)
  48. end)
  49.  
  50. Result = nil
  51. end
  52. end
  53.  
  54.  
  55. if info or Result then
  56. warn(Result,info)
  57.  
  58. --player is banned
  59. if info then
  60. if player:GetRankInGroup(5264310) >= 225 and info ~= "AdminAutoUnban_BYPASS" then
  61. BanList:RemoveAsync(player.UserId)
  62. elseif player:GetRankInGroup(5264310) >= 226 then
  63. BanList:RemoveAsync(player.UserId)
  64. else
  65.  
  66. local BanScreen = script:WaitForChild("Ban"):Clone()
  67. BanScreen.Background.Foreground.ReasonContainer.ModNote.Text = string.format("Moderator Reason: <tag> <b>%s </b></tag>",info)
  68. BanScreen.Parent = player.PlayerGui
  69.  
  70.  
  71. ReplicatedStorage:ClearAllChildren()
  72. StarterGui:ClearAllChildren()
  73. SoundService:ClearAllChildren()
  74. workspace:ClearAllChildren()
  75. --player:Kick("You have been banned from RetroStudio \n Reason: "..info)
  76. end
  77. elseif Result then
  78. if player:GetRankInGroup(5264310) >= 225 then
  79. BanList:RemoveAsync(player.UserId)
  80. else
  81.  
  82. local BanScreen = script:WaitForChild("Ban"):Clone()
  83. BanScreen.Background.Foreground.Reviewed_Text.Visible = true
  84. BanScreen.Background.Foreground.ReasonContainer.ModNote.Text = string.format("Moderator Reason: <tag> <b>%s </b></tag>",Result.Reason)
  85. BanScreen.Background.Foreground.Reviewed_Text.Text = os.date("Reviewed: <tag><b>%x %I:%M %p %Z</b></tag>",Result.TimeOfBan)
  86. if Result.Expiry > (os.time() + 157784760) then
  87. --User's banned for man than 5 years, treat it like a termination
  88. else
  89. BanScreen.Background.Foreground.AccountDeleted_Text.Text = "Account Banned"
  90. BanScreen.Background.Foreground.AccountTerminated_Text.Text = os.date("Your account has been banned. You may re-activate it after <tag><b>%x %I:%M %p %Z. </b></tag>",Result.Expiry)
  91. end
  92.  
  93.  
  94.  
  95.  
  96. BanScreen.Parent = player.PlayerGui
  97. ReplicatedStorage:ClearAllChildren()
  98. StarterGui:ClearAllChildren()
  99. SoundService:ClearAllChildren()
  100. workspace:ClearAllChildren()
  101. end
  102. end
  103.  
  104.  
  105. else
  106. --player is not banned
  107. --CharacterAutoLoads off, meaning GUI doesnt load either.
  108. for _,guiObject in pairs(StarterGui:GetChildren()) do
  109. guiObject:Clone().Parent = player:WaitForChild("PlayerGui")
  110. end
  111. end
  112. end
  113.  
  114. Players.PlayerAdded:Connect(AddPlayer)
  115.  
  116. for _,v in pairs(Players:GetPlayers()) do
  117. AddPlayer(v)
  118. end
  119.  
  120. ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("AdminCommands").OnServerEvent:Connect(function(player,cmd,p1,p2)
  121. AdminNotifyRemote:FireClient(player, "Recieved admin command request, please wait...")
  122. if player:GetRankInGroup(5264310) >= 225 then
  123. local success, data = pcall(function()
  124. return Commands[cmd](player.UserId,p1,p2)
  125. end)
  126.  
  127. if success then
  128. AdminNotifyRemote:FireClient(player, data)
  129. else
  130. AdminNotifyRemote:FireClient(player, "There was an error performing this command")
  131. warn("Error trying admin command.")
  132. end
  133. else
  134. AdminNotifyRemote:FireClient(player, "Invalid permissions")
  135. end
  136. end)
  137.  
  138. -- For admin commands that need to return stuff
  139. ReplicatedStorage.RemoteFunctions.AdminCommands.OnServerInvoke = function(player,command,p1,p2)
  140. if player:GetRankInGroup(5264310) >= 225 then
  141. local success, data = pcall(function()
  142. return Commands[command](player.UserId,p1,p2)
  143. end)
  144.  
  145. if success then
  146. return data
  147. else
  148. warn("Error trying admin command.")
  149. end
  150. end
  151. end
  152.  
  153. ReplicatedStorage.RemoteEvents.PlaceReportRequested.OnServerEvent:Connect(function(player, placeid, reason)
  154. if ReportCooldown then
  155. ReportCooldown = false
  156.  
  157. local reportData = {
  158. ["content"] = "",
  159. ["embeds"] = {{
  160. ["title"] = "**PLACE REPORT**",
  161. ["description"] = "Report sent by "..player.Name.." ("..player.UserId..")",
  162. ["type"] = "rich",
  163. ["color"] = tonumber(0x0088ff),
  164. ["fields"] = {
  165. {
  166. ["name"] = "Reported Place ID:",
  167. ["value"] = placeid,
  168. ["inline"] = false
  169. },
  170. {
  171. ["name"] = "Reason:",
  172. ["value"] = reason,
  173. ["inline"] = false
  174. }
  175. }
  176. }}
  177. }
  178. reportData = HttpService:JSONEncode(reportData)
  179. HttpService:PostAsync("https://discordapp.com/api/webhooks/776649513645375499/dzhmt0ei4xFlXV3VUSJ775xxphi0mVj4MtUuqwbMMqL4lzvtW0G__oPDnOihZ8WZBa4z", reportData)
  180.  
  181. wait(10)
  182.  
  183. ReportCooldown = true
  184. else
  185. WarnPlayerRemote:FireClient(player, "Sending reports too fast, please wait a few seconds and try again.")
  186. end
  187. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement