Plugins

Basic Admin Plugins for Hyra Ranking

This is a sample plugin to change a users rank with a Basic Admin plugin, utilising Hyra Ranking.

To install, simply add a ModuleScript into your Basic Admin Plugins folder. See image below.

You can name the script whatever you would like. Make sure you use a ModuleScript and not a normal script. ModuleScripts have a white/grey brick next to them in the icon.

Fixed Rank as Command Name
Using Rank as Argument
Fixed Rank as Command Name

Please copy the script below and paste it into your Plugin ModuleScript

local Plugin = function(...)
local Data = {...}
local remoteEvent = Data[1][1]
local remoteFunction = Data[1][2]
local returnPermissions = Data[1][3]
local Commands = Data[1][4]
local Prefix = Data[1][5]
local actionPrefix = Data[1][6]
local returnPlayers = Data[1][7]
local cleanData = Data[1][8]
local pluginName = 'sa' -- Your Command Name (We've used "sa" for Staff Assistant, make sure it's lowercase and unique)
local pluginPrefix = Prefix -- Prefix for your default prefix (usually ":"), actionPrefix for "!"
local pluginLevel = 2 -- The level which can run the plugin, 0 = everyone, 1 = Moderator, 2 = Admin, 3 = Superadmin
local pluginUsage = "<User(s)>" -- Don't touch this unless you really need to
local pluginDescription = "Promotes a user to the next rank." -- Don't touch this unless you really need to
local token = "XXXXXXXXXXXXXXXXXXXXXXXXX" -- CHANGE THIS ⚠ - THIS IS YOUR TOKEN TAKEN FROM THE HYRA ADMIN - KEEP THIS SECURE
local rankToRankTo = 35 -- CHANGE THIS ⚠ - THIS IS THE RANK YOU WANT TO PROMOTE THE USER TO
local groupId = 1 -- CHANGE THIS ⚠ - THIS IS YOUR GROUP ID
local Ranking = require(4754168383) -- Require the module
local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
local Player = Args[1]
if Args[3] then
local Victims = returnPlayers(Player, Args[3]) if not Victims then return end
local combinedVictims = ''
for a,b in pairs(Victims) do
if combinedVictims == '' then
combinedVictims = b.Name
else
combinedVictims = combinedVictims..', '..b.Name
end
end
for a,b in next,Victims do
local Callback = Ranking.SetRank(token, b.UserId, groupId, rankToRankTo)
if Callback.Success == true then
remoteEvent:FireClient(Player,'Hint','Success',b.Name..' was ranked.')
else
remoteEvent:FireClient(Player,'Hint','Error',b.Name..' was not ranked.')
end
end
end
end
-- Return Everything to the MainModule --
local descToReturn
if pluginUsage ~= "" then
descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
else
descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
end
return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}
end
return Plugin

Usage:

:sa <User(s)>

Using Rank as Argument

Pease copy the script below and paste it into your Plugin ModuleScript

You will need to update your if/elseif statements for each rank you want as an argument. Then edit the rankToRankTo variable in each if

local Plugin = function(...)
local Data = {...}
local remoteEvent = Data[1][1]
local remoteFunction = Data[1][2]
local returnPermissions = Data[1][3]
local Commands = Data[1][4]
local Prefix = Data[1][5]
local actionPrefix = Data[1][6]
local returnPlayers = Data[1][7]
local cleanData = Data[1][8]
local pluginName = 'rank' -- Your Command Name (We've used "sa" for Staff Assistant, make sure it's lowercase and unique)
local pluginPrefix = Prefix -- Prefix for your default prefix (usually ":"), actionPrefix for "!"
local pluginLevel = 2 -- The level which can run the plugin, 0 = everyone, 1 = Moderator, 2 = Admin, 3 = Superadmin
local pluginUsage = "<User(s)> <Rank>" -- Don't touch this unless you really need to
local pluginDescription = "Promotes a user to the next rank." -- Don't touch this unless you really need to
local token = "XXXXXXXXXXXXXXXXXXXXXXXXX" -- CHANGE THIS ⚠ - THIS IS YOUR TOKEN TAKEN FROM THE HYRA ADMIN - KEEP THIS SECURE
local groupId = 1 -- CHANGE THIS ⚠ - THIS IS YOUR GROUP ID
local Ranking = require(4754168383) -- Require the module
local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
local Player = Args[1]
if Args[3] then
local Victims = returnPlayers(Player, Args[3]) if not Victims then return end
local combinedVictims = ''
for a,b in pairs(Victims) do
if combinedVictims == '' then
combinedVictims = b.Name
else
combinedVictims = combinedVictims..', '..b.Name
end
end
for a,b in next,Victims do
if Args[4] then
if string.lower(Args[4]) == "sa" then
local rankToRankTo = 35 -- CHANGE THIS ⚠ - THIS IS THE RANK YOU WANT TO PROMOTE THE USER TO
local Callback = Ranking.SetRank(token, b.UserId, groupId, rankToRankTo)
if Callback.Success == true then
remoteEvent:FireClient(Player,'Hint','Success',b.Name..' was ranked.')
else
remoteEvent:FireClient(Player,'Hint','Error',b.Name..' was not ranked.')
end
elseif string.lower(Args[4]) == "trainee" then
local rankToRankTo = 10 -- CHANGE THIS ⚠ - THIS IS THE RANK YOU WANT TO PROMOTE THE USER TO
local Callback = Ranking.SetRank(token, b.UserId, groupId, rankToRankTo)
if Callback.Success == true then
remoteEvent:FireClient(Player,'Hint','Success',b.Name..' was ranked.')
else
remoteEvent:FireClient(Player,'Hint','Error',b.Name..' was not ranked.')
end
end
end
end
end
end
-- Return Everything to the MainModule --
local descToReturn
if pluginUsage ~= "" then
descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
else
descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
end
return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}
end
return Plugin

Usage:

:rank <User(s)> <Rank>

Important!

Make sure you edit the following variables for your group:

  • pluginName - The command name

  • pluginLevel - The role which can use the plugin > 0 = Everyone, 1 = Moderator, 2 = Admin, 3 = Superadmin

  • token - Your Hyra Ranking token

  • rankToRankTo - The rank you wish to promote to, the numerical number between 1 and 255 taken from group admin

  • groupId - Your Group ID taken from the URL of your group

Feel free to modify the code to include some useful stuff. For example, a Discord webhook.

Code licensed under APACHE-2.0 License.