Advertisement
1x_Gacha

Prison Command | Server

Aug 16th, 2020 (edited)
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.81 KB | None | 0 0
  1. local log = {}
  2.  
  3. local cd = {}
  4.  
  5. local i = 1
  6.  
  7. local testing = false
  8. local cooldown = 1
  9.  
  10. local ids = {}
  11. local ids2 = {}
  12. local bypass = {}
  13. local tester = {}
  14. local folder = script.Resources
  15. local storage = game:GetService('ReplicatedStorage')
  16. local arrestFolder = storage:FindFirstChild('ArrestFolder')
  17.  
  18.  
  19.  
  20.  
  21. local function checkPlayer(player)
  22.     local p = game.Players:FindFirstChild(player) ----
  23.     for _,v in pairs(ids)do
  24.         if p:IsInGroup(v) then
  25.             if p:GetRankInGroup(v) >= 3 then
  26.                 return true
  27.             end
  28.         else
  29.             for _,d in pairs(bypass)do
  30.                 if d == p.UserId then
  31.                     return true
  32.                 end
  33.             end
  34.         end
  35.     end
  36.     for _,v in pairs(ids2)do
  37.         if p:IsInGroup(v)then
  38.             if p:GetRankInGroup(v) >= 14 then
  39.                 return true
  40.             end
  41.         end
  42.     end
  43.     if testing then
  44.         for _,v in pairs(tester)do
  45.             if v == p.UserId then
  46.                 return true
  47.             end
  48.         end
  49.     end
  50. end
  51.  
  52. local function findPrisonedPlayer(target)
  53.     for _,v in pairs(arrestFolder:GetChildren())do
  54.        
  55.         if string.match(v.Name:sub(1, target:len()):lower(), (target:lower()))then
  56.             print('Unjailing Player: '..v.Name)
  57.             return v.Name
  58.         end
  59.     end
  60. end
  61.  
  62. local function findPlayer(target)
  63.     for _, players in pairs(game.Players:GetChildren()) do
  64.        
  65.     if string.match(players.Name:sub(1, target:len()):lower(), (target:lower())) then
  66.             print('Found Player: '..players.Name)
  67.             return players 
  68.         end
  69.     end
  70. end
  71.  
  72. local function checkCD(sender)
  73.     for i,v in pairs(cd)do
  74.         for a,b in pairs(v)do
  75.         if b == sender then
  76.             return true
  77.             end
  78.         end
  79.     end
  80. end
  81.  
  82. local function unjailPlayer(player)
  83.     local tag = arrestFolder:FindFirstChild(player)
  84.    
  85.     tag:Destroy()
  86. end
  87.  
  88. local function jailPlayer(player, duration, reason, sender, team)
  89.     if arrestFolder:FindFirstChild(player) then return end
  90.     if checkPlayer(player) then return end -----
  91.     if checkCD(sender) then return end
  92.     local tag = folder.PName:Clone()
  93.     log[#log+1] = {
  94.                 ['Player'] = player,   
  95.                 ['Duration'] = duration,
  96.                 ['Reason'] = reason,
  97.                 ['Sender'] = sender,
  98.                 ['Team'] = team
  99.     }
  100.    
  101.     cd[#cd+1] = {
  102.             ['Player'] = sender,
  103.             ['CoolDown'] = cooldown,
  104.         }
  105.    
  106.     tag.Name = player
  107.     tag.Value = player
  108.     tag.Reason.Value = reason
  109.     tag.Time.Value = duration*60
  110.     tag.Sentence.Value = duration*60
  111.     tag.Parent = arrestFolder
  112.     tag.Team.Value = team
  113.     tag.Sender.Value = sender
  114.        
  115.     game.Players[player].Team = game.Teams.Prison
  116.     game.Players[player]:LoadCharacter()
  117.    
  118.     for i,v in pairs(log)do
  119.         for c,d in pairs(log[i])do
  120.            
  121.         end
  122.     end
  123. end
  124.  
  125. local cmd1 = ';jail '
  126. local cmd2 = ';unjail '
  127. local cmd3 = ';plog'
  128.  
  129. local function checkCommand(msg, sender)
  130.     if msg:sub(1, cmd1:len()):lower()== cmd1:lower() then
  131.     local mainstring = msg:sub(cmd1:len() + 1)
  132.     local split = string.split(mainstring, ', ')
  133.     if split[2] == ' ' or nil then return end
  134.     local duration = split[2]
  135.     local playername = split[1]
  136.     local reason = split[3]
  137.     local findplayer = findPlayer(playername)
  138.     local player = game.Players:FindFirstChild(findplayer.Name)
  139.     local team = game.Players:FindFirstChild(findplayer.Name).Team.Name
  140.         jailPlayer(player.Name, duration, reason, sender.Name, team) -----
  141.     end
  142.    
  143.     if msg:sub(1, cmd2:len()):lower() == cmd2:lower() then
  144.         local playername = msg:sub(cmd2:len() + 1)
  145.         local playertag = findPrisonedPlayer(playername)
  146.         unjailPlayer(playertag)
  147.     end
  148.    
  149.     if msg:sub(1, cmd3:len()):lower()== cmd3:lower() then
  150.        
  151.     end
  152. end
  153.  
  154. local function inGame(player)
  155.     if game.Players:FindFirstChild(player)then
  156.         return true
  157.     end
  158. end
  159.  
  160. local function inPrison(player)
  161.     if inGame(player) then
  162.     local prisonarea = game.Workspace.PrisonAreas.PrisonArea
  163.     local char = game.Workspace:FindFirstChild(player)
  164.     if (char.HumanoidRootPart.Position - prisonarea.Position).Magnitude < 55 then
  165.         return true
  166.         end
  167.     end
  168. end
  169.  
  170. local ui = script.Arrest
  171.  
  172. game.Players.PlayerAdded:Connect(function(player)
  173.     repeat wait()
  174.        
  175.     until player.Character
  176.    
  177.     if checkPlayer(player.Name) then
  178.         local clone = ui:Clone()
  179.         clone.Parent = player.PlayerGui
  180.         player.Chatted:Connect(function(msg)
  181.         checkCommand(msg, player) ----
  182.         end)
  183.     end
  184.    
  185.     if arrestFolder:FindFirstChild(player.Name) then
  186.         player.Team = game.Teams.Prison
  187.         player:LoadCharacter()
  188.     end
  189.        
  190. end)
  191.  
  192. spawn(function()
  193. while true do
  194.     wait(1)
  195.     for i,v in pairs(arrestFolder:GetChildren())do
  196.         v.Time.Value = v.Time.Value-1
  197.         if v.Time.Value == 0 then
  198.             unjailPlayer(v.Name)
  199.             v:Destroy()
  200.             end
  201.         end
  202.     end
  203. end)
  204.  
  205. spawn(function()
  206. while true do
  207.     wait(5)
  208.     for i,v in pairs(game.Players:GetChildren())do
  209.         if arrestFolder:FindFirstChild(v.Name)then
  210.             if v.Team == game.Teams.Prison then
  211.             else
  212.                 v.Team = game.Teams.Prison
  213.                 v:LoadCharacter()
  214.             end
  215.         else
  216.             if v.Team == game.Teams.Prison then
  217.                 if v:IsInGroup(5425370)then
  218.                     v.Team = game.Teams.GCR
  219.                 else
  220.                     v.Team = game.Teams.Civilians
  221.                 end
  222.                     v:LoadCharacter()
  223.                 end
  224.             end
  225.         end
  226.     end
  227. end)
  228.  
  229. spawn(function()
  230.     while true do
  231.         wait(1)
  232.         for i,v in pairs(cd)do
  233.             for a,b in pairs(v)do
  234.                 if a == 'CoolDown' then
  235.                     cd[i][a] = b-1 
  236.                     if b == 0 then
  237.                         table.remove(cd, i)
  238.                     end
  239.                 end
  240.             end
  241.         end
  242.     end
  243. end)
  244.  
  245. spawn(function()
  246.     while true do
  247.         wait(2.5)
  248.         for i,v in pairs(arrestFolder:GetChildren())do
  249.             local plyr = v.Name
  250.             if inPrison(v.Name) then
  251.        
  252.             else
  253.                 if inGame(v.Name) then
  254.                     local player = game.Players:FindFirstChild(v.Name)
  255.                     player:LoadCharacter()
  256.                 end
  257.             end
  258.         end
  259.     end
  260. end)
  261.  
  262.  
  263. game.ReplicatedStorage.ArrestFolder.ChildAdded:Connect(function(tag)
  264.     wait(5)
  265.     local ff = false
  266.     for i,v in pairs(log)do
  267.         if tag.Name == log[i]['Player'] then
  268.             if tag.Reason.Value == log[i]['Reason'] then
  269.                 if tag.Sender.Value == log[i]['Sender'] then
  270.                     ff = true
  271.                     warn('True Prison')
  272.                 end
  273.             end
  274.         end
  275.     end
  276.     if ff == false then
  277.         warn('False Prison')
  278.         tag:Destroy()
  279.     end
  280. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement