Valhalla Legends Forums Archive | Battle.net Bot Development | Reading a list

AuthorMessageTime
Gangz
I am making an access list for my bot and i am puttin masters in Master.txt and operator in Op.txt and so on. I was wondering if i have a cmd look like
Case "IPB"
If upperusername = UCase(Form1.varmaster) Then Form1.Send "/ban " & Right(Message, (Len(Message) - 5))
If upperusername = UCase(Form1.varmaster) Then Form1.Send "/Ignore " & Right(Message, (Len(Message) - 5))

How can i make a it check a list of names from a txt and return a match as varmaster?
December 5, 2003, 7:41 AM
Smurfling
Well i would suggest you to read the textfile into an array. Then perform a check if the username is within the array.

I solved that for me through loading all data from a XML file into a SortedList. It's pretty easy to check if the username is in there (SortedList.ContainsKey(Username)). You can store much more information than just the username within the sortedlist (Values). Once you know the username is there, just get the index and the values. Pretty easy though.

Answer for your question would be so:
[code]
If SortedList.ContainsKey(Username) Then
Select Case CMD
Case cmdBan
Insert(Type.tNTString,"/ban " & cmdVar1 & " " & cmdVar2)
SendPacket(&HE)
End Select
End If
[/code]

You can replace the code within the if statement with your own code ;)
December 5, 2003, 10:36 AM
Fleet-
I used listboxes to store all the data which wouldnt be shifted around alot.

ie: Tagbans, Shitlist, Phrasebans, Access

Listboxes are fairly simple to read from as well. HOWEVER, they are not the best on speed, I may switch to variable arrays soon depending on how much the change impacts the ammount of memory my bot eats.

Also just as an idea...write a small send sub..and dont put it in form1 so you don't have to type "Form1.Send" every time.
December 5, 2003, 3:59 PM
Skywing
As a general practice, you should avoid using user-interface features for things completely unrelated to a user interface (e.g. as a data storage mechanism).
December 5, 2003, 4:05 PM
ObsidianWolf
I use an Access database for all my data besides channel logs, not entirely sure how efficient it is, but it saves time for me. If you would like info on how to do this just pm me.
December 5, 2003, 6:29 PM
Zakath
I use linked lists.
December 6, 2003, 11:50 PM
Fleet-
I recently just switched from listboxes to arrays, arrays are a bit more pain in the ass, but they are alot faster and less memory consuming.
December 10, 2003, 1:30 PM
Puzzle
[quote author=Fleet- link=board=17;threadid=4085;start=0#msg34586 date=1071063006]
I recently just switched from listboxes to arrays, arrays are a bit more pain in the ass, but they are alot faster and less memory consuming.
[/quote]

I'm not exactly sure how much faster switching from objects to arrays would make the program, but I'm pretty sure it's not enough to be noticable. Like Skywing said, it just isn't a good practice to use objects for data storage.
Edit: Spelling
December 10, 2003, 7:59 PM

Search