07.07.2014, 07:53
I just made this. Don't know if it works. But it is more user-friendly.
pawn Код:
CMD:calculate(playerid, params)
{
new num1, operation[1], num2;
if(sscanf(params, "ici", num1, operation, num2)) return SendClientMessage(playerid, -1, "USAGE: /calculate [number1] [+,-,*,/] [number2]");
new str[128];
if(!strcmp("+", operation)) format(str, sizeof(str), "%i added to %i equals %i", num1, num2, num1 + num2);
else if(!strcmp("-", operation)) format(str, sizeof(str), "%i subtracted from %i equals %i", num2, num1, num1 - num2);
else if(!strcmp("*", operation)) format(str, sizeof(str), "%i multiplied by %i equals %i", num1, num2, num1 * num2);
else if(!strcmp("/", operation)) format(str, sizeof(str), "%i divided by %i equals %i", num1, num2, num1 / num2);
else return SendClientMessage(playerid, -1, "You didn't put a valid operator. Valid operators are +, -, /, *");
SendClientMessage(playerid, -1, str);
return true;
}