Raised This Month: $ Target: $400
 0% 

Menu Command Scripting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-03-2011 , 00:00   Re: Menu Command Scripting
Reply With Quote #1

  • 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 #2

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
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 08-03-2011 , 00:21   Re: Menu Command Scripting
Reply With Quote #3

in fact
one command, one menu and one menu handler is enough !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
HBxander
Senior Member
Join Date: Jan 2011
Location: Behind you!
Old 08-03-2011 , 11:34   Re: Menu Command Scripting
Reply With Quote #4

I would do like this:
PHP Code:
new boolgBoughtItem 32 ] [ 
when he buy 25 HP and it takes his money, do this:
PHP Code:
gBoughtItem [id][0] = true 
and if he buy 50 HP do this:
PHP Code:
gBoughtItem [id][1] = true 
PHP Code:
RegisterHam Ham_Spawn"player""FwdPlayerSpawn"
PHP Code:
public FwdPlayerSpawn iPlayer )
{
        if ( 
gBoughtItem iPlayer ] [ ] )
                
set_user_health iPlayerget_user_health iPlayer ) + 25 )
        if ( 
gBoughtItem iPlayer ] [ ] )
                
set_user_health iPlayerget_user_health iPlayer ) + 50 )
        
gBoughtItem iPlayer ] [ ] = false
        gBoughtItem 
iPlayer ] [ ] = false

__________________
Selling:

- PointMod for Hide And Seek - $20
- Private BlockMaker with Weapon Block And More - $50
- Achievements ( FFA GamePlay ) - $25

PM Me about Private Work!
HBxander is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-03-2011 , 12:55   Re: Menu Command Scripting
Reply With Quote #5

Quote:
Originally Posted by HBxander View Post
I would do like this:
PHP Code:
new boolgBoughtItem 32 ] [ 
when he buy 25 HP and it takes his money, do this:
PHP Code:
gBoughtItem [id][0] = true 
and if he buy 50 HP do this:
PHP Code:
gBoughtItem [id][1] = true 
PHP Code:
RegisterHam Ham_Spawn"player""FwdPlayerSpawn"
PHP Code:
public FwdPlayerSpawn iPlayer )
{
        if ( 
gBoughtItem iPlayer ] [ ] )
                
set_user_health iPlayerget_user_health iPlayer ) + 25 )
        if ( 
gBoughtItem iPlayer ] [ ] )
                
set_user_health iPlayerget_user_health iPlayer ) + 50 )
        
gBoughtItem iPlayer ] [ ] = false
        gBoughtItem 
iPlayer ] [ ] = false

With your code, you are limited to 2 options. With my suggestion, you are unlimited while using a smaller array.
__________________
fysiks is offline
deadman909
Veteran Member
Join Date: Oct 2008
Old 08-03-2011 , 21:36   Re: Menu Command Scripting
Reply With Quote #6

Okay I got it to work. But now what I want to do is how would I set this menu to appear right after someone has join the server and they are on a team. I want it to appear only that one time. The rest of the time they have to say /shop to see it again.

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < fun >
#include < cstrike >

new boolgBoughtItem 32 ] [ ]


public 
plugin_init()
{
    
register_plugin"T SHOP""1.0""Dead Man" );
    
RegisterHam Ham_Spawn"player""FwdPlayerSpawn")

    
register_clcmd"say /shop""ShopT" );
}

public 
client_connectid )
{
    
gBoughtItemid ][ ] = false;
    
gBoughtItemid ][ ] = false;
}
    
public 
FwdPlayerSpawn iPlayerid )
{
        if ( 
gBoughtItem iPlayer ] [ ] )
                
set_user_health iPlayerget_user_health iPlayer ) + 25 )
        if ( 
gBoughtItem iPlayer ] [ ] )
                
set_user_health iPlayerget_user_health iPlayer ) + 50 )
        
gBoughtItem iPlayer ] [ ] = false
        gBoughtItem 
iPlayer ] [ ] = false
}

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)
           
gBoughtItemid ][ ] = true;
        }
        case 
2:
        {
           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)
           
gBoughtItemid ][ ] = true;
        }
    }
    return 
PLUGIN_HANDLED;

__________________


Last edited by deadman909; 08-04-2011 at 00:55.
deadman909 is offline
Send a message via MSN to deadman909 Send a message via Yahoo to deadman909
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