jeeras

Sync Admin Plate of Fate Script

Jun 19th, 2020
7,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.09 KB | None | 0 0
  1. --[[
  2. WELCOME!
  3.  
  4. Current commands:
  5.  
  6. :size (all, others, me, playerName) amount (10, 20, -10, 20, etc)
  7. Examples:
  8. :size all 20
  9. :size others -10
  10. :size me 100
  11. :size noob123 -30
  12.  
  13. :potato (all, others, me, playerName)
  14. Examples:
  15. :potato all
  16. :potato others
  17. :potato me
  18. :potato noob123
  19.  
  20. :explode (all, others, me, playerName)
  21. Examples:
  22. :explode all
  23. :explode others
  24. :explode me
  25. :explode noob123
  26.  
  27. :admin (all, playerName)
  28. Examples:
  29. :admin all
  30. :admin noob123
  31.  
  32. :unadmin (all, playerName)
  33. ! This command only works on the person running the script
  34. Examples:
  35. :unadmin all
  36. :unadmin noob123
  37.  
  38. :win (me, playerName)
  39. Examples:
  40. :win me
  41. :win noob123
  42.  
  43. :sound (me) (id)
  44. Examples:
  45. :sound me 111111
  46.  
  47. :decal (me) (id)
  48. Examples:
  49. :decal me 111111
  50. ]]--
  51.  
  52. local players = game:GetService('Players')
  53. local localPlr = players.LocalPlayer
  54. local char = localPlr.Character or localPlr.CharacterAdded:Wait()
  55. local utils = {}
  56. local admins = { localPlr }
  57. local prefix = ':'
  58. local remoteKey = "D=9Vb7aMuZt!8aMH"
  59.  
  60. local events = {
  61.     changePlateSize = game:GetService("Workspace").RemoteEvents:FindFirstChild("ChangePlateSize"),
  62.     potatoEvent = game:GetService("Workspace").RemoteEvents:FindFirstChild("PotatoEvent"),
  63.     placeMineEvent = game:GetService("Workspace").RemoteEvents:FindFirstChild("PlaceMineEvent"),
  64.     placePlateEvent = game:GetService("Workspace").RemoteEvents:FindFirstChild("PlacePlateEvent"),
  65.     addDecalEvent = game:GetService("Workspace").RemoteEvents:FindFirstChild("AddDecal"),
  66.     addSoundEvent = game:GetService("Workspace").RemoteEvents:FindFirstChild("AddSound")
  67. }
  68.  
  69. local function sizeCmd(cmd, args, player)
  70.     if not args then return end
  71.  
  72.     local victim = tostring(args[1])
  73.     local size = tonumber(args[2])
  74.  
  75.     if not victim or not size then return end
  76.  
  77.     if victim == 'all' then
  78.         for i, v in pairs(players:GetPlayers()) do
  79.             if v.gamestats.Plate.Value then
  80.                 events.changePlateSize:FireServer(v.gamestats.Plate.Value, size, remoteKey)
  81.             end
  82.         end
  83.     elseif victim == 'others' then
  84.         for i, v in pairs(players:GetPlayers()) do
  85.             if v.gamestats.Plate.Value and v ~= player then
  86.                 events.changePlateSize:FireServer(v.gamestats.Plate.Value, size, remoteKey)
  87.             end
  88.         end
  89.     elseif victim == 'me' then
  90.         if localPlr.gamestats.Plate.Value then
  91.             events.changePlateSize:FireServer(localPlr.gamestats.Plate.Value, size, remoteKey)
  92.         end
  93.     else
  94.         local victimPlr = utils.findPlayer(victim)
  95.  
  96.         if not victimPlr then return end
  97.  
  98.         if victimPlr.gamestats.Plate.Value then
  99.             events.changePlateSize:FireServer(victimPlr.gamestats.Plate.Value, size, remoteKey)
  100.         end
  101.     end
  102. end
  103.  
  104. local function potatoCmd(cmd, args, player)
  105.     if not args then return end
  106.  
  107.     local victimName = args[1]
  108.  
  109.     if not victimName then return end
  110.  
  111.     if victimName == 'all' then
  112.         for i, v in pairs(players:GetPlayers()) do
  113.             events.potatoEvent:FireServer(v.Name, remoteKey)
  114.         end
  115.     elseif victimName == 'others' then
  116.         for i, v in pairs(players:GetPlayers()) do
  117.             if v ~= player then
  118.                 events.potatoEvent:FireServer(v.Name, remoteKey)
  119.             end
  120.         end
  121.     elseif victimName == 'me' then
  122.         events.potatoEvent:FireServer(player.Name, remoteKey)
  123.     else
  124.         local victimPlr = utils.findPlayer(victimName)
  125.  
  126.         if not victimPlr then return end
  127.  
  128.         events.potatoEvent:FireServer(victimPlr.Name, remoteKey)
  129.     end
  130. end
  131.  
  132. local function explodeCmd(cmd, args, player)
  133.     if not args then return end
  134.  
  135.     local victimName = args[1]
  136.  
  137.     if not victimName then return end
  138.  
  139.     if victimName == 'all' then
  140.         for i, v in pairs(players:GetPlayers()) do
  141.             local humPos = v.Character.HumanoidRootPart.Position
  142.  
  143.             if humPos then
  144.                 events.placeMineEvent:FireServer(humPos, remoteKey)
  145.             end
  146.         end
  147.     elseif victimName == 'others' then
  148.         for i, v in pairs(players:GetPlayers()) do
  149.             if v ~= player then
  150.                 local humPos = v.Character.HumanoidRootPart.Position
  151.  
  152.                 if humPos then
  153.                     events.placeMineEvent:FireServer(humPos, remoteKey)
  154.                 end
  155.             end
  156.         end
  157.     elseif victimName == 'me' then
  158.         local humPos = player.Character.HumanoidRootPart.Position
  159.  
  160.         if humPos then
  161.             events.placeMineEvent:FireServer(humPos, remoteKey)
  162.         end
  163.     else
  164.         local victimPlr = utils.findPlayer(victimName)
  165.  
  166.         if not victimPlr then return end
  167.  
  168.         local victimHumPos = victimPlr.Character.HumanoidRootPart.Position
  169.  
  170.         if victimHumPos then
  171.             events.placeMineEvent:FireServer(victimHumPos, remoteKey)
  172.         end
  173.     end
  174. end
  175.  
  176. local function winCmd(cmd, args, player)
  177.     if not args then return end
  178.  
  179.     local plrName = args[1]
  180.  
  181.     if not plrName then return end
  182.  
  183.     if plrName == 'me' then
  184.         for i, v in pairs(players:GetPlayers()) do
  185.             if v ~= player and v.gamestats.Plate.Value then
  186.                 local humPos = v.Character.HumanoidRootPart.Position
  187.  
  188.                 for _ = 1, 3, 1 do
  189.                     events.potatoEvent:FireServer(v.Name, remoteKey)
  190.                     events.placeMineEvent:FireServer(humPos, remoteKey)
  191.                 end
  192.             end
  193.         end
  194.     else
  195.         local plr = utils.findPlayer(plrName)
  196.  
  197.         if not plr then return end
  198.  
  199.         for i, v in pairs(players:GetPlayers()) do
  200.             if v ~= player and v.gamestats.Plate.Value then
  201.                 local humPos = v.Character.HumanoidRootPart.Position
  202.  
  203.                 for _ = 1, 3, 1 do
  204.                     events.potatoEvent:FireServer(v.Name, remoteKey)
  205.                     events.placeMineEvent:FireServer(humPos, remoteKey)
  206.                 end
  207.             end
  208.         end
  209.     end
  210. end
  211.  
  212. local function soundCmd(cmd, args, player)
  213.     if not args then return end
  214.  
  215.     local plrPlateName = tostring(args[1])
  216.     local soundId = tonumber(args[2])
  217.  
  218.     if not plrPlateName or not soundId then return end
  219.  
  220.     if plrPlateName == 'all' then
  221.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  222.             events.addSoundEvent:FireServer('rbxassetid://'..soundId, v, remoteKey)
  223.         end
  224.     elseif plrPlateName == 'others' then
  225.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  226.             if v ~= player then
  227.                 events.addSoundEvent:FireServer('rbxassetid://'..soundId, v, remoteKey)
  228.             end
  229.         end
  230.     elseif plrPlateName == 'me' then
  231.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  232.             if v.Owner.Value == player.Name then
  233.                 events.addSoundEvent:FireServer('rbxassetid://'..soundId, v, remoteKey)
  234.             end
  235.         end
  236.     else
  237.         local plr = utils.findPlayer(plrPlateName)
  238.  
  239.         if not plr then return end
  240.  
  241.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  242.             if v.Owner.Value == plr.Name then
  243.                 events.addSoundEvent:FireServer('rbxassetid://'..soundId, v, remoteKey)
  244.             end
  245.         end
  246.     end
  247. end
  248.  
  249. local function decalCmd(cmd, args, player)
  250.     if not args then return end
  251.  
  252.     local plrPlateName = tostring(args[1])
  253.     local decalId = tonumber(args[2])
  254.  
  255.     if not plrPlateName and not decalId then return end
  256.  
  257.     if plrPlateName == 'all' then
  258.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  259.             events.addDecalEvent:FireServer(decalId, v, remoteKey)
  260.         end
  261.     elseif plrPlateName == 'others' then
  262.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  263.             if v ~= player then
  264.                 events.addDecalEvent:FireServer(decalId, v, remoteKey)
  265.             end
  266.         end
  267.     elseif plrPlateName == 'me' then
  268.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  269.             if v.Owner.Value == player.Name then
  270.                 events.addDecalEvent:FireServer(decalId, v, remoteKey)
  271.             end
  272.         end
  273.     else
  274.         local plr = utils.findPlayer(plrPlateName)
  275.  
  276.         if not plr then return end
  277.  
  278.         for i, v in pairs(game.Workspace.Plates:GetChildren()) do
  279.             if v.Owner.Value == plr.Name then
  280.                 events.addDecalEvent:FireServer(decalId, v, remoteKey)
  281.             end
  282.         end
  283.     end
  284. end
  285.  
  286. local function adminCmd(cmd, args, player)
  287.     if not args then return end
  288.  
  289.     local adminName = args[1]
  290.  
  291.     if not adminName then return end
  292.  
  293.     if adminName == 'all' then
  294.         for i, v in pairs(players:GetPlayers()) do
  295.             utils.addAdmin(v)
  296.         end
  297.     else
  298.         local adminPlr = utils.findPlayer(adminName)
  299.  
  300.         if not adminPlr then return end
  301.  
  302.         utils.addAdmin(adminPlr)
  303.     end
  304. end
  305.  
  306. local function unadminCmd(cmd, args, player)
  307.     if not args then return end
  308.  
  309.     local plrName = args[1]
  310.  
  311.     if not plrName then return end
  312.  
  313.     if plrName == 'all' then
  314.         for i, v in pairs(players:GetPlayers()) do
  315.             if v ~= player then utils.removeAdmin(v) end
  316.         end
  317.     else
  318.         local plr = utils.findPlayer(plrName)
  319.  
  320.         if not plr or plr == localPlr then return end
  321.  
  322.         utils.removeAdmin(plr)
  323.     end
  324. end
  325.  
  326. local cmds = {
  327.     ['size'] = sizeCmd,
  328.     ['potato'] = potatoCmd,
  329.     ['explode'] = explodeCmd,
  330.     ['win'] = winCmd,
  331.     ['sound'] = soundCmd,
  332.     ['decal'] = decalCmd,
  333.     ['admin'] = adminCmd,
  334.     ['unadmin'] = unadminCmd
  335. }
  336.  
  337. --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
  338.  
  339. utils.hasAdmin = function (player)
  340.     for i, v in pairs(admins) do
  341.         if v.Name == player.Name then return true end
  342.     end
  343.  
  344.     return false
  345. end
  346.  
  347. utils.matchCmd = function (msg)
  348.     for i, v in pairs(cmds) do
  349.         if msg:match(i) and msg:match(prefix) then return i end
  350.     end
  351.  
  352.     return nil
  353. end
  354.  
  355. utils.addAdmin = function (player)
  356.     if utils.hasAdmin(player) then return end
  357.  
  358.     table.insert(admins, player)
  359. end
  360.  
  361. utils.removeAdmin = function (player)
  362.     if not utils.hasAdmin(player) then return end
  363.  
  364.     for i, v in pairs(admins) do
  365.         if v.Name == player.Name then table.remove(admins, i) end
  366.     end
  367. end
  368.  
  369. utils.parseArgs = function (msg)
  370.     local args = {}
  371.  
  372.     for word in string.gmatch(msg, "[^%s]+") do
  373.         table.insert(args, word)
  374.     end
  375.  
  376.     table.remove(args, 1) -- remove the command from the message, so you get the args
  377.  
  378.     return args
  379. end
  380.  
  381. utils.findPlayer = function (playerName)
  382.     for i, v in pairs(players:GetPlayers()) do
  383.         if v.Name == playerName then return v end
  384.     end
  385.  
  386.     return nil
  387. end
  388.  
  389. --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
  390.  
  391. local function onPlayerChatted(message, player)
  392.     if not utils.hasAdmin(player) then return end
  393.  
  394.     local cmdName = utils.matchCmd(message)
  395.  
  396.     if not cmdName then return end
  397.  
  398.     if cmdName == 'unadmin' and player ~= localPlr then return end
  399.  
  400.     local cmd = cmds[cmdName]
  401.     local args = utils.parseArgs(message)
  402.  
  403.     cmd(message, args, player)
  404. end
  405.  
  406. local function onPlayerJoin(player)
  407.     player.Chatted:Connect(function(message)
  408.         onPlayerChatted(message, player)
  409.     end)
  410. end
  411.  
  412. for _, player in pairs(players:GetPlayers()) do
  413.     player.Chatted:Connect(function(message)
  414.         onPlayerChatted(message, player)
  415.     end)
  416. end
  417.  
  418. players.PlayerAdded:Connect(onPlayerJoin)
Advertisement
Add Comment
Please, Sign In to add comment