Dice Roll Chat Commands
Posted: Mon Apr 11, 2022 9:18 pm
Someone on the discord suggested adding dice rolls to the chat commands. An example:
This would allow anyone to roll literally and single dice at any time. IE, if you needed to roll a d2314, you could. Could also further parse it for multiple dice.
Code: Select all
else if (GetStringLeft(sSaid, 7) == "/roll d" && StringToInt(GetSubString(sSaid, 7, GetStringLength(sSaid))) != 0)
{
//maybe add while loop to make sure all characters after '/roll d' are numbers
int iDiceParsed = StringToInt(GetSubString(sSaid, 7, GetStringLength(sSaid)));
string sDiceParsed = IntToString(iDiceParsed);
int iDiceRoll = Random(StringToInt(sDiceParsed))+1;
SetPCChatMessage(COLOR_GOLD+sName+" rolled a d"+sDiceParsed+". The result was: "+IntToString(iDiceRoll)+COLOR_END);
return;
}