• Welcome to Valhalla Legends Archive.
 

2 VB questions

Started by Makaveli, November 16, 2003, 05:35 PM

Previous topic - Next topic

Makaveli

(In VB 6.0) I have 2 questions
1. Which is faster or just all around more efficient to use for a queue/method to find a users access: Listview, Listbox, or Collection

2. I'm working on a bot with a flag-based access system.  I want to have 3 flags that can each add specific flags, but not the sames flags as the other.  Here's an example of what i need help with: (With flags: A, B, I, M, O, S, T) I want to make it so that only users with O can add B flag, A can add I, S, and T, and M can add A.  Now how would I go about setting these flag restrictions during an ".adduser" command, and during this situation: User has A flag only, and sends - .adduser MyFriend IMOS - How would i make it so that the bot only adds MyFriend "IS" and not any of the other flags included.

I did try a search and I'm not sure exactly how to phrase the search for either, which is why I'm asking for help.  Thanks in advance

Banana fanna fo fanna

Quote from: Makaveli on November 16, 2003, 05:35 PM
(In VB 6.0) I have 2 questions
1. Which is faster or just all around more efficient to use for a queue/method to find a users access: Listview, Listbox, or Collection
Collection. Don't use GUI controls for anything not meant to be GUI.
Quote
2. I'm working on a bot with a flag-based access system.  I want to have 3 flags that can each add specific flags, but not the sames flags as the other.  Here's an example of what i need help with: (With flags: A, B, I, M, O, S, T) I want to make it so that only users with O can add B flag, A can add I, S, and T, and M can add A.  Now how would I go about setting these flag restrictions during an ".adduser" command, and during this situation: User has A flag only, and sends - .adduser MyFriend IMOS - How would i make it so that the bot only adds MyFriend "IS" and not any of the other flags included.
1) Get the flags of the user that issued the commands
2) Iterate through each flag after the .adduser command
3) For each flag, test whether the issuer has a certain flag (i.e. "O")
4) If the test is successful, add the flag.
Quote
I did try a search and I'm not sure exactly how to phrase the search for either, which is why I'm asking for help.  Thanks in advance

GJ, +1

Stealth

#2
1. I would think a collection is fastest because it doesn't need to store or deal with any of the unused properties of a listbox/view.

2. I would accomplish this as follows:

A. Find the access the user is trying to set the add target to.
".adduser MyFriend IMOS" -> "IMOS"
This can be accomplished using VB's Split() function or InStr() and Mid$().

B. Analyze each one of the flags the user is trying to add individually using Mid$(string, counter, 1).

C. For each of the flags, I would see if the user has the access necessary to set that flag. If they don't have enough access, I would proceed to the next flag; otherwise, the flag would be appended to a buffer holding the user's successful flag changes.

D. Use the buffer to modify the target user's access in your database. If it's null, it means that no changes were successful, and you should inform your user accordingly.

Hope that helps.

EDIT: It appears St0rm beat me to it. Oh well. :)
- Stealth
Author of StealthBot

Spht

#3
I suggest treating flags in Zerobot Traditional Flags Format (ZTFF) -- this meaning that 'A' = 1, 'B' = 2, 'C' = 4, D = '8', etcetera. You can then treat attributes as bitmask operators which makes adding/subtracting attributes much easier.

This will take care of your repeated attribute problem also.

Makaveli

I planned on using a For statement to identify each flag being set but I'm not sure what I'm setting it to look for, unless I'm just overthinking it and the answer is about as obvious as it gets