Raised This Month: $ Target: $400
 0% 

Set user flags from const...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unkolix
Veteran Member
Join Date: Sep 2012
Old 04-22-2013 , 08:16   Set user flags from const...
Reply With Quote #1

Can't try this, but will this work ok? Will this add all the flags in the const?
PHP Code:
new const FreeFlags[][] = {
    
"ADMIN_IMMUNITY""ADMIN_RESERVATION""ADMIN_CHAT"
}
/***/
public somefuction(id) {
    
set_user_flags(idFreeFlags)

Unkolix is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-22-2013 , 08:22   Re: Set user flags from const...
Reply With Quote #2

It won't, first off these are constants not strings and secondly you can't use array in the set_user_flags native.

Code:
new const FreeFlags[ ] = { ADMIN_IMMUNITY, ADMIN_RESERVATION, ADMIN_CHAT } public somefunction( id ) {       new iFlags       for( new i; i < sizeof FreeFlags; i ++ ) iFlags = iFlags | FreeFlags[ i ]       set_user_flags( id, iFlags ) }
Probably can be done better than using a loop but I have no idea about bitwise operators

Or a better way:

Code:
new const FreeFlags = ADMIN_IMMUNITY | ADMIN_RESERVATION | ADMIN_CHAT public somefunction( id ) {      set_user_flags( id, FreeFlags ) }

Last edited by Backstabnoob; 04-22-2013 at 08:25.
Backstabnoob is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 04-22-2013 , 08:23   Re: Set user flags from const...
Reply With Quote #3

Oh lol... I absolutely forgot about this...

Thanks!
Unkolix is offline
Sherazaa
Member
Join Date: Jun 2012
Old 04-23-2013 , 14:02   Re: Set user flags from const...
Reply With Quote #4

Why did you not do that :

Code:
new const FreeFlags = ADMIN_IMMUNITY & ADMIN_RESERVATION & ADMIN_CHAT

Why you set an OR BITWISE operator and not an AND BITWISE ?
__________________
[B]Bhop & Kz Player
Sherazaa is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 04-23-2013 , 15:11   Re: Set user flags from const...
Reply With Quote #5

Quote:
Originally Posted by Sherazaa View Post
Why did you not do that :

Code:
new const FreeFlags = ADMIN_IMMUNITY & ADMIN_RESERVATION & ADMIN_CHAT

Why you set an OR BITWISE operator and not an AND BITWISE ?
Bit-wise operators do not work according to their names.
Re-read the bitwise tutorial you would understand it
I think this will make you understand.
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-23-2013 , 15:24   Re: Set user flags from const...
Reply With Quote #6

PHP Code:
set_user_flags(id,read_flags("abcd....")); // And other flags 
Ps. These set_user_flags it will replate existing flags example:

If the player have "a" flag, its will replace again with a flag "a" i not understand the Optmization of this, so for remove the "z" user flag, it will used with a

PHP Code:
remove_user_flags(id,read_flags("z")); // Or others flags 

A better example:

If will turn a normal user admin with a flag "a", write this:

PHP Code:
set_user_flags(id,read_flags("a")); 
But the result is the player with these flags: "az"

so to remove the "z" flag, you need to:

PHP Code:
remove_user_flags(id,read_flags("z")); // Or others flags 
I not sure of this
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-23-2013 at 15:30.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Unkolix
Veteran Member
Join Date: Sep 2012
Old 04-23-2013 , 16:05   Re: Set user flags from const...
Reply With Quote #7

So I can do it like this?
PHP Code:
new g_flags
/***/
g_flags register_cvar("flags""abcde")
/***/
new flags[22]
get_pcvar_string(g_flagsflagscharsmax(flags));
set_user_flags(id,read_flags(flags)); 
Unkolix is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-23-2013 , 16:24   Re: Set user flags from const...
Reply With Quote #8

Yes perfectly...
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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:56.


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