Just follow the comments within the code:
- Code: Select all
using System;
using System.Xml;
namespace MCDzienny
{
public class CmdTestMe : Command
{
public override string name { get { return "eightball"; } }
public override string shortcut { get { return "8-ball"; } }
public override string type { get { return "other"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override void Use(Player p, string message)
{
if (message != null && message.Length >= 3) //Question must contain text and is greater or equal to 3 in lenght.
{
string[] answer = new string[3]; //Using the variable "answer" to create "3" diffrent outputs.
answer[0] = "Yes."; //Random answer #1
answer[1] = "Maybe."; //Random answer #2
answer[2] = "No."; //Random answer #3
Random rnd = new Random();
Player.SendMessage(p, "%7Your question is:%b " + message + ", %7The 8 ball says: %b" + answer[rnd.Next(0, 2)]);
}
else
Player.SendMessage(p, "Please ask a question.");
}
public override void Help(Player p)
{
Player.SendMessage(p, "/8-ball [question] - Ask the 8-ball a question.");
}
}
}
So if you want to add more answers just do the following sequence:
- Code: Select all
string[] answer = new string[4]; //Change new string[3] to new string[4]
answer[0] = "Yes.";
answer[1] = "Maybe.";
answer[2] = "No.";
answer[3] = "Sometimes."; //Addded my new answer with [3]
I hope you enjoy it!
Uses:
/eightball [question]
/8-ball [question]
Note
There is already an 8ball command, just be sure on how you use the command, the other 8 ball is used by /8ball, this one is /8-ball, also this one doesn't show everyone (but you can change that).
Feel free to ask questions if you have any problems!
Picture of command used:
Spoiler: