Raised This Month: $ Target: $400
 0% 

[HELP] Formatex error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-27-2015 , 11:37   [HELP] Formatex error
Reply With Quote #1

Expected token "," but found ":" line 354, 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"
The first one is edited by me
The second one is the original
Attached Files
File Type: sma Get Plugin or Get Source (zp50_admin_menu.sma - 585 views - 17.8 KB)
__________________

Last edited by Depresie; 12-27-2015 at 16:43.
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-27-2015 , 11:48   Re: [HELP] Formatex error
Reply With Quote #2

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"
It hurts my eyes too much to find where the error is in that line. I'm guessing you did not write that, so I would grab the original and work from there. It's probably missing a parenthesis (parenthesi?) somewhere.
__________________
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-27-2015 , 12:04   Re: [HELP] Formatex error
Reply With Quote #3

i wrote it... i checked 10 times, didnt miss anything..
i wrote it using this pattern, which works ->

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" 
"CLASS_ZOMBIE" 
: (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" 
"CLASS_HUMAN"
for better visibility
__________________

Last edited by Depresie; 12-27-2015 at 12:09.
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-27-2015 , 12:13   Re: [HELP] Formatex error
Reply With Quote #4

I would try to avoid lines that long. If it's one or two conditions where you are using the ? value_if_true : value_if_false system then that's fine, but when it's branched out 9 times, you are better off doing it the old fashioned way so you can easily debug if needed.
__________________
Bugsy is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-27-2015 , 12:20   Re: [HELP] Formatex error
Reply With Quote #5

After "CLASS_ZOMBIE", there should be a "," or you made a mistake there.
PartialCloning is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-27-2015 , 12:24   Re: [HELP] Formatex error
Reply With Quote #6

@PartialCloning
as i can see in the main code i used as refference, there is no "," after "CLASS_ZOMBIE" =/ it is ":" hmmm, are you sure about it?

@Bugsy
well, this is the original code... i need to add about 6 new classes/modes to this menu
the nemesis/assassin/dragon/tyrant/alpha classes are zombie like classes ( more exactly bosses )
the survivor/sniper/ninja are human like classes ( again bosses )

So, could you please write an example on how would you write it so i can follow the pattern? this code gets me a little confused, i never understood menus, never did them, always hated them

Later Edit:
P.S -> Could you guys give me a page or something where i can find all the symbols/terms used in formatex and their meaning?

Player List part
PHP Code:
Player List Menu
show_menu_player_list
(id)
{
    static 
menu[128], player_name[32]
    new 
menuidplayerbuffer[2], userflags get_user_flags(id)
    
    
// Title
    
switch (PL_ACTION)
    {
        case 
ACTION_INFECT_CUREformatex(menucharsmax(menu), "%L\r"id"MENU_ADMIN1")
        case 
ACTION_MAKE_NEMESISformatex(menucharsmax(menu), "%L\r"id"MENU_ADMIN2")
        case 
ACTION_MAKE_SURVIVORformatex(menucharsmax(menu), "%L\r"id"MENU_ADMIN3")
        case 
ACTION_RESPAWN_PLAYERformatex(menucharsmax(menu), "%L\r"id"MENU_ADMIN4")
    }
    
menuid menu_create(menu"menu_player_list")
    
    
// Player List
    
for (player 0player <= g_MaxPlayersplayer++)
    {
        
// Skip if not connected
        
if (!is_user_connected(player))
            continue;
        
        
// Get player's name
        
get_user_name(playerplayer_namecharsmax(player_name))
        
        
// Format text depending on the action to take
        
switch (PL_ACTION)
        {
            case 
ACTION_INFECT_CURE// Infect/Cure command
            
{
                if (
zp_core_is_zombie(player))
                {
                    if ((
userflags read_flags(g_access_make_human)) && is_user_alive(player))
                        
formatex(menucharsmax(menu), "%s \r[%L]"player_nameid, (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" "CLASS_ZOMBIE")
                    else
                        
formatex(menucharsmax(menu), "\d%s [%L]"player_nameid, (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" "CLASS_ZOMBIE")
                }
                else
                {
                    if ((
userflags read_flags(g_access_make_zombie)) && is_user_alive(player))
                        
formatex(menucharsmax(menu), "%s \y[%L]"player_nameid, (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" "CLASS_HUMAN")
                    else
                        
formatex(menucharsmax(menu), "\d%s [%L]"player_nameid, (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" "CLASS_HUMAN")
                }
            }
            case 
ACTION_MAKE_NEMESIS// Nemesis command
            
{
                if (
LibraryExists(LIBRARY_NEMESISLibType_Library) && (userflags read_flags(g_access_make_nemesis)) && is_user_alive(player) && !zp_class_nemesis_get(player))
                {
                    if (
zp_core_is_zombie(player))
                        
formatex(menucharsmax(menu), "%s \r[%L]"player_nameid, (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" "CLASS_ZOMBIE")
                    else
                        
formatex(menucharsmax(menu), "%s \y[%L]"player_nameid, (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" "CLASS_HUMAN")
                }
                else
                    
formatex(menucharsmax(menu), "\d%s [%L]"player_nameidzp_core_is_zombie(player) ? (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" "CLASS_ZOMBIE" : (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" "CLASS_HUMAN")
            }
            case 
ACTION_MAKE_SURVIVOR// Survivor command
            
{
                if (
LibraryExists(LIBRARY_SURVIVORLibType_Library) && (userflags read_flags(g_access_make_survivor)) && is_user_alive(player) && !zp_class_survivor_get(player))
                {
                    if (
zp_core_is_zombie(player))
                        
formatex(menucharsmax(menu), "%s \r[%L]"player_nameid, (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" "CLASS_ZOMBIE")
                    else
                        
formatex(menucharsmax(menu), "%s \y[%L]"player_nameid, (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" "CLASS_HUMAN")
                }
                else
                    
formatex(menucharsmax(menu), "\d%s [%L]"player_nameidzp_core_is_zombie(player) ? (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NEMESIS" "CLASS_ZOMBIE" : (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" "CLASS_HUMAN")
            }
            case 
ACTION_RESPAWN_PLAYER// Respawn command
            
{
                if ((
userflags read_flags(g_access_respawn_players)) && allowed_respawn(player))
                    
formatex(menucharsmax(menu), "%s"player_name)
                else
                    
formatex(menucharsmax(menu), "\d%s"player_name)
            }
        }
        
        
// Add player
        
buffer[0] = player
        buffer
[1] = 0
        menu_additem
(menuidmenubuffer)
    }
    
    
// Back - Next - Exit
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_BACKNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_NEXT")
    
menu_setprop(menuidMPROP_NEXTNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_EXIT")
    
menu_setprop(menuidMPROP_EXITNAMEmenu)
    
    
// If remembered page is greater than number of pages, clamp down the value
    
MENU_PAGE_PLAYERS min(MENU_PAGE_PLAYERSmenu_pages(menuid)-1)
    
    
// Fix for AMXX custom menus
    
set_pdata_int(idOFFSET_CSMENUCODE0)
    
menu_display(idmenuidMENU_PAGE_PLAYERS)

Full Code

Spoiler
__________________

Last edited by Depresie; 12-27-2015 at 12:41.
Depresie is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-27-2015 , 12:57   Re: [HELP] Formatex error
Reply With Quote #7

It seems to me like you're doing:

condition ? if true : if false : if false.

(LibraryExists(LIBRARY_ALPHA, LibType_Library) && zp_class_alpha_get(player))
? "CLASS_ALPHA"
: "CLASS_ZOMBIE"
: (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && zp_class_survivor_get(player))

You can only have one if false. But then again it might be just one if false and that last one is a part of the wider conditions.


http://www.amxmodx.org/api/string/formatex

Is the full code yours? It complies fine for me.

Edit: I added your code to the full plugin just to see if it complies, and it does compile, though I had to change the names to nemisis as I dont have the library for the rest of them.

Last edited by PartialCloning; 12-27-2015 at 12:58.
PartialCloning is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-27-2015 , 15:48   Re: [HELP] Formatex error
Reply With Quote #8

the full code is not mine, it's the unedited version of zp 5.0 menu ( in the spoiler )
in the second post made by me it's the unedited code used by me as a pattern to write the one from the first post..
->> this is the unedited code from the second post

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" 
"CLASS_ZOMBIE" 
: (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" 
"CLASS_HUMAN"
also, what amxmodx were you using for compiling? 1.8.3?
__________________

Last edited by Depresie; 12-27-2015 at 15:50.
Depresie is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-27-2015 , 17:13   Re: [HELP] Formatex error
Reply With Quote #9

Quote:
Originally Posted by Depresie View Post
the full code is not mine, it's the unedited version of zp 5.0 menu ( in the spoiler )
in the second post made by me it's the unedited code used by me as a pattern to write the one from the first post..
->> this is the unedited code from the second post

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" 
"CLASS_ZOMBIE" 
: (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(player)) ? "CLASS_SURVIVOR" 
"CLASS_HUMAN"
also, what amxmodx were you using for compiling? 1.8.3?

Yeah, 1.8.3. Under the show_menu_player_list(id) function I added this code at the bottom inside the case ACTION_RESPAWN_PLAYER:

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_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_ASSASSIN" 
    
: (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_DRAGON" 
    
: (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_TYRANT" 
    
: (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_ALPHA" 
    
"CLASS_ZOMBIE" 
    
: (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_SURVIVOR" 
    
: (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_SNIPER" 
    
: (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(player)) ? "CLASS_NINJA" 
    
"CLASS_HUMAN"
    } 
Which is your code, I just renamed everything to nemesis as I don't have the other libraries. It compiles so perhaps your error is elsewhere? Even if the compiler says it's in the formatex part. Remove it, then fix all the other errors if there are any, then add it back, see if it compiles.
PartialCloning is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 12-27-2015 , 16:13   Re: [HELP] Formatex error
Reply With Quote #10

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
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