Register for your free account! | Forgot your password?

You last visited: Today at 11:22

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Just Little Help

Discussion on Just Little Help within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Just Little Help

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 ???
shadowman123 is offline  
Old 03/11/2012, 03:43   #2
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Regex. Google it.
_DreadNought_ is offline  
Thanks
1 User
Old 03/11/2012, 04:28   #3
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Thx M8 i got Alot of informations About Regex and Sm other Stuffs that i needed to know Hopefuly i can use it
shadowman123 is offline  
Old 03/11/2012, 12:44   #4
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
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();
}
}
{ Angelius } is offline  
Thanks
2 Users
Old 03/11/2012, 17:25   #5
 
elite*gold: 20
Join Date: Jul 2007
Posts: 613
Received Thanks: 486
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>
samehvan is offline  
Old 03/11/2012, 18:08   #6
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
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>
{ Angelius } is offline  
Old 03/11/2012, 19:01   #7
 
U2_Caparzo's Avatar
 
elite*gold: 0
Join Date: Aug 2011
Posts: 314
Received Thanks: 90
Quote:
Originally Posted by { Angelius } View Post
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
U2_Caparzo is offline  

Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.