Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 07-25-2006, 11:02 AM   #1 (permalink)
Forum Novice
 
Join Date: Jun 2005
Location: Turkey
Age: 24
Posts: 105
Default Char or word ignoring in a textbox

I work on a script which included textbox but i want some chars or word in the textbox give a warning if this is a easyuo script i was used
Code:
 if ( "idontwant" in textbox )
doaction
but in c# i cant do that always give error please tell me a way for this....
__________________
:confused: Why Dark Jedis Use Light Saber :confused:
hollysong is offline   Reply With Quote
Old 07-25-2006, 01:13 PM   #2 (permalink)
Forum Expert
 
Join Date: Aug 2004
Location: Redmond, WA
Age: 21
Posts: 1,288
Send a message via AIM to Sep102 Send a message via MSN to Sep102
Default

That's because in C# the "in" keyword is meant to only be used as part of a foreach statement, not to test if a value is a part of a sequence. Also, when using the TextBox class, you cannot treat instances of it as a String, you need to use the Text property (so, textbox.Text, instead of textbox).

Now, what you're looking for is something along the lines of the Contains() method of the String class, which finds a given substring in the string. So to find a substring in the text of a textbox, it would be of the form
Code:
textbox.Text.Contains("substring")
Sep102 is offline   Reply With Quote
Old 07-26-2006, 03:04 AM   #3 (permalink)
Forum Novice
 
Join Date: Jun 2005
Location: Turkey
Age: 24
Posts: 105
Default

so can i use this in runuo server gumps?
__________________
:confused: Why Dark Jedis Use Light Saber :confused:
hollysong is offline   Reply With Quote
Old 07-26-2006, 03:26 PM   #4 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

in gumps sent to the client? I dont think gumps are able to do anything put output and receive input. So you would have to check if what they enters contains the criteria once they submit it and if it contains it, do whatever you need to do.
mordero is offline   Reply With Quote
Old 07-27-2006, 10:40 AM   #5 (permalink)
Forum Novice
 
Join Date: Jun 2005
Location: Turkey
Age: 24
Posts: 105
Default

yes i send to client but i cant do if you know please show me a sample...
__________________
:confused: Why Dark Jedis Use Light Saber :confused:
hollysong is offline   Reply With Quote
Old 07-27-2006, 12:22 PM   #6 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,760
Default

if( textbox.Text.IndexOf( "words or char u dont want" ) != -1 )
DoAction();
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 07-28-2006, 08:15 PM   #7 (permalink)
Forum Novice
 
Join Date: Jun 2005
Location: Turkey
Age: 24
Posts: 105
Default

Thanx Jeff but i cant use this in a gump.

I need this for use at password change gump my players made a mistake use turkish chars in password and client does not support to write and people cant login to server..
__________________
:confused: Why Dark Jedis Use Light Saber :confused:
hollysong is offline   Reply With Quote
Old 07-31-2006, 12:54 PM   #8 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,760
Default

Quote:
Originally Posted by hollysong
Thanx Jeff but i cant use this in a gump.

I need this for use at password change gump my players made a mistake use turkish chars in password and client does not support to write and people cant login to server..
u can use this in a gump...you owuld just grab the text from the textentry and run that same if on it.
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 07-31-2006, 06:44 PM   #9 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

Ok, never used gumps before in my life, but use the concept of what Jeff said, not the exact code. In your script though, it would be in the OnResponse function and would be similar to this (I think lol):

PHP Code:
OnResponse(Server.Network.NetState senderRelayInfo info)
{
    
//do whatever you need to get to this point

    
TextRelay passEntry info.GetTextEntry(0);
    
TextRelay passVerify info.GetTextEntry(1);

    
string pEntry = ( passEntry == null null passEntry.Text.Trim() );
    
string pVerify = ( passVerify == null null passVerify.Text.Trim() );

    
//do whatever to make sure they are the same

    //now check for the char or phrase
    
if (pEntry.IndexOf("words or char u dont want") != -1)
        {
            
//Do Action
        
}

I think the concept of all that is what you want, but youll of course have to test it and all that (especially since ive never worked with gumps before). Hope this helps
mordero is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5