Raised This Month: $ Target: $400
 0% 

get_user_flags question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
twix_p
Member
Join Date: Jul 2011
Old 01-15-2014 , 10:00   get_user_flags question
Reply With Quote #1

Hi, I'm wondering how can I get user flags into a global variable like g_cPlayerFlags[ 33 ][ 32 ];

not like this: new iFlags = get_user_flags( iPlayer )

Last edited by twix_p; 01-15-2014 at 10:01.
twix_p is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 01-15-2014 , 13:43   Re: get_user_flags question
Reply With Quote #2

PHP Code:
 //get_flags - Converts a sum of bits into a string. 
// get_flags ( flags, output[], len ) 

 
new players[32], iNumiFlags 
get_players
(playersiNum"c")
for(new 
i;i<iNum;i++) {
        
iFlags get_user_flags(players[i])
        
get_flags(iFlagsg_cPlayerFlags[i], sizeof (cPlayerFlags) - 1

Last edited by DWIGHTpN; 01-18-2014 at 14:01.
DWIGHTpN is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-15-2014 , 16:54   Re: get_user_flags question
Reply With Quote #3

Explain exactly what your trying to do.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 01-15-2014 at 16:54.
hornet is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-16-2014 , 00:48   Re: get_user_flags question
Reply With Quote #4

If you want to always have strings filled (i doubt you need, that's why you have to clearly explain why you want this) :

PHP Code:
new g_szUsersFlags[32][27];

public 
client_infochanged(id)
{
    if( 
is_user_connected(id) && !is_user_bot(id) )
    {
        
get_flags(get_user_flags(id), g_szUsersFlags[id], charsmaxg_szUsersFlags[] ));
    }

Or if you want to print it some times :

PHP Code:
Some_Functionid )
{
    new 
szStringFlags[27];
    
get_user_flags_string(idszStringFlagscharsmax(szStringFlags));
    
client_print(idprint_chat"Your flags are : %s"szStringFlags);
}

get_user_flags_string(idszFlags[], len)
{
    return 
get_flags(get_user_flags(id), szFlagslen);


Also, if you are learning amxx coding, you should have wondered where you could have find the solution by yourself, so you should have thought about amx_who command that is showing players flags as strings in player console, and then you should have browse its plugin source.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
twix_p
Member
Join Date: Jul 2011
Old 01-16-2014 , 13:56   Re: get_user_flags question
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
If you want to always have strings filled (i doubt you need, that's why you have to clearly explain why you want this) :

PHP Code:
new g_szUsersFlags[32][27];

public 
client_infochanged(id)
{
    if( 
is_user_connected(id) && !is_user_bot(id) )
    {
        
get_flags(get_user_flags(id), g_szUsersFlags[id], charsmaxg_szUsersFlags[] ));
    }

It its perfect, thank you so much, I did not know about get_flags native.
twix_p is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 01-16-2014 , 06:23   Re: get_user_flags question
Reply With Quote #6

Did you know that in structure (1 << K), K might be from 0 to 31? If you don't want more than 32 characters, then a numerical variable is enough.

In case you have more than 32 characters, you should do something like this:

new Flags[33][128];
new Client = GetRandomClient(); // an example.
formatex(Flags[Client], charsmax(Flags[]), "%s", "abcdefghijklmnopqrstu1234567890-=\[];',./_+|{}:^"<>?`~!@#$%^^&*()"); // note that ^" means " and ^^ means ^ for real, in a string.
if (containi(Flags[Client], "#") != -1) { // client got # flag. }
__________________

Last edited by claudiuhks; 01-16-2014 at 06:34.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-16-2014 , 14:39   Re: get_user_flags question
Reply With Quote #7

Quote:
Originally Posted by claudiuhks View Post
Did you know that in structure (1 << K), K might be from 0 to 31? If you don't want more than 32 characters, then a numerical variable is enough.

In case you have more than 32 characters, you should do something like this:

new Flags[33][128];
new Client = GetRandomClient(); // an example.
formatex(Flags[Client], charsmax(Flags[]), "%s", "abcdefghijklmnopqrstu1234567890-=\[];',./_+|{}:^"<>?`~!@#$%^^&*()"); // note that ^" means " and ^^ means ^ for real, in a string.
if (containi(Flags[Client], "#") != -1) { // client got # flag. }
Yes, already made something like this on forum, but get_flags and (or, don't remember) read_flags doesn't support it, you have convert those natives.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 10:11.


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