Raised This Month: $ Target: $400
 0% 

Menu Command Scripting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deadman909
Veteran Member
Join Date: Oct 2008
Old 08-02-2011 , 05:27   Re: Menu Command Scripting
Reply With Quote #1

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;

__________________

deadman909 is offline
Send a message via MSN to deadman909 Send a message via Yahoo to deadman909
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-02-2011 , 08:13   Re: Menu Command Scripting
Reply With Quote #2

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 MEXIT_NEVER
__________________
fysiks is offline
deadman909
Veteran Member
Join Date: Oct 2008
Old 08-02-2011 , 23:17   Re: Menu Command Scripting
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
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 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.
__________________

deadman909 is offline
Send a message via MSN to deadman909 Send a message via Yahoo to deadman909
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-03-2011 , 00:00   Re: Menu Command Scripting
Reply With Quote #4

  • Global array[33]
  • menu_handler: array[id] = key (if they can afford it)
  • hook new round (search for "new round" in the tutorial section, see page 2). Or use spawn if you only spawn on new round (same tutorial as noted for new round).
  • Then do a switch(array[id) there to give the appropriate health if any
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 08-03-2011 , 00:12   Re: Menu Command Scripting
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
  • Global array[33]
  • menu_handler: array[id] = key (if they can afford it)
  • hook new round (search for "new round" in the tutorial section, see page 2). Or use spawn if you only spawn on new round (same tutorial as noted for new round).
  • Then do a switch(array[id) there to give the appropriate health if any
Then set array[id] to no item or 0 or -1 or w/e.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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 03:25.


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