@spydercam500 (Spu) posted a new topic, subject "How do i make custom commands for Cmdr". It read:

   How do i make custom commands for Cmdr  
    Thats about it i got it setup i just need to know how to make the custom commands i looked on the website and i dont understand how to do it if you could provide a video or explanation on how to do this please let me know!

@Stickpuppet (Puppet) replied

    Here's a template with comments to guide you. I recommend doing research and looking at the existing commands to learn how they are laid out and made.
    
    Name this module to command name
    [code] 
        return {
        	Name = "kick";
        	Aliases = {"boot"};
        	Description = "Kicks a player or set of players.";
        	Group = "DefaultAdmin";
        	Args = {
        		{
        			Type = "players";
        			Name = "players";
        			Description = "The players to kick."; --you can input their usernames when the type is players, I recommend doing research on the types.
        		},
        		{
        			Type = "string";
        			Name = "reason";
        			Description = "The reason to kick the player."; --Make sure to include the name and description
        		},
        	};
        }
        
    [/code]
    
    Name this to the command name but add server at the end
    [code] 
        return function (_, players, reason) --returns the command
        	for _, player in pairs(players) do --this gets the player
        		player:Kick("You have been kicked for "..reason) --includes the kick reason.
        	end
        
        	return ("Kicked %d players."):format(#players) --tells you how many players were kicked
        end
        
    [/code]

To which @minimic2002 (minimic2002) replied

    The best way is using string.split(Strint,Seperator)
    
    So when a player chats you split up what they say. Or a textbox
    
    function OnChat(Text)  
    local SplitVer = string.Split(Text," ") – split at spaces  
    if SplitVer[1].lower == “kick” then  
    – find and kick SplitVer[2]  
    end  
    end
    
    So if I was to say “:kick minimic2002”  
    SplitVer will become {":kick",“minimic2002”}
    
    String.Split will split up wherever it find the seperator, the seperator is just string and can consist of multiple characters.

After which, @spydercam500 (Spu) added

    Im talking about this
    
    Cmdr: A fully extensible and type safe command console for Roblox Developers Community Resources
    
    > [image] Cmdr Website Cmdr is a fully extensible and type safe command console for Roblox developers. Great for admin commands, but does much more. Make commands that tie in specifically with your game systems. Intelligent autocompletion and instant validation. Run commands programmatically on behalf of the local user. Bind commands to user input. Secure: the client and server both validate input separately. Embedded commands: dynamically use the output of an inner command when running a co… 
    
    Not a entire admin script

To which @liyuudd (liyud) replied

    There's a documentation for it.  
    You'll have to tweak in `BuiltInCommands` in the Cmdr ModuleScript.  
    Select any category (Admin, Debug, Utility)  
      
    Then, create 2 modulescripts. One named as your command and another named the exact same but with “Server” at the end.  
    Let's say I want to make a command named test. You'd have to make a first ModuleScript named “Test” and another one named “TestServer”.  
    In the first ModuleScript (Test), it would look like this.
    [code] 
        return {
        	Name = "test";
        	Aliases = {};
        	Description = "Prints something in the console.";
        	Group = "DefaultAdmin";
        	Args = {
        		{
        			Type = "string";
        			Name = "text";
        			Description = "The text to print.";
        		},
        	};
        }
        
    [/code]
    
    The server ModuleScript would then look like this.
    [code] 
        return function (context, text)
        	print(text)
        	return "Printed the text."
        --What is returned here will show in the Cmdr command bar
        end
        
    [/code]
    
    This is a very barebone tutorial but you'd get the idea.

Then @spydercam500 (Spu) said

    Ok so i did what you said and tryed to make my own command as a start its a simple command where you just change a int value of a int value object but it wont work heres the module script (not server)
    [code] 
        return {
        Name = "Core Temp";
        Aliases = {};
        Description = "Changes Core Temp";
        Group = "DefaultAdmin";
        Args = {
        	{
        		Type = "number";
        		Name = "TempNumber";
        		Description = "Core Temp Number";
        	},
        };
        }
        
    [/code]
    
    * * *
    
    And heres the 2nd module script (server)
    
    return function (context, text)
    [code] 
        game.ServerScriptService.CoreExplosionScript.CoreTemp = text
        
        return "Core Temp Changed."
        
        --What is returned here will show in the Cmdr command bar
        
        end
    [/code]

To which @liyuudd (liyud) replied

    spydercam500:
    
    > `game.ServerScriptService.CoreExplosionScript.CoreTemp = text`
    
    Try this instead:  
    `game.ServerScriptService.CoreExplosionScript.CoreTemp.Value = text`

After which, @spydercam500 (Spu) added

    Oh opps my bad i forgot to put that

Then @spydercam500 (Spu) said

    Now i get this error  
    04:50:53.149 Core_Temp command has no implementation!  
    @QuaternionIdentity

@spydercam500 (Spu) replied

    Ok so ive noticed that if i put the 2 scripts i made inside the admin folder or any other folder i can use the command (it still doesnt work cause of the error) but anyways when i put it in one of the folders i cant use some of the commands like the help command even though when i misspell a command or something it says use the help command to get a list of commands and i can only use that command and many more when i remove the 2 scripts i made

@CAROR567 (libc) replied

    You should create a folder in ServerStorage and name it “Commands” and add this line to the Cmdr server activation script
    [code] 
        Cmdr:RegisterCommandsIn(game.ServerStorage.Commands)
        
    [/code]
    
    Now you should store the custom commands in this folder. Otherwise adding custom commands to the BuildInCommands folder may break the system.  
    Also make sure to read the commands guide.

After which, @spydercam500 (Spu) added

    Ok so i cant use the help command and the command i added to the folder isnt showing up

So @CAROR567 (libc) replied

    Make sure to add this line
    [code] 
        Cmdr:RegisterCommandsIn(game.ServerStorage.Commands)
        
    [/code]
    
    To the Cmdr server activation script.

After which, @spydercam500 (Spu) added

    I did add that

After which, @spydercam500 (Spu) added

    Ok so apparently my commands i made werent in the commands folder somehow so when i moved them into it, it made the default commands work now i just need to get the command i made working because right now im getting this error

@Not0ffSale (Comet) replied

    S0YCHAD:
    
    > 
    [code]
    >     Core_Temp command has no implementation!
    >     
    [/code]
    
    Hey i also get this error. Have you fixed your problem? cause im trying to find out how to make a command work!

To which @COUNTYL1MITS (Wil) replied

    @spydercam500 @Not0ffSale You need to either define a ClientRun function in the command definition module or create a separate module with the suffix -Server, like kickServer. You would use ClientRun in the command if the command can run entirely on the client.


{'source': 'discourse', 'url': 'https://devforum.roblox.com/t/how-do-i-make-custom-commands-for-cmdr/1499966', 'title': 'How do i make custom commands for Cmdr', 'views': 1480, 'has_accepted_answer': True, 'word_count': 957, 'like_count': 11, 'reply_count': 14, 'participant_count': 7, 'posts': 17, 'tags': '', 'author': '@spydercam500 (Spu)', 'participants': '@spydercam500 (Spu), @Stickpuppet (Puppet), @minimic2002 (minimic2002), @liyuudd (liyud), @CAROR567 (libc), @Not0ffSale (Comet), @COUNTYL1MITS (Wil)', 'image_url': [None], 'created_at': '2021-10-08T14:08:49.327Z', 'last_posted_at': '2021-11-18T23:28:46.273Z'}