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
New on c#
Results 1 to 3 of 3

Thread: New on c#

  1. #1

    New on c#

    What is the problem? why returns player name = ""?

    Code:
    public static string Name
            {
                get
                {
                    string result = "";
                    dynamic @base = Bot.Main.Tibia.MainModule.BaseAddress.ToInt32();
                    int PlayerID = Memory.Memory.ReadInt32(Bot.Main.Tibia.Handle, 0x9d5034 + @base - 0x400000);
                    int bStart = 0xa2bf40 + @base - 0x400000;
                    int bStep = 0xdc;
                    int bMax = 1299;
                    int bEnd = bStart + (bStep * bMax);
                    int pConnected = 0x849eec + @base - 0x400000;
                    for (int i = bStart; i <= bEnd; i += bStep)
                    {
                        int CurrentID = Memory.Memory.ReadInt32(Bot.Main.Tibia.Handle, i);
                        if (CurrentID == PlayerID)
                        {
                            result = Memory.Memory.ReadString(Bot.Main.Tibia.Handle, i + 4);
                            return result;//Memory.Memory.ReadString(Bot.Main.Tibia.Handle, i + 4);
                        }
                        return result;
                    }
                    return result;
                }   
    
                set { }
               
            }
    And in my code to Client Chooser, return player name.

    Code:
    public void Refresh()
            {
                try
                {
                    listView1.Items.Clear();
                   
                    foreach (Process client in Process.GetProcessesByName("tibia"))
                    {
                        if (client.MainModule.FileVersionInfo.FileVersion == "10.7.8.0")
                        {
                            dynamic @base = client.MainModule.BaseAddress.ToInt32();
                            int PlayerID = Memory.Memory.ReadInt32(client.Handle, 0x9d5034 + @base - 0x400000);
                            int bStart = 0xa2bf40 + @base - 0x400000;
                            int bStep = 0xdc;
                            int bMax = 1299;
                            int bEnd = bStart + (bStep * bMax);
                            int pConnected = 0x849eec + @base - 0x400000;
                            for (int i = bStart; i <= bEnd; i += bStep)
                            {
                                int CurrentID = Memory.Memory.ReadInt32(client.Handle, i);
                                if (CurrentID == PlayerID)
                                {
                                    if (Memory.Memory.ReadInt32(client.Handle, pConnected) == 11)
                                    {
                                        ListViewItem newitem = new ListViewItem();
                                        newitem.Text = client.Id.ToString();
                                        newitem.SubItems.Add(client.MainModule.FileVersionInfo.FileVersion.ToString());
                                        newitem.SubItems.Add(Memory.Memory.ReadString(client.Handle, i + 4));
                                        listView1.Items.Add(newitem);
                                        //comboBox1.Items.Add(client.Id.ToString() + " | " + client.MainModule.FileVersionInfo.FileVersion.ToString() + " | " + Memory.Memory.ReadString(client.Handle, i + 4));
                                        break; // TODO: might not be correct. Was : Exit For
                                    }
                                    else
                                    {
                                        ListViewItem newitem = new ListViewItem();
                                        newitem.Text = client.Id.ToString();
                                        newitem.SubItems.Add(client.MainModule.FileVersionInfo.FileVersion.ToString());
                                        newitem.SubItems.Add("Not connected");
                                        listView1.Items.Add(newitem);
                                        //comboBox1.Items.Add(client.Id.ToString() + " | " + client.MainModule.FileVersionInfo.FileVersion.ToString() + " | Not connected");
                                        break; // TODO: might not be correct. Was : Exit For
                                    }
                                }
                            }
                        }
                        else
                        {
                            ListViewItem newitem = new ListViewItem();
                            newitem.Text = client.Id.ToString();
                            newitem.SubItems.Add(client.MainModule.FileVersionInfo.FileVersion.ToString());
                            newitem.SubItems.Add("Invalid version");
                            listView1.Items.Add(newitem);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }

  2. #2
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Probably, return statement right after the if block should not exist

  3. #3
    Why you're not using "int baseA" ?

    Dynamic variables can be converted to a double value in some cases, since C# will pick the "best" object type even converting .ToInt32()

Posting Permissions

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