Advertisement
minimic2002

Roblox Chat --> Ban Script

Nov 26th, 2020
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. ----------------------------------------------------------------------- // DSS Functions
  2. local DataStoreService = game:GetService("DataStoreService")
  3.  
  4. function SetData(Store,Player,Data)
  5. while true do
  6. local S, R = pcall(function()
  7. local NewStore = DataStoreService:GetDataStore(Store)
  8. NewStore:SetAsync(Player,Data)
  9. end)
  10. if S then
  11. print("Set Data")
  12. break
  13. else
  14. print("DSS Error:")
  15. print(R)
  16. wait(2)
  17. end
  18. end
  19.  
  20. end
  21.  
  22. function UpData(Store,Player,Data)
  23. while true do
  24. local S, R = pcall(function()
  25. local NewStore = DataStoreService:GetDataStore(Store)
  26. NewStore:UpdateAsync(Player,Data)
  27. end)
  28. if S then
  29. break
  30. else
  31. print("DSS Error:")
  32. print(R)
  33. wait(2)
  34. end
  35. end
  36.  
  37. end
  38.  
  39. function GetData(Store,Player)
  40. local Result
  41. while true do
  42. local S, R = pcall(function()
  43. local NewStore = DataStoreService:GetDataStore(Store)
  44. Result = NewStore:GetAsync(Player)
  45.  
  46. end)
  47. if S then
  48. return Result
  49. else
  50. print("DSS Error:")
  51. print(R)
  52. wait(2)
  53. end
  54. end
  55.  
  56. end
  57.  
  58. function RemoveData(Store,Player)
  59. while true do
  60. local S, R = pcall(function()
  61. local NewStore = DataStoreService:GetDataStore(Store)
  62. NewStore:RemoveAsync(Player)
  63. end)
  64. if S then
  65. print("Removed Data")
  66. break
  67. else
  68. print("DSS Error:")
  69. print(R)
  70. wait(2)
  71. end
  72. end
  73. end
  74.  
  75. function CheckForExistingData(Store,Player)
  76. local Data = GetData(Store,Player)
  77. if Data == nil then
  78. local Result = false
  79. return Result
  80. else
  81. local Result = true
  82. return Result
  83. end
  84. end
  85.  
  86. function CreateListing(Store,Data)
  87. while true do
  88. local S, R = pcall(function()
  89. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  90. if tonumber(EntryCount) == nil then
  91. EntryCount = 0
  92. end
  93. EntryCount = tostring(tonumber(EntryCount) + 1)
  94. SetData(Store,EntryCount,Data)
  95. SetData(Store .. "EntryCount","EntryCount",EntryCount)
  96.  
  97. end)
  98. if S then
  99. break
  100. else
  101. print("DSS Error:")
  102. print(R)
  103. wait(2)
  104. end
  105. end
  106.  
  107. end
  108.  
  109. function GetListings(Store)
  110. local StoreNames
  111. while true do
  112. local S, R = pcall(function()
  113. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  114. EntryCount = tonumber(EntryCount)
  115. StoreNames = {}
  116. for i = 1, EntryCount do
  117. local Name = tostring(i)
  118. local Check = CheckForExistingData(Store,tostring(i))
  119. if Check == true then
  120. table.insert(StoreNames,Name)
  121. end
  122. end
  123. end)
  124. if S then
  125. return StoreNames
  126. else
  127. print("DSS Error:")
  128. print(R)
  129. wait(2)
  130. end
  131. end
  132.  
  133.  
  134. end
  135.  
  136. function RemoveListing(Store,Number)
  137. SetData(Store,Number,nil)
  138. end
  139.  
  140. function GetEntryCount(Store)
  141. local EntryCount = GetData(Store .. "EntryCount","EntryCount")
  142. EntryCount = tonumber(EntryCount)
  143. return EntryCount
  144. end
  145.  
  146. ----------------------------------------------------------------------- // End Of DSS Functions
  147.  
  148. ----------------------------------------------------------------------- // Time And Date Module
  149. local TimeDateMod = require(script.TimeAndDate)
  150.  
  151. game.Players.PlayerAdded:Connect(function(Player)
  152. ------------------------------------------------------------------- // Perm Ban
  153. if CheckForExistingData("Bans",Player.Name) == true then
  154. local Reason = GetData("Bans",Player.Name)
  155. Player:Kick("You Have Been Permentantly Banned. Reason: " .. Reason)
  156. end
  157. ------------------------------------------------------------------- // Temp Ban
  158. if CheckForExistingData("TempBans",Player.Name) == true then
  159. local EndTime = GetData("TempBans",Player.Name)
  160. local CurrentTime = TimeDateMod.UTCTime() -- {Time,Year,Month,Day,Hour,Minute,Sec}
  161. EndTime = string.split(EndTime,":")
  162.  
  163. local StillBanned
  164. for i = 1,#EndTime do
  165. if CurrentTime[i] > EndTime[i] then
  166. StillBanned = true
  167. end
  168. end
  169. if StillBanned == true then
  170. for i = 2,#EndTime do
  171. EndTime[i] = EndTime[i] - CurrentTime[i]
  172. end
  173. Player:Kick("You Have Been Temp Banned For Another: \n" .. EndTime[2] .. "Years, " ..EndTime[3] .. "Months, " .. EndTime[4] .. "Days, " .. EndTime[5] .. "Hours, " .. EndTime[6] .. "Minutes, " .. EndTime[7] .. "Seconds.")
  174. end
  175. if StillBanned == nil then
  176. RemoveData("TempBans",Player.Name)
  177. end
  178. end
  179. ------------------------------------------------------------------- // Admin Ban Section
  180. if Player.Name == "minimic2002" then
  181. Player.Chatted:Connect(function(Msg)
  182. local Split = string.split(Msg," ")
  183. ----------------------------------------------------------- // Perm Ban
  184. if string.lower(Split[1]) == string.lower(":Ban") then
  185. local Players = game.Players:GetPlayers()
  186. for i = 1,#Players do
  187. if string.sub(1,#string.lower(Split[2])) == string.lower(Split[2]) then
  188. if Split[3] == nil then
  189. SetData("Bans",Players[i].Name,"You Have Been Banned For Life")
  190. else
  191. SetData("Bans",Players[i].Name,Split[3])
  192. end
  193.  
  194. end
  195. end
  196. end
  197. ----------------------------------------------------------- // Temp Ban
  198. if string.lower(Split[1]) == string.lower(":TempBan") then
  199. local Players = game.Players:GetPlayers()
  200. for i = 1,#Players do
  201. if string.sub(1,#string.lower(Split[2])) == string.lower(Split[2]) then
  202. if Split[3] == nil then
  203. local BannedTime = TimeDateMod.UTCTime()
  204. for i = 1,#BannedTime do
  205. if i == 4 then
  206. BannedTime[i] = BannedTime[i] + 1
  207. end
  208. end
  209. SetData("Bans",Players[i].Name,"You Have Been Temp Banned")
  210. Players[i]:Kick("You Have Been Temp Banned")
  211. else
  212. SetData("Bans",Players[i].Name,Split[3])
  213. end
  214.  
  215. end
  216. end
  217. end
  218. -------------------------------------------------------------
  219. end)
  220. end
  221. end)
  222.  
  223.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement