Aquarius_Raverus

Kage_Commands

Oct 18th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.41 KB | None | 0 0
  1. -- Kage Commands
  2.  
  3. local Players = game:GetService("Players")
  4. local HTTPService = game:GetService("HttpService")
  5. local SS = game:GetService("ServerStorage")
  6. local Storage = game:GetService("ReplicatedStorage")
  7.  
  8. local Remotes = Storage:WaitForChild("Kage_Remotes")
  9. local Stats = SS:WaitForChild(".stats")
  10.  
  11. local Url = ''
  12.  
  13. local Whitelisted = {
  14.     [45146698] = 'Hokage',
  15.     [461653567] = 'Kazekage',
  16.     [1737168766] = 'Mizukage',
  17.     [82540849] = 'Raikage',
  18.     [563523142] = 'Tsuchikage',
  19.     [410311110] = 'Otokage',
  20. };
  21.  
  22. local KageToVillage = {
  23.     Hokage = 'Leaf',
  24.     Kazekage = 'Sand',
  25.     Mizukage = 'Mist',
  26.     Raikage = 'Cloud',
  27.     Tsuchikage = 'Stone',
  28.     Otokage = 'Sound', 
  29. };
  30.  
  31. local VillageToNumber = {
  32.     Leaf = 1,
  33.     Cloud = 2,
  34.     Mist = 3,
  35.     Rain = 4,
  36.     Sand = 5,
  37.     Stone = 6,
  38.     Rogue = 7,
  39.     Sound = 8,
  40. };
  41.  
  42. local function adjustRankingPromo(cur)
  43.    
  44.     --0 = academy stud, 1 = genin, 2 = chunin, 3 = jonin, 4 = sepc. jonin
  45.  
  46.     if cur == 'Academy Student' then
  47.         return 'Genin'
  48.     elseif cur == 'Genin' then
  49.         return 'Chunin'
  50.     elseif cur == 'Chunin' then
  51.         return 'Jonin'
  52.     elseif cur == 'Jonin' then
  53.         return 'Spec. Jonin'
  54.     elseif cur == 'Spec. Jonin' then
  55.         return 'Spec. Jonin'
  56.     end
  57. end
  58.  
  59. local function adjustRankingDemo(cur)
  60.     if cur == 'Spec. Jonin' then
  61.         return 'Jonin'
  62.     elseif cur == 'Jonin' then
  63.         return 'Chunin'
  64.     elseif cur == 'Chunin' then
  65.         return 'Genin'
  66.     elseif cur == 'Genin' then
  67.         return 'Academy Student'
  68.     elseif cur == 'Academy Student' then
  69.         return 'Academy Student'
  70.     end
  71. end
  72.  
  73.  
  74. local function unRogue(plr, target)
  75.     local villageTo = KageToVillage[Whitelisted[plr.UserId]]
  76.     local targetStats = Stats:FindFirstChild(target.Name)
  77.    
  78.    
  79.     if villageTo ~= '' then
  80.         if targetStats then
  81.             if targetStats.Village.Value == VillageToNumber[villageTo] then
  82.                 -- already un rogued
  83.                 Remotes.Notif:InvokeClient(plr, 'Notif', {Text = 'This person is already un-rogued.'})
  84.                 return;
  85.             end
  86.            
  87.             warn("UnRogue ".. target.Name..' to '.. villageTo)
  88.             targetStats.Village.Value = VillageToNumber[villageTo]
  89.             Remotes.Notif:InvokeClient(plr, 'Notif', {Text = 'You have successfully un-rogued '.. target.Name.. ' to '.. villageTo})
  90.             Remotes.Notif:InvokeClient(target, 'Notif', {Text = 'You have successfully been un-rogued to '.. villageTo.. ' by the '.. Whitelisted[plr.UserId].. ' '.. plr.Name})
  91.         end
  92.     end
  93. end
  94.  
  95. local function rogue(plr, target)
  96.     local targetStats = Stats:FindFirstChild(target.Name)
  97.    
  98.     if targetStats then
  99.         if targetStats.Village.Value == VillageToNumber['Rogue'] then
  100.             -- notify already rogued
  101.             Remotes.Notif:InvokeClient(plr, 'Notif', {Text = 'This person is already rogue.'})
  102.             return
  103.         end
  104.        
  105.         warn("Rogue ".. target.Name.. " to Rogue Village")
  106.         targetStats.Village.Value = VillageToNumber['Rogue']
  107.        
  108.         Remotes.Notif:InvokeClient(plr, 'Notif', {Text = 'You have successfully rogued '.. target.Name.. ' to Rogue.'})
  109.         Remotes.Notif:InvokeClient(target, 'Notif', {Text = 'You have been successfully rogued by '.. plr.Name..' the '.. Whitelisted[plr.UserId]})
  110.     end
  111. end
  112.  
  113. Players.PlayerAdded:Connect(function(plr)
  114.     plr.Chatted:Connect(function(msg)
  115.         if not Whitelisted[plr.UserId] then
  116.             return;
  117.         end
  118.         msg = msg:split(" ")
  119.        
  120.         local Command = msg[1]
  121.         Command = Command:lower()
  122.        
  123.         local Target = msg[2]
  124.         if not Target then return end
  125.        
  126.         if game.Players:FindFirstChild(Target) then
  127.             Target = game.Players[Target]
  128.         else
  129.             return;
  130.         end
  131.        
  132.         local plrStats = Stats[Target.Name]
  133.        
  134.         local data =
  135.             {
  136.             ["content"] = "",
  137.             ["embeds"] = {{
  138.                 ["title"] = "[KAGE COMMAND LOGGER]",
  139.                 ["description"] = plr.Name.." has used a hokage-only command.",
  140.                 ["type"] = "rich",
  141.                 ["color"] = tonumber(0x00FF00),
  142.                 ["fields"] = {
  143.                     {
  144.                         ["name"] = "Hokage Title",
  145.                         ["value"] = Whitelisted[plr.UserId],
  146.                         ["inline"] = true
  147.                     },
  148.                     {
  149.                         ["name"] = "Command Name",
  150.                         ["value"] = Command,
  151.                         ["inline"] = true
  152.                     },
  153.                     {
  154.                         ["name"] = "Target/Target UserId",
  155.                         ["value"] = Target.Name.. ' | '.. Target.UserId,
  156.                         ["inline"] = true
  157.                     },
  158.                 }
  159.             }}
  160.         };
  161.        
  162.         data = HTTPService:JSONEncode(data)
  163.        
  164.         if Command == '!rogue' then
  165.             rogue(plr, Target)
  166.             HTTPService:PostAsync(Url, data)
  167.             return;
  168.         elseif Command == '!unrogue' then
  169.             unRogue(plr, Target)
  170.             HTTPService:PostAsync(Url, data)
  171.             return;
  172.         elseif Command == '!promote' then
  173.             local new = adjustRankingPromo(plrStats['Title'].Value)
  174.             if new == 'None' then
  175.                 return;
  176.             end
  177.             plrStats['Title'].Value = new
  178.             Target.leaderstats.Rating.Value = new
  179.            
  180.             Remotes.Notif:InvokeClient(plr, 'Notif', {Text = 'You have successfully promoted '.. Target.Name.. ' to '.. new})
  181.             Remotes.Notif:InvokeClient(Target, 'Notif', {Text = 'You have been promoted by the '.. Whitelisted[plr.UserId].. ' '.. plr.Name.. ' to '.. new})
  182.            
  183.             HTTPService:PostAsync(Url, data)
  184.             return;
  185.         elseif Command == '!demote' then
  186.             local new = adjustRankingDemo(plrStats['Title'].Value)
  187.             if new == 'None' then
  188.                 return;
  189.             end
  190.             plrStats['Title'].Value = new
  191.             Target.leaderstats.Rating.Value = new
  192.            
  193.             Remotes.Notif:InvokeClient(plr, 'Notif', {Text = 'You have successfully demoted '.. Target.Name.. ' to '.. new})
  194.             Remotes.Notif:InvokeClient(Target, 'Notif', {Text = 'You have been demoted by the '.. Whitelisted[plr.UserId].. ' '.. plr.Name.. ' to '.. new})
  195.            
  196.             HTTPService:PostAsync(Url, data)
  197.             return;
  198.         end
  199.        
  200.     end)
  201. end)
Add Comment
Please, Sign In to add comment