AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ~get_user_flags(id) & read_flags(flag) dosn't work (https://forums.alliedmods.net/showthread.php?t=261843)

OnePL 04-21-2015 16:31

~get_user_flags(id) & read_flags(flag) dosn't work
 
Why such use as in title of topic doesn't work?

Example:
PHP Code:

#define userFlags(%0,%1) get_user_flags(%0) & read_flags(%1)

public TakeDamage(identattackerFloat:damage) {
    if(!
is_user_connected(id) || !is_user_connected(attacker) || ~userFlags(attacker"s, v") || get_user_team(attacker) != 2) return 1;

    if(
GetUserWeapon(attacker) == 28 || GetUserWeapon(attacker) == 22) {
        
SetHamParamFloat(4damage 2.0);
        return 
2;
    }
    return 
1;



Bos93 04-21-2015 17:22

Re: ~get_user_flags(id) & read_flags(flag) dosn't work
 
~userFlags(attacker, "sv")

OnePL 04-21-2015 17:39

Re: ~get_user_flags(id) & read_flags(flag) dosn't work
 
No. Then the player will have to have both flags.
, = or in read_flags

!(userFlags(attacker, "s, v")) working
~userFlags(attacker, "s, v")) not working

jimaway 04-21-2015 20:15

Re: ~get_user_flags(id) & read_flags(flag) dosn't work
 
lets say that the "attacker" has both flags and userFlags macro returns 4 (binary 0100)

! is a logical operator. !4 will result false
~ is a bitwise operator. ~0100 will result in 1011 (decimal 11) and that is still considered true in the if statement

Bugsy 04-23-2015 20:28

Re: ~get_user_flags(id) & read_flags(flag) dosn't work
 
Use has_all_flags()

In your case, you would use !has_all_flags( id , "sv" )


All times are GMT -4. The time now is 08:48.

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