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 archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Auto-open bodies [Archive] - Forums

PDA

View Full Version : Auto-open bodies



poopsiedoodle
04-14-2014, 03:08 AM
I'm just gonna put this as simply as possible. This is my code for auto-opening bodies. It doesn't work, and I don't know why. So, I need help figuring out what I'm doing wrong (other than not being able to condense the 17859643832689765329847562038476 loops). Halp pl0x. (NOTE: I am using TibiaAPI) (NOTE2: My.Settings.deadlocs is just a stringcollection) (NOTE3: c = client, p = player) (NOTE4: I knew less about programming when I wrote this code than I do now, but I still have no idea what the hell I'm doing with this one)


My.Settings.deadlocs.Clear()
For Each dead As Creature In c.BattleList.GetCreatures
If dead.HPBar = 0 Then
My.Settings.deadlocs.Add(dead.Location.ToString)
For Each bodyloc As String In My.Settings.deadlocs
For Each square As Tile In c.Map.GetTiles
If square.Location.ToString = bodyloc Then
For Each deadbody As Item In square.Items
If deadbody.Data.Name.Contains("Dead") Or deadbody.Data.Name.Contains("Slain") Or deadbody.Data.Name.Contains("Remains") Then
p.Walk(bodyloc)
c.Inventory.UseItemOnTile(deadbody.Id, square)
Lootitems()
End If
Next
End If
Next
Next
End If
Next

I also tried


Private Function openbodies2()
Dim list As New List(Of body)
For Each dead As Creature In c.BattleList.GetCreatures
If dead.HPBar = 0 Then
Dim t As Tile = c.Map.GetTile(dead.Location)
Thread.Sleep(200)
Dim b As New body(t.Items.Find(Function(x) x.Data.Name.ToString.ToLower.StartsWith("dead ") Or x.Data.Name.ToString.ToLower.StartsWith("slain ") Or x.Data.Name.ToString.ToLower.StartsWith("remains ") And x.GetFlag(Addresses.DatItem.Flag.IsCorpse) = True).Id, dead.Location, False)
b.itemname = c.Map.GetTile(dead.Location).Items.Find(Function(x ) x.Data.Name.ToString.ToLower.StartsWith("dead ") Or x.Data.Name.ToString.ToLower.StartsWith("slain ") Or x.Data.Name.ToString.ToLower.StartsWith("remains ") And x.GetFlag(Addresses.DatItem.Flag.IsCorpse) = True).Name
list.Add(b)
End If
Next
For Each b As body In list
Dim i As New Item(b.ID, b.itemname)
i.OpenAsContainer(CByte(c.Inventory.GetContainers( ).Count()))
Lootitems()
Next
Return True
End Function

but got the error "Object reference not set to an instance of an object." where it checks the item flag the first time, which I think generated after the bot froze after I killed something, but failed to show until I switched to the Visual Basic window.