Hello! Trav you were on the right track, however, you missed something.
A player could easily just say 2d and it would work (it would multiply), or they could say M1 or 1M (capital m is not checked for).
The solution is very simple: for the first problem just check each letter of the text one by one in your for loop I'll show you what I mean in a second.
For the second problem: simply add capital letters to your array. (Not doing this one, too lazy)
PHP Code:
function onCreated() {
showcharacter();
this.head = "head0.png";
this.colors[0] = "orange";
this.colors[1] = "white";
this.colors[2] = "blue";
this.colors[3] = "red";
this.colors[4] = "black";
this.shield = "no-shield.png";
this.dir = 2;
this.nick= "Kirzey";
this.chat = "Tell me the diameter (in centimers) of the circle which it's circumference you want to know?";
setcharani("sit",null);
}
function onPlayerChats() {
temp.l = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j","k","l","m","o","p","q","r","s","t","u","v","w","x","y","z","!","@","#","$","%","^","&","*","(",")","{","}","[","]"};
temp.chat = player.chat;
for (temp.n = 0; temp.n <= 26; temp.n ++) {
temp.c = player.chat.substring(temp.n, temp.n);
if (temp.c in temp.l) { //if a letter is in the chat it will check off as true, therefore not working when someone says 1d or 8943748374m
this.chat = "Only numbers!";
return;
}
if (temp.chat.pos(temp.l[temp.n])>=0) {
this.chat = "Only numbers!";
return;
}else{ //Else, if the players chat starts by a number
this.chat = player.chat * pi; //Multiply the players chat by Pi
}
}
}
I added symbols in there for you, but got bored of that so I only put a few.
I didn't add capital letters to the array, but I'm sure you can figure that out or already know how to do it.
The magic lies here:
PHP Code:
for (temp.n = 0; temp.n <= 26; temp.n ++) {
temp.c = player.chat.substring(temp.n, temp.n);
if (temp.c in temp.l) {
I assume you know what everything I changed does, but if you don't just ask.
I'll be more than happy to help!
With many spelling and grammar mistakes,
-Zep