Just Little Help

03/11/2012 02:44 shadowman123#1
well i was making smthing very Good which is Changing the Bound Cps Into Cps So i made it through Input panel and the player Enters the number of cps he wanna get inside the panel then get it ..anyways The Problem is that the Input can contains String So It Creates Error in Console Which leads to lag in the case when a Dumbass player Write his name or any Words So i'd like to make it like that when i enter String value including words or even letters it says to him Stop writting letters DumbAss and heres Example of my Code

Code:
else if (npcRequest.Input.Contains(what should i write here))
                                                {
                                                    dialog.Text(" Are You Fucken Dumb Write Just Numebrs ");
                                                    dialog.Option("Sorry", 255);
                                                    dialog.Send();
                                                }
is there Any easier way Than making new list containing Chars Then Calling the list Using Contain method ???
03/11/2012 03:43 _DreadNought_#2
Regex. Google it.
03/11/2012 04:28 shadowman123#3
Thx M8 i got Alot of informations About Regex and Sm other Stuffs that i needed to know :D Hopefuly i can use it
03/11/2012 12:44 { Angelius }#4
Try something like....
Quote:
else
{
int Result = 0;
if (int.TryParse(Amount.Tostring(), out Result ))
{
// Result is the money amount do something with it
}
else
{
dialog.Text(" Are You Fucken Dumb Write Just Numebrs ");
dialog.Option("Sorry", 255);
dialog.Send();
}
}
03/11/2012 17:25 samehvan#5
int Val=0;
try
{
Val=int.Parse(<the value he entered here>);
}
catch
{
dialog.Text(" Are You Fucken Dumb Write Just Numebrs ");
dialog.Option("Sorry", 255);
dialog.Send();
break;
}
<here your code if he entered a valid number>
03/11/2012 18:08 { Angelius }#6
Quote:
Originally Posted by samehvan View Post
int Val=0;
try
{
Val=int.Parse(<the value he entered here>);
}
catch
{
dialog.Text(" Are You Fucken Dumb Write Just Numebrs ");
dialog.Option("Sorry", 255);
dialog.Send();
break;
}
<here your code if he entered a valid number>
:facepalm:
03/11/2012 19:01 U2_Caparzo#7
Quote:
Originally Posted by { Angelius } View Post
:facepalm:
Hey thanks... y never used TryParse caz i didn't know when to use it,i just used try/catch or an string numbers = "1234567890" and a foreach(char C in AnyString) and then if !numbers.Contains(C) send msg error break; :s, thanks man :)