Advertisement
CallumGetty

Calculator

Apr 10th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. [Command("calculator", Alias = "calc")]
  2.         public void Calculator_Command(Client player, int firstNum, string mathType, int secondNum)
  3.         {
  4.             //Add checks to see if they have a calculator here.
  5.  
  6.             float result = 0;
  7.             switch (mathType)
  8.             {
  9.                 case "*":
  10.                     {
  11.                         result = (firstNum * secondNum);
  12.                         break;
  13.                     }
  14.                 case "-":
  15.                     {
  16.                         result = (firstNum - secondNum);
  17.                         break;
  18.                     }
  19.                 case "+":
  20.                     {
  21.                         result = (firstNum + secondNum);
  22.                         break;
  23.                     }
  24.                 case "/":
  25.                     {
  26.                         result = (firstNum / secondNum);
  27.                         break;
  28.                     }
  29.             }
  30.  
  31.             API.sendChatMessageToPlayer(player, "[CALCULATOR] " + Convert.ToInt32(firstNum).ToString() + " " + mathType + " " + Convert.ToInt32(secondNum.ToString()) + " = " + result.ToString());
  32.  
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement