Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I want to make an adonis admin script, but I don't know how. Can somebody help me? [closed]

Asked by 3 years ago

I was wondering if any of you could help me on this.

Closed as Not Constructive by Cynical_Innovation, CreationNation1, matiss112233, and raid6n

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
SirGamezy 186
3 years ago
Edited 3 years ago

It takes a LOT of effort to make fully developed admin commands, so I thought I can teach you the basics.

String Manipulation

String manipulation is very important when making admin, because it makes it easier to get different segments of a chat message. Here are some examples:

string.split()

String.split has two parameters: (string, separator) What this does is split the text into a table and is separated by the separator.

For example, if the code was: string.split("This is a string", " "), then it would return a table: {"This", "is", "a", "string"}.

You can create a variable for the table, so you can use it in multiple lines:

local myText = "I love strings"
local splitString = string.split(myText, " ")

print(splitString[3])

You can also shorten it by slightly modifying it: myText:split(mySeparator).

string.sub()

Unlike split-string, sub-string consists of three parameters: (string, number, number) The numbers get the position of every letter of the string.

For example, if you wrote the code as: string.sub("Sub-String is great", 1, 5), then it would return a string: "Sub-S".

The 1 got the 1st letter of the string, and the 5 got the 5th letter of the string.

This can be used in a variety of ways, such as getting a single character prefix:

local prefix = "/"

if string.sub(message, 1, 1) == prefix then
    print("You entered the correct prefix!")
end

Like split-string, this can also be shortened: myText:sub(num1, num2).

Events

The most important aspect of making admin is getting the chat message of a player.

To do this, you can simply use a game.Players.PlayerAdded event to get the player, and a player.Chatted event to get the message.

Here's an example:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        -- code here
    end)
end)

Loops

Another important aspect of making admin is looping through important things, like tables. To do this, you can do:

local admins = {    -- admins table
    "SirGamezy",
    "Mr_Owlsss"
}

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        for _,item in pairs(admins) do
            if item = player.Name then
                -- code here
            end
        end
    end)
end)

Note that you can insert an additional 'for' loop to check if the message is a valid admin command.

Hopefully, this has helped you, comment for any questions!

0
Yes I have about 782 questions, what is a string? Mr_Owlsss -2 — 3y
0
A string is a text. To make one, simply add your text in quotation marks (") SirGamezy 186 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

I would look into using Cmdr. It's more or less a library you can build onto and make your own. It comes shipped with built in commands if you want to check those out too. Here's the link if you aren't sure where to find it:

https://github.com/evaera/Cmdr