Author | Message | Time |
---|---|---|
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 | November 16, 2003, 11:35 PM |
St0rm.iD | [quote author=Makaveli link=board=17;threadid=3655;start=0#msg29589 date=1069025712] (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 [/quote] 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. [/quote] 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 [/quote] GJ, +1 | November 17, 2003, 12:19 AM |
Stealth | 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. [code]".adduser MyFriend IMOS" -> "IMOS"[/code] 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. :) | November 17, 2003, 12:24 AM |
Spht | 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. | November 17, 2003, 2:05 AM |
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 | November 17, 2003, 3:52 AM |