Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple prefix support and adds ; as a prefix. #1841

Merged
merged 14 commits into from
Jan 27, 2025
2 changes: 1 addition & 1 deletion Loader/Config/Settings.luau
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ settings.SaveAdmins = true -- If true anyone you ;admin or ;headadmin in-game
settings.LoadAdminsFromDS = true -- If false, any admins saved in your DataStores will not load
settings.WhitelistEnabled = false -- If true enables the whitelist/server lock; Only lets admins & whitelisted users join

settings.Prefix = ";" -- The ; in ;kill me
settings.Prefix = {";", ":"} -- A list of prefixes for commands, the ; in ;kill me
settings.PlayerPrefix = "!" -- The ! in !donate; Mainly used for commands that any player can run; Do not make it the same as settings.Prefix
settings.SpecialPrefix = "" -- Used for things like "all", "me" and "others" (If changed to ! you would do ;kill !me)
settings.SplitKey = " " -- The space in ;kill me (eg if you change it to / ;kill me would be ;kill/me)
Expand Down
3 changes: 2 additions & 1 deletion MainModule/Client/UI/Default/UserPanel.luau
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ return function(data, env)
chatMod = Remote.Get("Setting",{"Prefix","SpecialPrefix","BatchKey","AnyPrefix","DonorCommands","DonorCapes"})
settingsData = Remote.Get("AllSettings")
Variables.Aliases = playerData.Aliases or {}
commandPrefix = chatMod.Prefix
commandPrefix = if type(chatMod.Prefix) == "table" then chatMod.Prefix[1] else chatMod.Prefix


for _, v in loadingIcons do
v:Destroy()
Expand Down
2,939 changes: 1,530 additions & 1,409 deletions MainModule/Server/Commands/Admins.luau

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions MainModule/Server/Commands/Moderators.luau
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ return function(Vargs, env)
Commands = {"cn", "customsmallmessage", "cnmessage"};
Args = {"title", "message"};
Filter = true;
Description = `Same as {Settings.Prefix}n but says whatever you want the title to be instead of your name.`;
Description = `Same as {Functions.GetMainPrefix()}n but says whatever you want the title to be instead of your name.`;
AdminLevel = "Moderators";
Function = function(plr: Player, args: {string})
Functions.Notify(service.BroadcastFilter(assert(args[1], "Missing title"), plr), service.BroadcastFilter(assert(args[2], "Missing message") , plr), service.GetPlayers())
Expand Down Expand Up @@ -377,7 +377,7 @@ return function(Vargs, env)

Remote.RemoveGui(v, "Notify")
Functions.Notify(`Warning from {service.FormatPlayer(plr)}`, reason, {v})
Functions.Notification("Notification", `Warned {service.FormatPlayer(v)}`, {plr}, 5, "MatIcons://Shield", Core.Bytecode(`client.Remote.Send('ProcessCommand','{Settings.Prefix}warnings {v.Name}')`))
Functions.Notification("Notification", `Warned {service.FormatPlayer(v)}`, {plr}, 5, "MatIcons://Shield", Core.Bytecode(`client.Remote.Send('ProcessCommand','{Functions.GetMainPrefix()}warnings {v.Name}')`))
end
end
end
Expand Down Expand Up @@ -416,7 +416,7 @@ return function(Vargs, env)
Core.CrossServer("RemovePlayer", v.Name, `Warning from {service.FormatPlayer(plr)}`, reason)
end

Functions.Notification("Notification", `Kick-warned {service.FormatPlayer(v)}`, {plr}, 5, "MatIcons://Shield", Core.Bytecode(`client.Remote.Send('ProcessCommand','{Settings.Prefix}warnings {v.Name}')`))
Functions.Notification("Notification", `Kick-warned {service.FormatPlayer(v)}`, {plr}, 5, "MatIcons://Shield", Core.Bytecode(`client.Remote.Send('ProcessCommand','{Functions.GetMainPrefix()}warnings {v.Name}')`))
end
end
end
Expand Down Expand Up @@ -725,7 +725,7 @@ return function(Vargs, env)
for k, t in v.Backpack:GetChildren() do
t.Parent = tools
end
Admin.RunCommand(`{Settings.Prefix}name`, v.Name, `-AFK-_{service.FormatPlayer(v)}_-AFK-`)
Admin.RunCommand(`{Functions.GetMainPrefix()}name`, v.Name, `-AFK-_{service.FormatPlayer(v)}_-AFK-`)
local torso = v.Character.HumanoidRootPart
local pos = torso.CFrame
local running=true
Expand All @@ -738,7 +738,7 @@ return function(Vargs, env)
for k, t in tools:GetChildren() do
t.Parent = v.Backpack
end
Admin.RunCommand(`{Settings.Prefix}unname`, v.Name)
Admin.RunCommand(`{Functions.GetMainPrefix()}unname`, v.Name)
event:Disconnect()
end)
repeat torso.CFrame = pos wait() until not v or not v.Character or not torso or not running or not torso.Parent
Expand Down Expand Up @@ -811,7 +811,7 @@ return function(Vargs, env)
Prefix = Settings.Prefix;
Commands = {"fullgod", "totalgod"};
Args = {"player"};
Description = `Same as {server.Settings.Prefix}god, but also provides blast protection`;
Description = `Same as {Functions.GetMainPrefix()}god, but also provides blast protection`;
AdminLevel = "Moderators";
Function = function(plr: Player, args: {string})
for _, v in service.GetPlayers(plr, args[1]) do
Expand Down Expand Up @@ -1243,7 +1243,7 @@ return function(Vargs, env)
TitleButtons = {
{
Text = "";
OnClick = Core.Bytecode(`client.Remote.Send('ProcessCommand','{Settings.Prefix}tools')`);
OnClick = Core.Bytecode(`client.Remote.Send('ProcessCommand','{Functions.GetMainPrefix()}tools')`);
Children = {
{
Class = "ImageLabel";
Expand Down Expand Up @@ -1594,7 +1594,7 @@ return function(Vargs, env)
local command = args[3]
local name = string.lower(plr.Name)
assert(command, "Missing command name to repeat")
if string.lower(string.sub(command, 1, #Settings.Prefix+string.len("repeat"))) == string.lower(`{Settings.Prefix}repeat`) or string.sub(command, 1, #Settings.Prefix+string.len("loop")) == string.lower(`{Settings.Prefix}loop`) or string.find(command, `^{Settings.Prefix}loop`) or string.find(command, `^{Settings.Prefix}repeat`) then
if string.lower(string.sub(command, 1, #Functions.GetMainPrefix()+string.len("repeat"))) == string.lower(`{Settings.Prefix}repeat`) or string.sub(command, 1, #Functions.GetMainPrefix()+string.len("loop")) == string.lower(`{Settings.Prefix}loop`) or string.find(command, `^{Settings.Prefix}loop`) or string.find(command, `^{Settings.Prefix}repeat`) then
error("Cannot repeat the loop command in a loop command")
return
end
Expand Down Expand Up @@ -2116,7 +2116,7 @@ return function(Vargs, env)
local data = {
Tools = {};
SavedTools = {};
Prefix = Settings.Prefix;
Prefix = Functions.GetMainPrefix();
SplitKey = Settings.SplitKey;
SpecialPrefix = Settings.SpecialPrefix;
}
Expand Down Expand Up @@ -4468,7 +4468,7 @@ return function(Vargs, env)
AdminLevel = "Moderators";
Function = function(plr: Player, args: {[number]:string})
Remote.MakeGui(plr, "Teams", {
CmdPrefix = Settings.Prefix; CmdPlayerPrefix = Settings.PlayerPrefix; CmdSpecialPrefix = Settings.SpecialPrefix; CmdSplitKey = Settings.SplitKey;
CmdPrefix = Functions.GetMainPrefix(); CmdPlayerPrefix = Settings.PlayerPrefix; CmdSpecialPrefix = Settings.SpecialPrefix; CmdSplitKey = Settings.SplitKey;
})
end
};
Expand Down
49 changes: 25 additions & 24 deletions MainModule/Server/Commands/Players.luau
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ return function(Vargs, env)

for _,alias in cmd.Commands do
if #cmdAliases >= 4 and (#cmd.Commands - #cmdAliases) ~= 0 then
table.insert(cmdAliases, `and {#cmd.Commands - #cmdAliases} more...`)
table.insert(cmdAliases, `and {#cmd.Commands - #cmdAliases} more...`)
break
end
end

table.remove(cmdAliases, 1)

local permissionDesc = Admin.FormatCommandAdminLevel(cmd)
Expand Down Expand Up @@ -83,7 +83,7 @@ return function(Vargs, env)
local cmd, ind
for i, v in Admin.SearchCommands(plr, "all") do
for _, p in v.Commands do
if (v.Prefix or "")..string.lower(p) == string.lower(args[1]) then
if (if type(v.Prefix) == "table" then v.Prefix[1] else v.Prefix or "")..string.lower(p) == string.lower(args[1]) then
cmd, ind = v, i
break
end
Expand All @@ -107,7 +107,7 @@ return function(Vargs, env)
Title = "Command Info";
Icon = server.MatIcons.Info;
Table = {
{Text = `<b>Prefix:</b> {cmd.Prefix}`, Desc = "Prefix used to run the command"},
{Text = `<b>Prefix:</b> {if type(cmd.Prefix) =="table" then table.concat(cmd.Prefix, ", ") else cmd.Prefix}`, Desc = "Prefix used to run the command"},
{Text = `<b>Commands:</b> {SanitizeXML(table.concat(cmd.Commands, ", "))}`, Desc = "Valid default aliases for the command"},
{Text = `<b>Arguments:</b> {if cmdArgs == "" then "-" else SanitizeXML(cmdArgs)}`, Desc = "Parameters taken by the command"},
{Text = `<b>Admin Level:</b> {Admin.FormatCommandAdminLevel(cmd)}`, Desc = "Rank required to run the command"},
Expand Down Expand Up @@ -150,7 +150,7 @@ return function(Vargs, env)
Description = "Shows you the command prefix using the :cmds command";
AdminLevel = "Players";
Function = function(plr: Player, args: {string})
Functions.Hint(`{Settings.Prefix}cmds`, {plr})
Functions.Hint(`{if type(Settings.Prefix) == "table" then Settings.Prefix[1] else Settings.Prefix}cmds`, {plr})
end
};

Expand Down Expand Up @@ -567,46 +567,47 @@ return function(Vargs, env)
Description = "Shows you how to use some syntax related things";
AdminLevel = "Players";
Function = function(plr: Player, args: {string})
local Prefix = if type(Settings.Prefix) == "table" then Settings.Prefix[1] else Settings.Prefix
local usage = {
"";
"Mouse over things in lists to expand them";
"You can also resize windows by dragging the edges";
"";
`Put <b>/e</b> in front to silence commands in chat (<b>/e {Settings.Prefix}kill scel</b>) or enable chat command hiding in client settings`;
`Put <b>/e</b> in front to silence commands in chat (<b>/e {Prefix}kill scel</b>) or enable chat command hiding in client settings`;
`Player commands can be used by anyone, these commands have <b>{Settings.PlayerPrefix}</b> infront, such as <b>{Settings.PlayerPrefix}info</b> and <b>{Settings.PlayerPrefix}rejoin</b>`;
"";
`<b>――――― Player Selectors ―――――</b>`;
`Usage example: <b>{Settings.Prefix}kill {Settings.SpecialPrefix}all</b> (where <b>{Settings.SpecialPrefix}all</b> is the selector)`;
`Usage example: <b>{Prefix}kill {Settings.SpecialPrefix}all</b> (where <b>{Settings.SpecialPrefix}all</b> is the selector)`;
`<b>{Settings.SpecialPrefix}me</b> - Yourself`;
`<b>{Settings.SpecialPrefix}all</b> - Everyone in the server`;
`<b>{Settings.SpecialPrefix}admins</b> - All admins in the server`;
`<b>{Settings.SpecialPrefix}nonadmins</b> - Non-admins (normal players) in the server`;
`<b>{Settings.SpecialPrefix}others</b> - Everyone except yourself`;
`<b>{Settings.SpecialPrefix}random</b> - A random person in the server excluding those removed with -SELECTION`;
`<b>@USERNAME</b> - Targets a specific player with that exact username Ex: <b>{Settings.Prefix}god @Sceleratis </b> would give a player with the username 'Sceleratis' god powers`;
`<b>#NUM</b> - NUM random players in the server <b>{Settings.Prefix}ff #5</b> will ff 5 random players excluding those removed with -SELECTION.`;
`<b>@USERNAME</b> - Targets a specific player with that exact username Ex: <b>{Prefix}god @Sceleratis </b> would give a player with the username 'Sceleratis' god powers`;
`<b>#NUM</b> - NUM random players in the server <b>{Prefix}ff #5</b> will ff 5 random players excluding those removed with -SELECTION.`;
`<b>{Settings.SpecialPrefix}friends</b> - Your friends who are in the server`;
`<b>%TEAMNAME</b> - Members of the team TEAMNAME Ex: {Settings.Prefix}kill %raiders`;
`<b>%TEAMNAME</b> - Members of the team TEAMNAME Ex: {Prefix}kill %raiders`;
`<b>$GROUPID</b> - Members of the group with ID GROUPID (number in the Roblox group webpage URL)`;
`<b>-SELECTION</b> - Inverts the selection, ie. will remove SELECTION from list of players to run command on. {Settings.Prefix}kill all,-%TEAM will kill everyone except players on TEAM`;
`<b>+SELECTION</b> - Readds the selection, ie. will readd SELECTION from list of players to run command on. {Settings.Prefix}kill all,-%TEAM,+Lethalitics will kill everyone except players on TEAM but also Lethalitics`;
`<b>radius-NUM</b> -- Anyone within a NUM-stud radius of you. {Settings.Prefix}ff radius-5 will ff anyone within a 5-stud radius of you.`;
`<b>-SELECTION</b> - Inverts the selection, ie. will remove SELECTION from list of players to run command on. {Prefix}kill all,-%TEAM will kill everyone except players on TEAM`;
`<b>+SELECTION</b> - Readds the selection, ie. will readd SELECTION from list of players to run command on. {Prefix}kill all,-%TEAM,+Lethalitics will kill everyone except players on TEAM but also Lethalitics`;
`<b>radius-NUM</b> -- Anyone within a NUM-stud radius of you. {Prefix}ff radius-5 will ff anyone within a 5-stud radius of you.`;
"";
`<b>――――― Repetition ―――――</b>`;
`Multiple player selections - <b>{Settings.Prefix}kill me,noob1,noob2,{Settings.SpecialPrefix}random,%raiders,$123456,{Settings.SpecialPrefix}nonadmins,-scel</b>`;
`Multiple Commands at a time - <b>{Settings.Prefix}ff me {Settings.BatchKey} {Settings.Prefix}sparkles me {Settings.BatchKey} {Settings.Prefix}rocket jim</b>`;
`You can add a delay if you want; <b>{Settings.Prefix}ff me {Settings.BatchKey} !wait 10 {Settings.BatchKey} {Settings.Prefix}m hi we waited 10 seconds</b>`;
`<b>{Settings.Prefix}repeat 10(how many times to run the cmd) 1(how long in between runs) {Settings.Prefix}respawn jim</b>`;
`Multiple player selections - <b>{Prefix}kill me,noob1,noob2,{Settings.SpecialPrefix}random,%raiders,$123456,{Settings.SpecialPrefix}nonadmins,-scel</b>`;
`Multiple Commands at a time - <b>{Prefix}ff me {Settings.BatchKey} {Prefix}sparkles me {Settings.BatchKey} {Prefix}rocket jim</b>`;
`You can add a delay if you want; <b>{Prefix}ff me {Settings.BatchKey} !wait 10 {Settings.BatchKey} {Prefix}m hi we waited 10 seconds</b>`;
`<b>{Prefix}repeat 10(how many times to run the cmd) 1(how long in between runs) {Prefix}respawn jim</b>`;
"";
`<b>――――― Reference Info ―――――</b>`;
`<b>{Settings.Prefix}cmds</b> for a list of available commands`;
`<b>{Settings.Prefix}cmdinfo &lt;command&gt;</b> for detailed info about a specific command`;
`<b>{Prefix}cmds</b> for a list of available commands`;
`<b>{Prefix}cmdinfo &lt;command&gt;</b> for detailed info about a specific command`;
`<b>{Settings.PlayerPrefix}brickcolors</b> for a list of BrickColors`;
`<b>{Settings.PlayerPrefix}materials</b> for a list of materials`;
"";
`<b>{Settings.Prefix}capes</b> for a list of preset admin capes`;
`<b>{Settings.Prefix}musiclist</b> for a list of preset audios`;
`<b>{Settings.Prefix}insertlist</b> for a list of insertable assets using {Settings.Prefix}insert`;
`<b>{Prefix}capes</b> for a list of preset admin capes`;
`<b>{Prefix}musiclist</b> for a list of preset audios`;
`<b>{Prefix}insertlist</b> for a list of insertable assets using {Prefix}insert`;
}
Remote.MakeGui(plr, "List", {
Title = "Usage";
Expand Down Expand Up @@ -937,7 +938,7 @@ return function(Vargs, env)
IsDonor = Admin.CheckDonor(v);
GameData = gameData;
IsServerOwner = v.UserId == game.PrivateServerOwnerId;
CmdPrefix = Settings.Prefix;
CmdPrefix = Functions.GetMainPrefix();
CmdSplitKey = Settings.SplitKey;
OnlineFriends = Remote.Get(v, "Function", "GetFriendsOnline");
})
Expand Down Expand Up @@ -1018,7 +1019,7 @@ return function(Vargs, env)
ServerAge = service.FormatTime(os.time() - server.ServerStartTime);
ServerInternetInfo = serverInfo;
Refreshables = Logs.ListUpdaters.ServerDetails(plr);
CmdPrefix = Settings.Prefix;
CmdPrefix = if type(Settings.Prefix) == "table" then Settings.Prefix[1] else Settings.Prefix,
CmdPlayerPrefix = Settings.PlayerPrefix;
SplitKey = Settings.SplitKey;
})
Expand Down
39 changes: 30 additions & 9 deletions MainModule/Server/Core/Admin.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,16 @@ return function(Vargs, GetEnv)
for ind, data in Commands do
if type(data) == "table" then
for i,cmd in data.Commands do
if data.Prefix == "" then Admin.BlankPrefix = true end
tempPrefix[data.Prefix] = true
tempTable[string.lower(data.Prefix..cmd)] = ind
if type(data.Prefix) ~= "table" and data.Prefix == "" then Admin.BlankPrefix = true end
if type(data.Prefix) == "table" then
for _,p in data.Prefix do
tempPrefix[p] = true
tempTable[string.lower(p..cmd)] = ind
end
else
tempPrefix[data.Prefix] = true
tempTable[string.lower(data.Prefix..cmd)] = ind
end
end
end
end
Expand Down Expand Up @@ -1232,13 +1239,27 @@ return function(Vargs, GetEnv)
end

for _, v in data.Commands do
if not blacklistedCommands["/"..data.Prefix..v] then
if not command1 then
command1 = "/"..data.Prefix..v
else
command2 = "/"..data.Prefix..v
if type(data.Prefix) == "table" then
for _, p in data.Prefix do
if not blacklistedCommands["/"..p..v] then
if not command1 then
command1 = "/"..p..v
else
command2 = "/"..p..v
end
end
end
else
if not blacklistedCommands["/"..data.Prefix..v] then
if not command1 then
command1 = "/"..data.Prefix..v
else
command2 = "/"..data.Prefix..v
end
end

end

end

if command1 then
Expand Down Expand Up @@ -1336,7 +1357,7 @@ return function(Vargs, GetEnv)

FormatCommand = function(command, cmdn)
return table.concat({
(command.Prefix or ""),
(if type(command.Prefix) == "table" then command.Prefix[1] else command.Prefix or ""),
tostring(command.Commands[cmdn or 1]),
#command.Args > 0 and Settings.SplitKey or "",
#command.Args > 0 and Admin.FormatCommandArguments(command) or ""
Expand Down
10 changes: 8 additions & 2 deletions MainModule/Server/Core/Commands.luau
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ return function(Vargs, GetEnv)
t = server.Typechecker;

local ValidateCommandDefinition = t.interface({
Prefix = t.string,
Prefix = t.union(t.string, t.array(t.string)),
Commands = t.array(t.string),
Description = t.string,
AdminLevel = t.union(t.string, t.number, t.nan, t.array(t.union(t.string, t.number, t.nan))),
Expand Down Expand Up @@ -99,7 +99,13 @@ return function(Vargs, GetEnv)
Admin.PrefixCache[cmd.Prefix] = true

for _, v in cmd.Commands do
Admin.CommandCache[string.lower(cmd.Prefix..v)] = ind
if type(cmd.Prefix) == "table" then
for _,p in cmd.Prefix do
Admin.CommandCache[string.lower(p..v)] = ind
end
else
Admin.CommandCache[string.lower(cmd.Prefix..v)] = ind
end
end

cmd.Args = cmd.Args or cmd.Arguments or {}
Expand Down
8 changes: 7 additions & 1 deletion MainModule/Server/Core/Functions.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1664,5 +1664,11 @@ return function(Vargs, GetEnv)
end
return if allowNil then nil else BrickColor.random()
end;
};

GetMainPrefix = function()
if type(Settings.Prefix) == "table" then return Settings.Prefix[1] else return Settings.Prefix end
end;
}


end
Loading
Loading