Raised This Month: $ Target: $400
 0% 

[HELP] Formatex error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 12-27-2015 , 16:13   Re: [HELP] Formatex error
Reply With Quote #1

Quote:
Originally Posted by Depresie View Post
Expected token "," but found ":" any ideea?


PHP Code:
    formatex(menucharsmax(menu), "\d%s [%L]"player_nameidzp_core_is_zombie(player
? (
LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" 
: (LibraryExists(LIBRARY_ASSASSINLibType_Library) && zp_class_assassin_get(player)) ? "CLASS_ASSASSIN" 
: (LibraryExists(LIBRARY_DRAGONLibType_Library) && zp_class_dragon_get(player)) ? "CLASS_DRAGON" 
: (LibraryExists(LIBRARY_TYRANTLibType_Library) && zp_class_tyrant_get(player)) ? "CLASS_TYRANT" 
: (LibraryExists(LIBRARY_ALPHALibType_Library) && zp_class_alpha_get(player)) ? "CLASS_ALPHA" 
"CLASS_ZOMBIE" 
: (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" 
: (LibraryExists(LIBRARY_SNIPERLibType_Library) && zp_class_sniper_get(player)) ? "CLASS_SNIPER" 
: (LibraryExists(LIBRARY_NINJALibType_Library) && zp_class_ninja_get(player)) ? "CLASS_NINJA" 
"CLASS_HUMAN"
Use more ((( and ))) to delimit arguments.
siriusmd99 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-27-2015 , 16:46   Re: [HELP] Formatex error
Reply With Quote #2

IMO, you should never do more than a couple nested ternary operators. If you need to do more than that, you should switch to an if-else-if structure to decide which one you will use and then pass the chosen one to formatex().

Using too many nested ternary operators unnecessarily obfuscates the code making it very difficult to understand.
__________________

Last edited by fysiks; 12-27-2015 at 17:52. Reason: Added link for the definition of ternary operator.
fysiks 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 18:08.


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