AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simple Question (https://forums.alliedmods.net/showthread.php?t=131600)

GXLZPGX 07-06-2010 21:18

Simple Question
 
Was looking at this:
http://forums.alliedmods.net/showpos...53&postcount=2

Why did he use:

if (!(get_user_flags(id)&ADMIN_KICK))

Instead of:

if (!get_user_flags(id)&ADMIN_KICK)

Bugsy 07-06-2010 22:45

Re: Simple Question
 
Quote:

Originally Posted by GXLZPGX (Post 1230455)
Was looking at this:
http://forums.alliedmods.net/showpos...53&postcount=2

Why did he use:

if (!(get_user_flags(id)&ADMIN_KICK))

Instead of:

if (!get_user_flags(id)&ADMIN_KICK)

Though you as a scripter may know what you're attempting to do, the compiler does not. This is why you must follow order of operations and use parenthesis where needed. Here, parenthesis are needed because we want to evaluate the NOT value of the entire condition. Without parenthesis, the compiler will first evaluate the result of !get_user_flags(id) and then do a bit comparison with ADMIN_KICK.

GXLZPGX 07-06-2010 23:36

Re: Simple Question
 
Quote:

Originally Posted by Bugsy (Post 1230527)
Though you as a scripter may know what you're attempting to do, the compiler does not. This is why you must follow order of operations and use parenthesis where needed. Here, parenthesis are needed because we want to evaluate the NOT value of the entire condition. Without parenthesis, the compiler will first evaluate the result of !get_user_flags(id) and then do a bit comparison with ADMIN_KICK.

Fair enough. Thanks


All times are GMT -4. The time now is 07:15.

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