Raised This Month: $51 Target: $400
 12% 

Get AdminFlagChar from AdminBitFlags?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 04-07-2017 , 12:15   Get AdminFlagChar from AdminBitFlags?
Reply With Quote #1

well, i kind of noob of this but i know if i'm gonna do it my way, it takes a year to complete and a huge size of file for the plugin, so this is how i get it for a single flag:
Spoiler

but i have realized that if if use 2 or 3 flags like abc it will return 7 (which is undefined here and is 1 + 2+ 4), is there any way to not do this that way? i mean if i want to do this that way i have to define all flags and 2 by 2 3 by 3 and .... and it's gonna take a year, any better ways?
__________________

Last edited by ambn; 04-07-2017 at 12:16.
ambn is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-07-2017 , 12:56   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #2

Try: FlagBitsToArray then concatenate the flag letter (mapped to AdminFlag) onto char array, once that's done, you got a complete flag string.

Edit: To get ascii map, read admin_levels.cfg with SMCParser and calling either FindFlagByChar or FindFlagByName
Edit2: FindFlagChar is better.
__________________

Last edited by WildCard65; 04-08-2017 at 07:20.
WildCard65 is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 04-07-2017 , 13:52   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #3

Quote:
Originally Posted by WildCard65 View Post
Try: FlagBitsToArray then concatenate the flag letter (mapped to AdminFlag) onto char array, once that's done, you got a complete flag string.

Edit: To get ascii map, read admin_levels.cfg with SMCParser and calling either FindFlagByChar or FindFlagByName
I'll try this soon and will tell you whether i could make it work or not
Thanks for the help
__________________
ambn is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 04-07-2017 , 14:12   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #4

Can you come up with some examples? if possible?
__________________
ambn is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 04-08-2017 , 02:19   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #5

I'm not sure if i'm doing it right or wrong but this is how i did it and it's returning empty, any help?
PHP Code:
Handle g_adtArray[MAXPLAYERS+1] = INVALID_HANDLE;
char GetUserCFlags(int clientchar StrFlag[16])
{
    
int UserFlagBits GetUserFlagBits(client);
    
char Flag[16];
    
g_adtArray[client] = CreateArray(32);
    
FlagBitsToArray(UserFlagBitsg_adtArray[client], 32);
    
GetArrayString(g_adtArray[client], 32Flagsizeof(Flag))
    
Format(StrFlagsizeof(StrFlag), Flag);

__________________
ambn is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-08-2017 , 03:50   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #6

I don't know where you got the idea to involve an ADT array, read the API doc on FlagBitsToArray.
__________________
asherkin is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 04-08-2017 , 04:27   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #7

Quote:
Originally Posted by asherkin View Post
I don't know where you got the idea to involve an ADT array, read the API doc on FlagBitsToArray.
I don't know how to use that and how should it be formed , so maybe you can give me some examples of codes for better understanding?
__________________

Last edited by ambn; 04-08-2017 at 04:28.
ambn is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-08-2017 , 06:14   Re: Get AdminFlagChar from AdminBitFlags?
Reply With Quote #8

Haven't tested it, but I think this should do it:

PHP Code:
public int GetFlagString(int clientchar[] flagStringint flagStringLength) {
    
int flagBits GetUserFlagBits(client);
    
    
AdminFlag flags[26];
    
int numFlags FlagBitsToArray(flagBitsflagssizeof(flags));
    
    if ((
numFlags 1) < flagStringLength) {
        
flagString[0] = '\0';
        return -
1;
    }
    
    
int i;
    for (
0numFlags; ++i) {
        
int flagChar// FindFlagChar has a bad type for the 2nd param.
        
FindFlagChar(flags[i], flagChar);
        
flagString[i] = flagChar;
    }
    
flagString[i] = '\0';
    
    return 
numFlags;

__________________
asherkin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode