AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help]Menu problem (https://forums.alliedmods.net/showthread.php?t=159646)

2reason2kill 06-19-2011 18:07

[Help]Menu problem
 
I dont know why but the menu for ct works but for the ts it dosent...


Heres the code

PHP Code:

    register_clcmd("say /shop","showmenu");
    
register_concmd("say_team /shop","Shop");
    
register_concmd("say /Help","Showhelp");
    
    
    
    
    
    
}


public 
showmenu(id)
{
    if(
is_user_alive (id) )
    {
    new 
Item[64];
    
    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
        new 
ShopCT menu_create("\y [\rHumen Shop\y]\y:","CsShop");
        
formatex(Itemcharsmax(Item), "\wSilver Light \y[\r %d $\y]"get_pcvar_num(silver_lighet_cost));
        
menu_additem(ShopCT,Item"1");
        
format(Item,sizeof(Item)-1"\wShotty\y[\r %d $\y]"get_pcvar_num(Shotghun_cost));
        
menu_additem(ShopCT,Item"2");
        
format(Item,sizeof(Item)-1"\wnightvision\y[\r %d $\y]"get_pcvar_num(nightvison_cost));
        
menu_additem(ShopCT,Item"3");
        
format(Item,sizeof(Item)-1"\wGreNade Packet\y[\r %d $\y]"get_pcvar_num(grenadepacket_cost));
        
menu_additem(ShopCT,Item"4");
        
format(Item,sizeof(Item)-1"\wMachinGun Guy!\y[\r %d $\y]"get_pcvar_num(m249_cost));
        
menu_additem(ShopCT,Item"5");
        
menu_setprop(ShopCTMPROP_PERPAGE0);
        
menu_display(idShopCT)
    }
    }
    else
    {
        if(
is_user_alive(id) )
    {
        new 
Item [100];
        
        if(
cs_get_user_team(id) == CS_TEAM_T)
        {    
            new 
ShopT menu_create("\y [\rVampire Shop\y]\y:","vampireshop");
            
formatex(Itemcharsmax(Item), "\wAnti Deagle\y[\r %s $\y]"get_pcvar_num(anti_deagle_cost));
            
menu_additem(ShopT,Item"1");
            
formatex(Itemcharsmax(Item), "\wRatio Shield!\y[\r %s $\y]"get_pcvar_num(ratio_shield_cost));
            
menu_additem(ShopT,Item"2");
            
formatex(Itemcharsmax(Item), "\wChamelon\y[\r %s $\y]"get_pcvar_num(spy_cost));
            
menu_additem(ShopT,Item"3");
            
menu_setprop(ShopTMPROP_PERPAGE,0);
            
menu_display(idShopT)
        }
    }
}



lucas_7_94 06-19-2011 18:15

Re: [Help]Menu problem
 
Code:
public showmenu(id) {     if( is_user_alive (id) ) // If the player is alive...     {         new Item[64];                 if(cs_get_user_team(id) == CS_TEAM_CT) // Check if the player is CT         {             new ShopCT = menu_create("\y [\rHumen Shop\y]\y:","CsShop");             formatex(Item, charsmax(Item), "\wSilver Light \y[\r %d $\y]", get_pcvar_num(silver_lighet_cost));             menu_additem(ShopCT,Item, "1");             format(Item,sizeof(Item)-1, "\wShotty\y[\r %d $\y]", get_pcvar_num(Shotghun_cost));             menu_additem(ShopCT,Item, "2");             format(Item,sizeof(Item)-1, "\wnightvision\y[\r %d $\y]", get_pcvar_num(nightvison_cost));             menu_additem(ShopCT,Item, "3");             format(Item,sizeof(Item)-1, "\wGreNade Packet\y[\r %d $\y]", get_pcvar_num(grenadepacket_cost));             menu_additem(ShopCT,Item, "4");             format(Item,sizeof(Item)-1, "\wMachinGun Guy!\y[\r %d $\y]", get_pcvar_num(m249_cost));             menu_additem(ShopCT,Item, "5");             menu_setprop(ShopCT, MPROP_PERPAGE, 0);             menu_display(id, ShopCT)         }         else // if the player isn't CT , the player is TT         {                 new ShopT = menu_create("\y [\rVampire Shop\y]\y:","vampireshop");             formatex(Item, charsmax(Item), "\wAnti Deagle\y[\r %s $\y]", get_pcvar_num(anti_deagle_cost));             menu_additem(ShopT,Item, "1");             formatex(Item, charsmax(Item), "\wRatio Shield!\y[\r %s $\y]", get_pcvar_num(ratio_shield_cost));             menu_additem(ShopT,Item, "2");             formatex(Item, charsmax(Item), "\wChamelon\y[\r %s $\y]", get_pcvar_num(spy_cost));             menu_additem(ShopT,Item, "3");             menu_setprop(ShopT, MPROP_PERPAGE,0);             menu_display(id, ShopT)         }     }     else // If the player isn't alive , he is dead.     {         client_print(id, print_chat, "# You should be alive to look the Vampire shop!") // print msg.     } }

You should look how the if statement works.

drekes 06-19-2011 18:20

Re: [Help]Menu problem
 
Lucas:
You have to check if his team is CS_TEAM_T because it can also be
- CS_TEAM_UNASSIGNED
- CS_TEAM_SPECTATOR

PHP Code:

public showmenu(id)
{
    if(
is_user_alive(id))
    {
        new 
ShopItem[35];
        
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_T
            {
                
Shop menu_create("\y [\rVampire Shop\y]\y:","vampireshop");
                
formatex(Itemcharsmax(Item), "\wAnti Deagle\y[\r %s $\y]"get_pcvar_num(anti_deagle_cost));
                
menu_additem(Shop,Item"1");
                
formatex(Itemcharsmax(Item), "\wRatio Shield!\y[\r %s $\y]"get_pcvar_num(ratio_shield_cost));
                
menu_additem(Shop,Item"2");
                
formatex(Itemcharsmax(Item), "\wChamelon\y[\r %s $\y]"get_pcvar_num(spy_cost));
                
menu_additem(Shop,Item"3");
            }
            
            case 
CS_TEAM_CT:
            {
                
Shop menu_create("\y [\rHumen Shop\y]\y:","CsShop");
                
formatex(Itemcharsmax(Item), "\wSilver Light \y[\r %d $\y]"get_pcvar_num(silver_lighet_cost));
                
menu_additem(Shop,Item"1");
                
format(Item,sizeof(Item)-1"\wShotty\y[\r %d $\y]"get_pcvar_num(Shotghun_cost));
                
menu_additem(Shop,Item"2");
                
format(Item,sizeof(Item)-1"\wnightvision\y[\r %d $\y]"get_pcvar_num(nightvison_cost));
                
menu_additem(Shop,Item"3");
                
format(Item,sizeof(Item)-1"\wGreNade Packet\y[\r %d $\y]"get_pcvar_num(grenadepacket_cost));
                
menu_additem(Shop,Item"4");
                
format(Item,sizeof(Item)-1"\wMachinGun Guy!\y[\r %d $\y]"get_pcvar_num(m249_cost));
                
menu_additem(Shop,Item"5");
            }
        }
        
        
menu_setprop(ShopMPROP_PERPAGE0);
        
menu_display(idShop);
    }



lucas_7_94 06-19-2011 20:57

Re: [Help]Menu problem
 
Quote:

Originally Posted by drekes (Post 1491806)
Lucas:
You have to check if his team is CS_TEAM_T because it can also be
- CS_TEAM_UNASSIGNED
- CS_TEAM_SPECTATOR

PHP Code:

public showmenu(id)
{
    if(
is_user_alive(id))
    {
        new 
ShopItem[35];
        
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_T
            {
                
Shop menu_create("\y [\rVampire Shop\y]\y:","vampireshop");
                
formatex(Itemcharsmax(Item), "\wAnti Deagle\y[\r %s $\y]"get_pcvar_num(anti_deagle_cost));
                
menu_additem(Shop,Item"1");
                
formatex(Itemcharsmax(Item), "\wRatio Shield!\y[\r %s $\y]"get_pcvar_num(ratio_shield_cost));
                
menu_additem(Shop,Item"2");
                
formatex(Itemcharsmax(Item), "\wChamelon\y[\r %s $\y]"get_pcvar_num(spy_cost));
                
menu_additem(Shop,Item"3");
            }
            
            case 
CS_TEAM_CT:
            {
                
Shop menu_create("\y [\rHumen Shop\y]\y:","CsShop");
                
formatex(Itemcharsmax(Item), "\wSilver Light \y[\r %d $\y]"get_pcvar_num(silver_lighet_cost));
                
menu_additem(Shop,Item"1");
                
format(Item,sizeof(Item)-1"\wShotty\y[\r %d $\y]"get_pcvar_num(Shotghun_cost));
                
menu_additem(Shop,Item"2");
                
format(Item,sizeof(Item)-1"\wnightvision\y[\r %d $\y]"get_pcvar_num(nightvison_cost));
                
menu_additem(Shop,Item"3");
                
format(Item,sizeof(Item)-1"\wGreNade Packet\y[\r %d $\y]"get_pcvar_num(grenadepacket_cost));
                
menu_additem(Shop,Item"4");
                
format(Item,sizeof(Item)-1"\wMachinGun Guy!\y[\r %d $\y]"get_pcvar_num(m249_cost));
                
menu_additem(Shop,Item"5");
            }
        }
        
        
menu_setprop(ShopMPROP_PERPAGE0);
        
menu_display(idShop);
    }



yea , i had the dude . but thanks to confirm.

2reason2kill 06-20-2011 14:17

Re: [Help]Menu problem
 
Quote:

Originally Posted by drekes (Post 1491806)
Lucas:
You have to check if his team is CS_TEAM_T because it can also be
- CS_TEAM_UNASSIGNED
- CS_TEAM_SPECTATOR

PHP Code:

public showmenu(id)
{
    if(
is_user_alive(id))
    {
        new 
ShopItem[35];
        
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_T
            {
                
Shop menu_create("\y [\rVampire Shop\y]\y:","vampireshop");
                
formatex(Itemcharsmax(Item), "\wAnti Deagle\y[\r %s $\y]"get_pcvar_num(anti_deagle_cost));
                
menu_additem(Shop,Item"1");
                
formatex(Itemcharsmax(Item), "\wRatio Shield!\y[\r %s $\y]"get_pcvar_num(ratio_shield_cost));
                
menu_additem(Shop,Item"2");
                
formatex(Itemcharsmax(Item), "\wChamelon\y[\r %s $\y]"get_pcvar_num(spy_cost));
                
menu_additem(Shop,Item"3");
            }
            
            case 
CS_TEAM_CT:
            {
                
Shop menu_create("\y [\rHumen Shop\y]\y:","CsShop");
                
formatex(Itemcharsmax(Item), "\wSilver Light \y[\r %d $\y]"get_pcvar_num(silver_lighet_cost));
                
menu_additem(Shop,Item"1");
                
format(Item,sizeof(Item)-1"\wShotty\y[\r %d $\y]"get_pcvar_num(Shotghun_cost));
                
menu_additem(Shop,Item"2");
                
format(Item,sizeof(Item)-1"\wnightvision\y[\r %d $\y]"get_pcvar_num(nightvison_cost));
                
menu_additem(Shop,Item"3");
                
format(Item,sizeof(Item)-1"\wGreNade Packet\y[\r %d $\y]"get_pcvar_num(grenadepacket_cost));
                
menu_additem(Shop,Item"4");
                
format(Item,sizeof(Item)-1"\wMachinGun Guy!\y[\r %d $\y]"get_pcvar_num(m249_cost));
                
menu_additem(Shop,Item"5");
            }
        }
        
        
menu_setprop(ShopMPROP_PERPAGE0);
        
menu_display(idShop);
    }





thanks you taught me something


All times are GMT -4. The time now is 23:26.

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