Skip to content

Documentation

gdr edited this page Sep 4, 2024 · 10 revisions

First time here

We recommend you to first visit Getting Started, before getting deeper into the logic.

ServerCommand Layout table Dictionary

  • ServerCommand Layout is the important thing to make Custom Command.
  • Default ServerCommand Layout:
{
  Command: string = "Name",
  RequiredRank: number = 0,
  Alias: array = {"Name2", "SecondName"},
  
  UppercaseMatters: bool = false,
  Loop: bool = false,
  
  Client: bool = false,
  ClientOnly: bool = false,
  CallerClient: bool = false,
  
  Arguments: array = {"Player;", "number;"},
  References: array = {"Player", "Studs"},
  ArgPermissions: array = {4},
  
  Revoke: array = {"UnName", "UnName2"},
  UnDo: (Caller, Arguments) = ...,
  Function: (Caller, Arguments) = ...,
  PreFunction: (Caller, Arguments) = ...,
}

Explanation of every thing inside of the Layout:

Command string

Main name of the command which will show up in the Panel Commands Section.

RequiredRank number

Required rank to use the command.

Alias Array

Secondary names of the command that player can use.

UppercaseMatter boolean

Determines if Parser will care of incorrectly spelled case or not.

Loop boolean

Determines if the command will run again after player's death or not.

Client boolean

Returns command to the client. Mostly useless.

ClientOnly boolean

Determines if the command is located at the ClientCommands and has ClientCommand Layout.

CallerClient boolean

Determines if the command will run only on caller's computer.
If false and Argument[1] is a Player, will run on this player's computer.

Arguments array

Arguments of the command.
Will give Arguments as an array as a second argument in UnDo, Function, PreFunction functions.
See more about arguments here.

References array

Will replace argument's name into the one, located here.
All of the names needs to be positioned right as in the Arguments array.

ArgPermissions array

Sets rank for usage of the argument.
All of the numbers needs to be positioned right as in the Arguments array.

Revoke array

Same as Alias, but used for UnDo.

UnDo function

Arguments: Caller: Player, Arguments: array.
If ClientOnly is set to true, leave this method as boolean.
Main method of undoing the command.
If Loop is true, command will stop rerunning after undo.

Function function

Arguments: Caller: Player, Arguments: array.
If ClientOnly is set to true, leave this method as nil.
Main function of the command.

PreFunction function

Argument: Caller: Player Arguments: array.
If ClientOnly is set to true, leave this method as nil. Client command doesn't have PreFunction.
Will run before command's main function.
Before running, Main Function will wait for PreFunction end.



ClientCommand Layout Key & Value Dictionary

  • ClientCommand Layout is the important thing to make Custom Command on a client.
  • Needs to have ServerCommand Layout on the server.
  • Default ClientCommand Layout:
ClientCommands.CommandName = function(Caller, Arguments)
  -- YOUR CODE HERE.
end

ClientCommands.UnCommandName = function(Caller, Arguments)
  -- YOUR CODE HERE.
end

Explanation of the layout:

CommandName string

Name of the command's function.
Needs to be identical to the ServerCommand Layout's command name.

Function function

Argument: Caller: Player, Arguments: array.
MainFunction of the command like in the ServerCommand Layout, but changes will be seen only for the client.

UnCommandName string

UnDo of the command.
If your function has UnDo, you must have name of the function like this: Un{NAME}. (Un must be the prefix.)
If UnDo set to false on the ServerCommand Layout, no need to have it here.

UnDo function function

Argument: Caller: Player, Arguments: array.
If UnDo set to false on the ServerCommand Layout, no need to have it here.
UnDo function of the command like in the ServerCommand Layout, but changes will be seen only for the client.



Arguments string

An array, that will be second argument for the UnDo, Function and PreFunction of the command. Arguments will be placed order exactly like you placed them in the ServerCommand Layout Arguments table.
Needs to have Argument Types to work properly.
On the moment there's 7 arguments.
Here's what they return in an array:

Player Player

Returns Player instance.

Tool Object

Returns Tool instance.

Rank number

Returns rank id. (Rank Id - number from 1 to 5.)

Object Object

Returns descendant of the workspace.

Stat string

Returns name of the statistic in the player's leaderstats.
Due to limitations, we can only give a name of statistic, and not the object.
Use this to get statistic:

local Statistic = player:FindFirstChild(StatName, true)

number number

Returns number.
If nil, will be set to 0.

string string

Returns string.
If nil, will be set to empty string.



Argument Types Symbol

Argument Type is a symbol, placed after an argument.
Example:

"Player;"
"Player@"
"Player!"
...etc.

1. ;

Default argument.

2. !

Only works with Player argument.
Determines if player needs to be online or not.

3. ?

Determines if argument is optional or not.
Arguments as Tool, Rank, Object, Stat will return nil if set to true.

4. @

Only works with Player argument.
Player is an optional argument, but if given, player needs to be online.

5. #

Only works with string argument.
Filters the string, using TextService.
If filtering failed, will return [Unable to filter] as a string.

6. +

Only works with Rank argument.
Rank can't be higher or equal to player's rank.

7. :

Only works with Object argument.
Object must be certain class.
Example:

"Object:Folder"
"Object:Part"

8. "|"

one argument can be multiple arguments and types.
Example:

"string#|number;"
"Stat?|Tool;"





Parser Module Server

If you ever wanted to run a command in your own script, :GetParser() method will help you.
:GetParser() method is located at MainModule of the GAdmin.

Example:

task.wait(.5)
local GAdmin = require(_G.GAdmin)
local Parser = GAdmin:GetParser()

You need to use task.wait() in the start for GAdmin to appear in the _G.
But how to actually use Parser?

Main method of Parser is :TriggerCommand(Caller, Command, Arguments).
But Player is the first argument, so you need to use method :RunOnComplete() of MainModule:

task.wait(.5)
local GAdmin = require(_G.GAdmin)
local Parser = GAdmin:GetParser()

GAdmin:RunOnComplete(function()
	for i, player in ipairs(game.Players:GetPlayers()) do
		Parser:TriggerCommand(player, "about", {player})
	end
end)

RunOnComplete method runs after GAdmin has been fully configurated.

About Meta

TriggerCommand meta

Arguments: Caller: Player, Command: string, Arguments: array.
Arguments is an array table, which must contain arguments that was written in ServerCommand Layout.
If you don't actually want to type arguments yourself, use method :Parse() of Parser.

ParseMessage meta Deprecated

It's Deprecated because it can identify string argument as another command. Use :Parse() instead.

Arguments: Caller: Player, Message: string, NoPrefix: boolean.
Message - String of commands and arguments. Example: ;kill me ;view me ;god me.
NoPrefix - If set to true, you can type commands in Message without prefixes. (Example: kill me view me god me)

Returns MessageData type, that can be used in :TriggerCommands() method of Parser:

local MessageData = Parser:ParseMessage(Caller, "fly", true)
Parser:TriggerCommands(Caller, MessageData)

Parse meta

Arguments: Caller: Player, Message: string, IgnoreCustomPrefix: boolean.
Message - String of commands and arguments. Example: ;kill me ;view me ;god me.
IgnoreCustomPrefix - Automaticly sets prefix in the message to default prefix (Settings.DefaultPrefix).

Returns MessageData type, that can be used in :TriggerCommands() method of Parser:

local MessageData = Parser:Parse(Caller, ";fly", true)
Parser:TriggerCommands(Caller, MessageData)

TriggerCommands meta

Arguments: Caller: Player, Data: MessageData.
Used to trigger one command, or multiple of them.



Framework Module Client

Framework - main module on the client, which contains all of the important for GAdmin Panel methods.
You can get Framework in your own LocalScript with _G:

repeat task.wait() until _G.GFramework
local Framework = require(_G.GFramework)