Hello. I’m trying to make a command so that higher leveled admins can run :instructor player and then the player would receive Instructor commands. I have an instructor rank in my settings.Ranks in the settings script.
I’ve made a server plugin but now i just need to know how. I’ve tried copy pasting the TempMod command from the Admins module but the senderLevel doesn’t work and i don’t know why.
Here is my settings.Ranks:
I have enabled these API calls:
Here is my server plugin:
--[[
SERVER PLUGINS' NAMES MUST START WITH "Server:" OR "Server-"
CLIENT PLUGINS' NAMES MUST START WITH "Client:" OR "Client-"
Plugins have full access to the server/client tables and most variables.
You can use the MakePluginEvent to use the script instead of setting up an event.
PlayerJoined will fire after the player finishes initial loading
CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
service.Events.PlayerAdded(function(p)
print(`{p.Name} Joined! Example Plugin`)
end)
service.Events.CharacterAdded(function(p)
server.RunCommand('name', plr.Name, 'BobTest Example Plugin')
end)
--]]
return function(Vargs)
local server, service = Vargs.Server, Vargs.Service
local Settings = server.Settings
local Functions, Commands, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Deps =
server.Functions, server.Commands, server.Admin, server.Anti, server.Core, server.HTTP, server.Logs, server.Remote, server.Process, server.Variables, server.Deps
server.Commands.InstructorCmd = {
Prefix = server.Settings.Prefix; -- Prefix to use for command
Commands = {"instructor"}; -- Commands
Args = {"player"}; -- Command arguments
Description = "Gives temporary instructor commands"; -- Command Description
Hidden = false; -- Is it hidden from the command list?
Fun = false; -- Is it fun?
AdminLevel = "FJ-JuniorOfficers"; -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
Function = function(plr: Player, args: {string}, data: {any}) -- Function to run for command
local senderLevel = data.PlayerData.Level
for _, v in service.GetPlayers(plr, assert(args[1], "Missing target player (argument #1)")) do
if senderLevel > Admin.GetLevel(v) then
Admin.AddAdmin(v, "Instructors", true)
Functions.Notification("Notification", "You are a temp moderator. Click to view commands.", {v}, 10, "MatIcons://Shield", Core.Bytecode(`client.Remote.Send('ProcessCommand','{Settings.Prefix}cmds')`))
Functions.Hint(`{service.FormatPlayer(v, true)} is now a temp moderator`, {plr})
else
Functions.Hint(`{service.FormatPlayer(v, true)} is already the same admin level as you or higher`, {plr})
end
end
end
}
end
the local senderLevel doesn’t work and when i run the command it says attempt to index nil with Level.