AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu Command Scripting (https://forums.alliedmods.net/showthread.php?t=163599)

deadman909 08-01-2011 04:44

Menu Command Scripting
 
Okay what I need help is int getting a same command to work in both teams but to open different menus.

register_clcmd( "say /buy", "shopCT");
register_clcmd( "say /buy", "shopT");

I have this to commands register and plugin compiles. But for some reason the command only works for CT and not T.

How would i set it up so the command works for both teams?

drekes 08-01-2011 04:55

Re: Menu Command Scripting
 
register it to 1 function & build/show the menu depending on the team.

deadman909 08-01-2011 05:03

Re: Menu Command Scripting
 
Hmm do you think you can please give me an example of what you mean register it to one fuction?

HBxander 08-01-2011 05:04

Re: Menu Command Scripting
 
PHP Code:

register_clcmd "say /buy""shopChooseTeam" );

public 
shopChooseTeam id )
{
       if ( 
cs_get_user_team id ) == CS_TEAM_T )
       {
               
//code for menu for T team
       
}
       else if ( 
cs_get_user_team id ) == CS_TEAM_CT )
       {
               
//code for menu for CT team
       
}



deadman909 08-01-2011 05:11

Re: Menu Command Scripting
 
EDIT: Alright Thanks it Worked =)

HBxander 08-01-2011 05:28

Re: Menu Command Scripting
 
Quote:

Originally Posted by deadman909 (Post 1523177)
EDIT: Alright Thanks it Worked =)

No problem.

fysiks 08-01-2011 08:01

Re: Menu Command Scripting
 
PHP Code:

    switch( cs_get_user_team(id) ) // optimization
    
{
        case 
CS_TEAM_T:
        {
            
shopT(id// readability
        
}
        case 
CS_TEAM_CT:
        {
            
shopCT(id// readability
        
}
    } 


deadman909 08-02-2011 05:27

Re: Menu Command Scripting
 
Thanks everybody. One more question now. How would I set it so when they buy something they get it the next round and not the current round already started. I want all affects to happen on next round.

Also another question on the menu, what part of it do I need to remove so players don't get the ZERO key that lets them exit the menu. I want them to have to get something if they open it.
PHP Code:

public ShopT(id)
{
    new 
menu menu_create("\yWhat well you buy?""submenu_handler")

    
menu_additem(menu"\wExtra 25 HP for ($5000)""1"0);
    
menu_additem(menu"\wExtra 50 HP for ($10000)""2"0);

    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

public 
submenu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
           if(
cs_get_user_moneyid ) < 5000
           {
               
client_print(idprint_chat"You do not have enough money.")
               return 
PLUGIN_CONTINUE
           
}
           
cs_set_user_money(idcs_get_user_money(id) - 5000)
           
set_user_health(idget_user_health(id) + 25)
        }
        case 
2:
        {
           if(
cs_get_user_moneyid ) < 10000
           {
               
client_print(idprint_chat"You do not have enough money.")
               return 
PLUGIN_CONTINUE
           
}
           
cs_set_user_money(idcs_get_user_money(id) - 10000)
           
set_user_health(idget_user_health(id) + 50)
        }

    }
    return 
PLUGIN_HANDLED;



fysiks 08-02-2011 08:13

Re: Menu Command Scripting
 
1. You would need to store their selection in a variable and use it to create the action on the new round.

2. MEXIT_ALL :arrow: MEXIT_NEVER

deadman909 08-02-2011 23:17

Re: Menu Command Scripting
 
Quote:

Originally Posted by fysiks (Post 1524081)
1. You would need to store their selection in a variable and use it to create the action on the new round.

2. MEXIT_ALL :arrow: MEXIT_NEVER

Hmm I am still learning on how to code. Anybody want to give me an example of how one would do that. With one example is enough I well create all the rest from that one.


All times are GMT -4. The time now is 03:25.

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