Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
UPdating Text Box
Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: UPdating Text Box

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    27

    UPdating Text Box

    I want to have a text box display the current exp. I would like it to update every 1 second and update the new exp to the text box. Im not sure how.




    Also, im trying to make an auto attacker (simple version). Right now it does work but it wont refresh to see it working, how do i refresh the "action" so it knows the box is enabled. It will attack the first monster but wont attack a second.

  2. #2
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    you can use simple winforms timers to update textbox's content

    Code:
                    int ms = 1000;
                    System.Windows.Forms.Timer expTimer = new System.Windows.Forms.Timer();
                    
                    expTimer.Interval = ms;
                    expTimer.Tick += (sender, e) => { expTextBox.Text = ReadExp().ToString(); };
                    expTimer.Start();
    supposing you have an expTextBox and a ReadExp function, ofc.

    You may get confused with line "expTimer.Tick += (SENDER, E) => ...", this is because I'm lazy and do not like to write something like:

    Code:
    expTimer.Tick += new System.EventHandler(expTimer_Tick);
    and somewhere write:
    Code:
    void expTimer_Tick(object sender, EventArgs e)
    {
          expTextBox.Text = ReadExp().ToString();
    }

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    27
    Quote Originally Posted by Blequi View Post
    you can use simple winforms timers to update textbox's content

    Code:
                    int ms = 1000;
                    System.Windows.Forms.Timer expTimer = new System.Windows.Forms.Timer();
                    
                    expTimer.Interval = ms;
                    expTimer.Tick += (sender, e) => { expTextBox.Text = ReadExp().ToString(); };
                    expTimer.Start();
    supposing you have an expTextBox and a ReadExp function, ofc.

    You may get confused with line "expTimer.Tick += (SENDER, E) => ...", this is because I'm lazy and do not like to write something like:

    Code:
    expTimer.Tick += new System.EventHandler(expTimer_Tick);
    and somewhere write:
    Code:
    void expTimer_Tick(object sender, EventArgs e)
    {
          expTextBox.Text = ReadExp().ToString();
    }





    Right now i have
    Code:
     Client C = Client.GetClients()[0];
                Player P;
    
                P = C.GetPlayer();
                richTextBox1.Text = (P.Experience.ToString());
    on the load to get the current exp. I am un certin on how to call it other wise.
    Last edited by athenso; 03-09-2013 at 04:02 AM.

  4. #4
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by athenso View Post
    I want to have a text box display the current exp. ...
    Quote Originally Posted by athenso View Post
    What is ur ReadExp().ToString();

    ?
    function that returns your character's experience

    EDIT:
    drop a timer from the toolbox to your form.
    double click it to add a ticker event

    update your richtextbox there
    Last edited by Blequi; 03-09-2013 at 04:09 AM.

  5. #5
    Junior Member
    Join Date
    Aug 2012
    Posts
    27
    Code:
     Client C = Client.GetClients()[0];
                Player P;
    
                P = C.GetPlayer();
    
                int ms = 1000;
                System.Windows.Forms.Timer expTimer = new System.Windows.Forms.Timer();
    
                expTimer.Interval = ms;
                expTimer.Tick += (sender, e) => { richTextBox1.Text = (P.Experience.ToString()); };
                expTimer.Start();
    This is what i have by the timer, and the Clinet c = client.getClinets() is throwing an error. and the tiker event im having an error with too. Sorry its been a long night.

  6. #6
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    if you are facing error in this function, probably you are not being able to find a client, so probably you indexing an array with no elements.

    looks like you are using tibiaapi, right? For what version are you using it? Error in "GetClients" is probably because you have not started up a Tibia before call it.

    paste full error here

  7. #7
    Junior Member
    Join Date
    Aug 2012
    Posts
    27
    + $exception {"Operation is not valid due to the current state of the object."} System.Exception {Tibia.Exceptions.NotLoggedInException}
    + this {Buster_Bot.BusterB, Text: Buster B.} Buster_Bot.BusterB
    ms 0 int
    expTimer null System.Windows.Forms.Timer
    + C {[8.70] Chaoss} Tibia.Objects.Client
    P null Tibia.Objects.Player


    Yes i am using TibiaAPI. Just want to build an OT helper. I do have a tibia client open and logged in when trying.

  8. #8
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    apparently, you are using an outdated version, since you are stating to be logged in, but on the other hand the bot is throwing an "NotLoggedInException".
    There's no much that I can do to help you.

  9. #9
    Junior Member
    Join Date
    Aug 2012
    Posts
    27
    I have it almost working now. I have
    Code:
    timer1.Tick +=  expTextBox.Text = ("Experience: " + P.Experience.ToString());
    and im getting an error, but if i can get that to work it should all work smoothly
    Last edited by athenso; 03-09-2013 at 05:20 AM.

  10. #10
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    You could always use a new thread, i.e:

    Import threading lib:
    Code:
    using Threading;
    Declare new thread in your class but not inside a function:
    Code:
    Thread myExpIncrementer;
    Declare new instance of a Thread based on ExpIncrementFunction (add this to formload):
    Code:
    myExpIncrementer = new Thread(ExpIncrementFunction);
    ExpIncrementFunction (Add this in class but not in a function):
    Code:
    public void ExpIncrementFunction()
    {
                while (true)
                {
                            this.Dispatcher.Invoke(delegate {
                                        expTextBox.Text= "Xp: " + P.Experience.ToString();
                            });
                            Thread.Sleep(1000);
                }
    }
    Add a button which will "start" the thread (Make a button, double click it, and insert this in the Button1_Click(objects sender, SystemEventArgs e) function):
    Code:
    myExpIncrementer.Start()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •