AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Show description when menu item is pressed (https://forums.alliedmods.net/showthread.php?t=295231)

Airkish 03-19-2017 19:16

Show description when menu item is pressed
 
Need to make that when menu key is pressed it would show description of that achievement

PHP Code:

public CmdAch(iPlayer

    new 
g_AchMenu menu_create("\wPasiekimai""Achievements_Handler"
     
    new 
Key[6
     
    for(new 
iAch 0iAch AchievesiAch++) 
    { 
        if(
Achievement[iPlayer][iAch] == 0formatex(szTempcharsmax(szTemp), "\d%s - [%d/%d]"AchName[iAch], Achievement[iPlayer][iAch], AchRequirement[iAch]) 
        else if(
Achievement[iPlayer][iAch] >= AchRequirement[iAch]) formatex(szTempcharsmax(szTemp), "\y%s \w- [\rĮVYKDYTAS\w]"AchName[iAch]) 
        else 
formatex(szTempcharsmax(szTemp), "\y%s \w- [\r%d\w/\r%d\w]"AchName[iAch], Achievement[iPlayer][iAch], AchRequirement[iAch]) 
        
menu_additem(g_AchMenuszTempKey
    } 
     
    
menu_setprop(g_AchMenuMPROP_EXITMEXIT_ALL
    
menu_display(iPlayerg_AchMenu0


public 
Achievements_Handler(iPlayerg_AchMenuitem)  
{  
    if(
item == MENU_EXIT)  
    {  
        
menu_destroy(g_AchMenu
        return 
PLUGIN_HANDLED  
    

    else 
    { 
        if(
Achievement[iPlayer][item] >= AchRequirement[item])  
        {  
            
ColorChat(iPlayerRED"Completed."
            
CmdAch(iPlayer);  
        }  
        else  
        {  
            
ColorChat(iPlayerRED"%s"AchDescription[iPlayer]) 
                       
CmdAch(iPlayer);  
        }  
    }  
    return 
PLUGIN_CONTINUE  



OciXCrom 03-19-2017 19:49

Re: Show description when menu item is pressed
 
So what's the problem?!

Airkish 03-19-2017 20:43

Re: Show description when menu item is pressed
 
Quote:

Originally Posted by OciXCrom (Post 2504988)
So what's the problem?!

The problem is that when I press any key I get same description.

EDIT: Stupid me
PHP Code:

ColorChat(iPlayerRED"%s"AchDescription[iPlayer]) 

->
PHP Code:

ColorChat(iPlayerRED"%s"AchDescription[item]) 


Natsheh 03-20-2017 04:27

Re: Show description when menu item is pressed
 
SmaLL optimize

Remove the if statments (item == menu_exit)
In the menu handler and destroy the menu directly since ur not saving any data


All times are GMT -4. The time now is 18:05.

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