Decided to make a calculator command, it clearly has much more work to be done, like double (decimal) and determine remainders ect.. and a better way of using the command, but here's a quick one I made for now:
/calculator [option] [number 1] [number 2]
Options:
add, subtract, multiply, add. You can also just use a short version: + - * /
Then use the numbers so /calc + 5 5 Equals 10
- Code: Select all
using System;
using System.Threading;
namespace MCDzienny
{
public class CmdCalculator : Command
{
public Boolean active;
public override string name { get { return "calculate"; } }
public override string shortcut { get { return "calc"; } }
public override string type { get { return "other"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override void Use(Player p, string message)
{
string option = message.Split(' ')[0];
int first = Convert.ToInt32(message.Split(' ')[1]);
int second = Convert.ToInt32(message.Split(' ')[2]);
if (option == "add" || option == "plus" || option == "+")
{
try
{
Player.SendMessage(p, "%bThe answer is: %7" + (first + second));
}
catch { Player.SendMessage(p, "Syntax Error."); return; }
}
if (option == "subtract" || option == "minus" || option == "-")
{
try
{
Player.SendMessage(p, "%bThe answer is: %7" + (first - second));
}
catch { Player.SendMessage(p, "Syntax Error."); return; }
}
if (option == "multiply" || option == "times" || option == "*")
{
try
{
Player.SendMessage(p, "%bThe answer is: %7" + (first * second));
}
catch { Player.SendMessage(p, "Syntax Error."); return; }
}
if (option == "divide" || option == "/")
{
try
{
Player.SendMessage(p, "%bThe answer is: %7" + (first / second));
}
catch { Player.SendMessage(p, "Syntax Error."); return; }
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/calculator - A simple calculator made by LeeIzaZombie");
Player.SendMessage(p, "It can add, multiply, subtract or divide two numbers.");
Player.SendMessage(p, "Example - %b/calculator add 5 5");
Player.SendMessage(p, "Shortcuts can be used: %b+ / * -");
Player.SendMessage(p, "/calculator + 5 5");
Player.SendMessage(p, "This is %aVersion 1.0");
}
}
}