AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_flags question (https://forums.alliedmods.net/showthread.php?t=233457)

twix_p 01-15-2014 10:00

get_user_flags question
 
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 )

DWIGHTpN 01-15-2014 13:43

Re: get_user_flags question
 
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


hornet 01-15-2014 16:54

Re: get_user_flags question
 
Explain exactly what your trying to do.

ConnorMcLeod 01-16-2014 00:48

Re: get_user_flags question
 
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.

claudiuhks 01-16-2014 06:23

Re: get_user_flags question
 
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. }

twix_p 01-16-2014 13:56

Re: get_user_flags question
 
Quote:

Originally Posted by ConnorMcLeod (Post 2086586)
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.

ConnorMcLeod 01-16-2014 14:39

Re: get_user_flags question
 
Quote:

Originally Posted by claudiuhks (Post 2086664)
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.


All times are GMT -4. The time now is 10:11.

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