Parsing a string for admin flags
I just wrote a small function that I am assuming should work for checking multiple flags in a string, but when I pass it something like "abz" it doesnt. I dont mess with flags often so im assuming I made a mistake somewhere.
PHP Code:
|
Re: Parsing a string for admin flags
Hmm from the ReadFlagString function description (and looking at its c++ code in AdminCache.cpp), it should be able to handle a string of flags (in any order), so I doubt that's the problem. But your code looks fine to me (assuming you require the client have all of the listed flags in order to pass).
|
Re: Parsing a string for admin flags
edit
like this, if you pass the flags, and one of the flags, it's true your way = client needs all the flags both work just fine passing multiple flags. :D:D:D:D:D:D:D:D PHP Code:
like if a client has as flags (what my donators have), it will return true if you put in abz, false if they put in a bunch of flags they dont have (bcdefgz) the original way was returning true no mater what gibberish i put. i duno i think you wanted it to check for all them them i fail Edit never mind, your way works just fine for me, i forgot to take that root part out durr. I set my flags to as, passing as returns true, passing a returns true, passing as returns true, passing asb returns false. Ive been wanting to add a convar where someone could just put in sm_flags "abcd" and sm_flags_excusive 0/1 where they can say people with all these flags = admin, or people with 1 of these flags = admin. neat stuff. You obviously want an admin to have all flags for it to return true, *slaps self but hey i learned stuff thank you!!!!!!!!!! rep++ ahawhhawhaw Duno why you were having problems, seems to work fine depending how you set it up, a client needs just 1 of the flags, or all of the flags being passed, and it not mattering if you pass more than 1 flag. Edit not sure why im so hyper at 1:40 am, but wee |
Re: Parsing a string for admin flags
Try this out. I modified another stock that I wrote to handle flag strings instead of just bitflags.
PHP Code:
|
Re: Parsing a string for admin flags
Cool thanks guys.
|
Re: Parsing a string for admin flags
This is normally completely valid:
PHP Code:
But lets be clear here, there's one big problem: The root flag. GetUserFlagBits for a root user will return only root, not all flags and root. So if you were to test for 'abz', that's reservation, generic admin, and root. Its impossible to have all 3 of those bits at once. As a result, ReadFlagString("abz") will probably return (1<<0) | (1<<1) | (1<<14), but no one will have ALL those bits set at once, as I said above. Your function seems correct, just that having "abz" together is impossible. You've already covered the root user case. You should just be testing for "ab" not "abz". If they're root, it'll return true, else they need both ADMFLAG_RESERVATION and ADMFLAG_GENERIC at once. And if you want to test for root and root alone, you can just test for "z" and that should work. |
Re: Parsing a string for admin flags
Ive been using similar code for admin flag checks. I was not aware it could check for multiple flags. I had thought it was limited to just one flag? I guess it looks like thats what bl4nks post does.
|
Re: Parsing a string for admin flags
Quote:
Thanks bl4nk. New API Syntax: PHP Code:
|
| All times are GMT -4. The time now is 05:28. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.