AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unknown fault (https://forums.alliedmods.net/showthread.php?t=153628)

bibu 03-26-2011 18:49

Unknown fault
 
I don't really know where the fault is, with the edited one, if I press any key, nothing happens. I just added \r, \w before the numbers and changed the header of menu:

Original:

PHP Code:

public ShowExtraMenuidpos )
{
    if( 
pos ) return

    new 
i0nStartnEndnLennKeys = (1<<9)
    new 
szMenuBody[512]

    
nStart pos MAX_DISPLAY

    
if( nStart >= MO_MAX_EXTRA )
        
nStart pos g_nMenuPosition[id-1] = 0

    nLen 
formatszMenuBody511"\yExtras Menu:\R%d/2^n\w^n"pos )

    
nEnd nStart MAX_DISPLAY
    
if( nEnd MO_MAX_EXTRA nEnd MO_MAX_EXTRA

    
for( nStartnEndi++ )
    {
        
nKeys |= (1<<j++)
        
nLen += formatszMenuBody[nLen], (511-nLen), "%d. %s^n"jg_szExtraMenuTxt[i] )
    }

    if( 
nEnd != MO_MAX_EXTRA )
    {
        
formatszMenuBody[nLen], (511-nLen), "^n9. More...^n0. Back" )
        
nKeys |= (1<<8)
    }
    else 
formatszMenuBody[nLen], (511-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return


Edited:

PHP Code:

public ShowExtraMenuidpos )
{
    if( 
pos ) return

    new 
i0nStartnEndnLennKeys = (1<<9)
    new 
szMenuBody[512]

    
nStart pos MAX_DISPLAY

    
if( nStart >= MO_MAX_EXTRA )
        
nStart pos g_nMenuPosition[id-1] = 0

    nLen 
formatszMenuBody511"\yExtra Menu: %d/2^n\w^n^n"pos )

    
nEnd nStart MAX_DISPLAY
    
if( nEnd MO_MAX_EXTRA nEnd MO_MAX_EXTRA

    
for( nStartnEndi++ )
    {
        
nKeys |= (1<<j++)
        
nLen += formatszMenuBody[nLen], (511-nLen), "\r%d. \w%s^n"jg_szExtraMenuTxt[i] )
    }

    if( 
nEnd != MO_MAX_EXTRA )
    {
        
formatszMenuBody[nLen], (511-nLen), "^n\r9. \wMore...^n\r0. \wBack" )
        
nKeys |= (1<<8)
    }
    else 
formatszMenuBody[nLen], (511-nLen), "^n\r0. \wBack" )

    
show_menuidnKeysszMenuBody, -)
    return



Exolent[jNr] 03-26-2011 18:54

Re: Unknown fault
 
The colors may be interfering with the format args.
Try this:
PHP Code:

nLen += formatszMenuBody[nLen], (511-nLen), "%s%d. %s%s^n""\r"j"\w"g_szExtraMenuTxt[i] ) 


Sylwester 03-26-2011 18:59

Re: Unknown fault
 
When you change header of menu, you must also change it in plugin_init:
PHP Code:

register_menucmd(register_menuidHEADER ), .....) 


bibu 03-27-2011 06:05

Re: Unknown fault
 
Quote:

Originally Posted by Sylwester (Post 1439843)
When you change header of menu, you must also change it in plugin_init:
PHP Code:

register_menucmd(register_menuidHEADER ), .....) 


Exactly, forgot this.

@Exolent:

Is your line with format better, then I will replace it with yours. Though I think both do the same.

Thanks for both! :)

ConnorMcLeod 03-27-2011 06:29

Re: Unknown fault
 
Quote:

Originally Posted by bibu (Post 1440010)
@Exolent:

Is your line with format better, then I will replace it with yours. Though I think both do the same.

Thanks for both! :)

If it's just a matter of putting \w inside or outside of the unformatted string, it shouldn't matter at all, except in some situations i can't remember if you use web compiler, but i don't know if xolent's way would fix it. You can stick with your way, w/e.

bibu 03-27-2011 11:51

Re: Unknown fault
 
Alright, thanks. :)

bibu 03-30-2011 14:52

Re: Unknown fault
 
Somehow, still the same:

PHP Code:

register_menucmd(register_menuid("Extras:"),            1023"ExtraMenuCmd" )

public 
ExtraMenuCmdidkey )
{
    
// Track which Option was chosen
    
g_nMenuOption[id-1] = g_nMenuPosition[id-1] * MAX_DISPLAY key

    
switch( key )
    {
        case 
8:
        {
            
// User Selected "More..." Option
            
ShowExtraMenuid, ++g_nMenuPosition[id-1] )
        }
        case 
9:
        {
            
// User Chose to go Back to Previous Menu
            
if( g_nMenuPosition[id-1] )
            {
                
ShowExtraMenuid, --g_nMenuPosition[id-1] )
            }else
            {
                
ShowMainMenuid )
            }
        }
        default: 
ShowPlayerMenuidg_nMenuPosition[id-1] = )
    }
    return 
PLUGIN_HANDLED
}

public 
ShowExtraMenuidpos )
{
    if( 
pos ) return

    new 
i0nStartnEndnLennKeys = (1<<9)
    new 
szMenuBody[512]

    
nStart pos MAX_DISPLAY

    
if( nStart >= MO_MAX_EXTRA )
        
nStart pos g_nMenuPosition[id-1] = 0

    nLen 
formatszMenuBody511"\yExtras: %d/2^n\w^n^n"pos )

    
nEnd nStart MAX_DISPLAY
    
if( nEnd MO_MAX_EXTRA nEnd MO_MAX_EXTRA

    
for( nStartnEndi++ )
    {
        
nKeys |= (1<<j++)
        
//nLen += format( szMenuBody[nLen], (511-nLen), "\r%d. \w%s^n", j, g_szExtraMenuTxt[i] )
    
nLen += formatszMenuBody[nLen], (511-nLen), "%s%d. %s%s^n""\r"j"\w"g_szExtraMenuTxt[i] )
    }

    if( 
nEnd != MO_MAX_EXTRA )
    {
        
formatszMenuBody[nLen], (511-nLen), "^n\r9. \wMore...^n\r0. \wBack" )
        
nKeys |= (1<<8)
    }
    else 
formatszMenuBody[nLen], (511-nLen), "^n\r0. \wBack" )

    
show_menuidnKeysszMenuBody, -)
    return



fysiks 03-30-2011 18:27

Re: Unknown fault
 
Remove "\y" or use the title section of show_menu(.title="Extras:")

bibu 03-31-2011 11:37

Re: Unknown fault
 
If I remove "\y", title is white. Didn't understand your second method.

Exolent[jNr] 03-31-2011 17:47

Re: Unknown fault
 
PHP Code:

register_menucmd(register_menuid("Extras:"),            1023"ExtraMenuCmd" 

:arrow:
PHP Code:

register_menucmd(register_menuid("\yExtras:"),            1023"ExtraMenuCmd" 

OR

PHP Code:

show_menuidnKeysszMenuBody, -

:arrow:
PHP Code:

show_menuidnKeysszMenuBody, -1"Extras:" 



All times are GMT -4. The time now is 14:36.

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