Hello again, I am having trouble on using the custom commands property to run commands inside it.
Lets say I want to do :shift and then when I do shift, the custom command should do like this:
:m All staff head to the kitchen for a briefing for the shift, thank you.
But when I use the server.RunCommand() it does not works.
So I am wondering how to use the server.RunCommand() or how to fix it.
You’re assuming people know what Adonis is or how it works while lacking any information other than an explanation of your problem which, in itself, introduces unknown and unexplained concepts. Also, have you tried looking at their API (if they have any documentation) or running quickly through the code via Ctrl + F for key terms that could lead you closer to a solution?
If you’re that desperate, make your own. Make it so on message, check if it is equal to :shift, check permissions and stuff then tween a GUI on and off the screen saying shift to those needed.
Yes, the API docs in Adonis are extremely lacking, I did contact Sceleratis/DaveyBones directly at some point, I had the same questions. Here are the responses, I hope you find them useful in some way or another. Altough it does not mention custom commands, it is all the information I managed to obtain.
Responses
O woops, the API documentation module hasn’t been updated for a while as I just forgot to keep it up to date qq.
Anyway, you can use service.Events.CommandRan:connect(function(plr, msg, matched, args, command, index, ran, error, isSystem) print(“stuff here”) end)
plr = Player running command
msg = The message they chatted in which a command was found
matched = The first part of the command in the message used to identify the command being ran (eg if the message was :m hi matched would be “:m”)
args = The table containing command arguments (so “hi” in “:m hi” would be args[1])
command = The command’s data table (contains all the information about the command including it’s function to run)
index = The index the command data is at in the server.Commands table
ran = Whether or not the command ran successfully (no error)
error = The command error if it failed to run correctly
isSystem = Will be true if the command was ran by the system/script instead of a player
Do note that the event fires after the command is ran, and will not fire until the command is finished running and exits as that’s the only way to see if it successfully ran and get any errors.
If you would like to just see command logs you can use server.Events.LogAdded:connect(function(logTable, logEntry) end) instead as it will not wait for a command to finish before firing, however only provides logging data and does not provide any information about whether or not the command was successful and also does not provide the player who ran the command. To get the name of the table the log is being sent to, you can use server.Logs.TabToType(logTable).
All Adonis modules & plugins can access the service table and it’s event’s subtable, so there shouldn’t be anything that needs to be done prior.
The admin doesn’t use server.RunCommand, it uses Admin.RunCommand. You would use it like Admin.RunCommand(":fly", PlayerName), the first parameter is the command you want to run and the other parameters are the args.
You really wouldn’t even have to do that :m thing though, within its API you can do things like Remote.MakeGui() to create messages. The “:m” command does something like this:
Remote.MakeGui(v,"Message",{
Title = "Message from " .. plr.Name;
Message = args[1];--service.Filter(args[1],plr,v);
Scroll = true;
Time = (#tostring(args[1])/19)+2.5;
})