Author | Message | Time |
---|---|---|
TriCk | Ok heres the thing... I got AutoBans working ... but i need help to not ban ppl that are on a List (users.ini) which i have got Loading and Saving to a ListBox.... how could i Protect the ppl in that INI file? - TriCk | May 22, 2003, 9:47 AM |
laurion | check if they're in the list box (instr) and if they are, dont ban. if they arent, ban. ^^ | May 22, 2003, 10:31 AM |
Stealth | It seems to me that a listbox would be a significant waste of RAM. Try a dynamic array instead... On startup, and whenever else you need it, call a function that does the following in a loop: 1. Read a name out of the text file and into a temporary string. 2. Apply the temporary string (LCase()d, perhaps?) to a dynamic array you have declared publicly somewhere in your code. 3. Resize the array so that it may include the next name. Depending on how you choose to do things, 2. and 3. can be switched. Close the loop when the file has been completely read, and you now have a safelist. Whenever you need to check it, loop through it using a For...Next loop and compare each member of the array to the username you're checking. Be sure to check the following before attempting the above file access: 1. Does the file exist? If it doesn't, it will return File Not Found. 2. If it exists, then is it empty? An empty file will return Input Past End of File if you try to read out of it. Useful file access and array navigation functions: (Plug them into Google or MSDN to find out more) LOF() EOF() UBound() and LBound() Best of luck. | May 22, 2003, 9:25 PM |
TriCk | Stealth I downloaded your 1.4 code so it says from some site... And is the Safelist ur referring to in ur code ? Because im not familiar with arrays and i'd like to see some code to see how its used... I know EOF() = End Of File but thats about it :( - TriCk | May 23, 2003, 5:30 AM |
Noodlez | [code]Dim strArray() As String[/code] ^--- That's an array Want to add data to it? First, allocate some slots. [code]ReDim strArray(1 to 5)[/code] Now access the members of the array simply by entering it's index in parathensis. [code]strArray(1) = "hi" MsgBox strArray(1) [/code] The resulting value will be a message box containing "Hi" If you want to add additional indexes to an array, simply add a Preserve after ReDim [code]ReDim Preserve strArray(1 to 20)[/code] | May 23, 2003, 6:00 AM |
TriCk | Ok thats all good and all... I get how it works sorta, but if i want to read from a txt file how do i do that with arrays? | May 23, 2003, 12:02 PM |
CupHead | I've found that the easiest way to read from text files is using the TextStream objects. They're relatively recent, but they allow you to read files by line or all at once rather easily. This isn't actual VB code, but it gives you the idea of how to use them: [code] TextStreamObject = FileSystemObject.OpenTextFile(App.Path & "\MyFile.txt") 'Read the whole thing and then split by line Dim WholeFile as String Dim WholeArray() as String WholeFile = TextSteamObject.ReadAll WholeArray = Split(WholeFile, vbCrLf) 'Read line by line into a dynamically sized array Dim LineArray() as String Dim LineCounter as Integer/Long LineCounter = 0 ReDim LineArray(0) Do While Not TextStreamObject.EOF LineArray(LineCounter) = TextSteamObject.ReadLine LineCounter = LineCounter + 1 ReDim Preserve LineArray(LineCounter) Loop [/code] MSDN is probably your best bet for a reference on how to use these. (Suggest searching for OpenTextFile Method) The only problem with these methods is that Norton (or was it McAfee) detects the usage of OpenTextFile as potentially harmful. | May 23, 2003, 2:30 PM |
TriCk | hmm do i put that as a function or a sub ? how do i load that like when CleanSlateBot_UserJoins If Username = ... Then 'Don't Ban ElseIf Username = Username Then CleanSlateBot.Send "/ban " & Username Sorta thing how do i check that list for the username ?? | May 24, 2003, 12:03 AM |