Raised This Month: $ Target: $400
 0% 

Booleans outputs integers?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-09-2018 , 03:29   Re: Booleans outputs integers?
Reply With Quote #1

g_bAdmin[id] = boolget_user_flags(id) & ADMIN_LEVEL_G) ? true:false;

As klippy said operator & is not a comparison operator.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 08-09-2018 , 03:33   Re: Booleans outputs integers?
Reply With Quote #2

Quote:
Originally Posted by Natsheh View Post
g_bAdmin[id] = bool:(get_user_flags(id) & ADMIN_LEVEL_G) ? true:false;

As klippy said operator & is not a comparison operator.
Does !! not work in AMX Mod X? Also, why are you tagging as bool something that is already bool? If your ternary operator is already returning true or false... the tag isn't necessary?

PHP Code:
g_bAdmin[id] = !!(get_user_flags(id) & ADMIN_LEVEL_G); 
Is this not valid in Amx?
__________________

Last edited by ddhoward; 08-09-2018 at 03:37.
ddhoward is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-09-2018 , 03:44   Re: Booleans outputs integers?
Reply With Quote #3

Quote:
Originally Posted by ddhoward View Post
Does !! not work in AMX Mod X? Also, why are you tagging as bool something that is already bool? If your ternary operator is already returning true or false... the tag isn't necessary?

PHP Code:
g_bAdmin[id] = !!(get_user_flags(id) & ADMIN_LEVEL_G); 
Is this not valid in Amx?
It works.

Quote:
Originally Posted by fatal_nl View Post
PHP Code:
// ... 
This wil give 262144 in chat. I thought booleans are supposed to give either true (1) or false (0).

EVERYTHING in this language is a 32-bit cell or an array of it. Integers, booleans, floats, strings and pointers, it's just all the same. Tags are there so the compiler can point out possible mistakes.
__________________

Last edited by Black Rose; 08-09-2018 at 03:57.
Black Rose 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 12:37.


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