Basics for coding commands.

Basics for coding commands.

Postby Leeizazombie » 22 Jan 2014, 00:43

Hey there, this post is for anyone who is a beginner coder and would like to learn some things you can do when making commands!

Sending certain messages:
You can send Global messages and messages that only the player can see.
For a Global message, which is a message shown to all players online, you use:
Code: Select all
Player.GlobalMessage("Hello world!");

To send a message to the player you can use:
Code: Select all
Player.SendMessage(p, "Hey me!");

Always remember the "p," part as that will tell the server that the message goes to you, you can also use it to send message to other players.

Finding a player and then executing a code:
Code: Select all
if (message == "")
{
    Help(p);
    return;
}
string playerName = message.Split(' ')[0];
Player who = Player.Find(playerName);

if (who == null)
{
    Player.SendMessage(p, "Player is not online.");
    return;
}
else
{
    // Code goes here when player is found.
    Player.SendMessage(p, "You found " + who.color + who.PublicName);
}


Using an in-game command:
Code: Select all
Command.all.Find("CommandNameHere").Use(p, "Command Arguments");

For example I will give a player a title:
Code: Select all
Command.all.Find("settitle").Use(p, "LeeIzaZombie IrishLad");

Where "LeeIzaZombie IrishLad" is the argument for "settitle", as if I used /settitle LeeIzaZombie IrishLad
You can leave the argument blank for commands like /shutdown

I hope I helped, please request any help that you need! :)
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: Basics for coding commands.

Postby joppiesaus » 23 Jan 2014, 15:22

Nice, this will help people who are new to custom commands.
Also, "else" at the "Finding a player and executing a code" is optional, but easier to read.
That's because you already return when player is not found before errors can happen :)
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: Basics for coding commands.

Postby Leeizazombie » 23 Jan 2014, 18:11

Yeah I know, but I decided to put else there to make sure people get an idea of using the method.
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.


Return to Knowledge Base

Who is online

Users browsing this forum: No registered users and 1 guest

cron