Raised This Month: $32 Target: $400
 8% 

My First Attempt to make a menu!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-29-2011 , 13:14   My First Attempt to make a menu!
Reply With Quote #1

code:
Code:
// Menu - Basics

#define M3MULT 3        // damage multiplier for M3 # admin only.

#include <superheromod>

public plugin_init()
{

      register_plugin("WeaponMenu", "1.0", "RB");

      register_clcmd("say /buy", "cmd_menu");
      register_clcmd("say_team /buy", "cmd_menu");

}

public cmd_menu(id, lvl, cid)
{

      if ( is_user_alive(id) )
      {
            new menu = menu_create("Choose Your Weapon Set", "menu_handler");
            menu_additem(menu, "/yBuy M4A1 + HE", "1", 0);
            menu_additem(menu, "/yBuy AK47 + HE", "2", 0);
            menu_additem(menu, "/yBuy AWP + Kevlar", "3", 0);
            menu_additem(menu, "/yBuy M249 + Deagle/Smoke", "4", 0);
            menu_additem(menu, "/yBuy Super M3", "5", ADMIN_ADMIN);
            menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);

            menu_display(id, menu, 0); 
      }  

      else
      {
            client_print(id, print_chat, "[AMXX] You Have To Be Alive To Use The Menu.");
      }
}

public menu_handler(id, menu, item)
{

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

      new data[6], Name[64], acces, callback, key;
      menu_item_getinfo(menu, item, acces, data, 6, Name, 63, callback);

      key = str_to_num(data);

      switch(key)
      {
            case 1:
            {
                  menu_destroy(menu);
                  sh_give_weapon(id, CSW_M4A1, true);
                  sh_give_weapon(id, CSW_HEGRENADE);
                  cs_set_user_money(id, cs_get_user_money(id) - 4000, 1);
                  client_print(id, print_chat, "[AMXX] Bought Weapon Set 1");
                  return PLUGIN_HANDLED;
            }

            case 2:
            {
                  menu_destroy(menu);
                  sh_give_weapon(id, CSW_AK47, true);
                  sh_give_weapon(id, CSW_HEGRENADE);
                  cs_set_user_money(id, cs_get_user_money(id) - 4000, 1);
                  client_print(id, print_chat, "[AMXX] Bought Weapon Set 2");
                  return PLUGIN_HANDLED;
            }

            case 3:
            {
                  menu_destroy(menu);
                  sh_give_weapon(id, CSW_AWP, true);
                  set_user_armor(id, 100);
                  cs_set_user_money(id, cs_get_user_money(id) - 4500, 1);
                  client_print(id, print_chat, "[AMXX] Bought Weapon Set 3");
                  return PLUGIN_HANDLED;
            }

            case 4:
            {
                  menu_destroy(menu);
                  sh_give_weapon(id, CSW_M249, true);
                  sh_give_weapon(id, CSW_DEAGLE);
                  sh_give_weapon(id, CSW_FLASHBANG);
                  cs_set_user_money(id, cs_get_user_money(id) - 6000, 1);
                  client_print(id, print_chat, "[AMXX] Bought Weapon Set 4");
                  return PLUGIN_HANDLED;
            }

            case 5:
            {
                  menu_destroy(menu);
                  sh_give_weapon(id, CSW_M3, true);
                  sh_set_hero_dmgmult(id, M3MULT, CSW_M3);
                  client_print(id, print_chat, "[AMXX] Bought Super Weapon Set");
                  return PLUGIN_HANDLED;
            }
      }

      menu_destroy(menu);
      return PLUGIN_HANDLED;
}
now i wanna do that if the player isn't an admin then the last case will be shown in GREY! how do i do that?

Last edited by RollerBlades; 05-30-2011 at 14:03.
RollerBlades is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 05-29-2011 , 15:00   Re: My First Attempt to make a menu!
Reply With Quote #2

You cant do that. sh_set_hero_dmgmult only works in public plugin_init()

Make an admin check perhaps? ^^ Check G-Dog's admin only hero stuff for the code.
__________________
The Art of War is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-30-2011 , 06:30   Re: My First Attempt to make a menu!
Reply With Quote #3

My question is : Is this plugin superhero related or not ?
Because there is other ways without shmod.
Fr33m@n is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-30-2011 , 09:04   Re: My First Attempt to make a menu!
Reply With Quote #4

i just like using SH includes ;P it's easier that way
RollerBlades is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-30-2011 , 13:49   Re: My First Attempt to make a menu!
Reply With Quote #5

of course, but dude you will also need to have sh running on the server for getting them work. Ok it will compile but it will not work ingame without the core !
Fr33m@n is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-30-2011 , 13:57   Re: My First Attempt to make a menu!
Reply With Quote #6

i have SH + Deatmach server


and how do i set weapon mult in here?

Last edited by RollerBlades; 05-30-2011 at 14:04.
RollerBlades is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 05-30-2011 , 15:15   Re: My First Attempt to make a menu!
Reply With Quote #7

sh_extra_damage
__________________
The Art of War is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 05-30-2011 , 15:43   Re: My First Attempt to make a menu!
Reply With Quote #8

Quote:
Originally Posted by The Art of War View Post
You cant do that.
he could switch to the older style menu method to do it. Alternatively if the new menu style does support colors properly now(I had problems the first time I tried to use it) then this edit should do the trick
PHP Code:
// Menu - Basics

#define M3MULT 3        // damage multiplier for M3 # admin only.

#include <superheromod>

new const itemcost[5] = { 4000400045006000}
new 
bool:extradmg[SH_MAXSLOTS+1];

public 
plugin_init()
{

      
register_plugin("WeaponMenu""1.0""RB");

      
register_clcmd("say /buy""cmd_menu");
      
register_clcmd("say_team /buy""cmd_menu");
      
      
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage");
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{    
    if (
victim == attacker || !is_user_connected(attacker)) // non-player damage or self damage
        
return HAM_IGNORED;
    
    if ( 
extradmg[attacker] ) SetHamParamFloat(4damage M3MULT);    //basic dmg multiplier
    
    
return HAM_IGNORED;
}

public 
client_disconnect(id)
    
extradmg[id] = false;
    
/* if the damage mult should dissapear upon the player's death then uncomment this function

public sh_client_death(victim, attacker, headshot, const wpnDescription[])
    extradmg[victim] = false;
*/



/*    if the damage mult should only last 1 round then uncomment this function

public sh_round_new()
    arrayset(extradmg, false, SH_MAXSLOTS+1);
*/

public cmd_menu(id)
{

    if ( 
is_user_alive(id) )
    {
        new 
menu menu_create("Choose Your Weapon Set""menu_handler");
        
menu_additem(menu"/yBuy M4A1 + HE""0"0);
        
menu_additem(menu"/yBuy AK47 + HE""1"0);
        
menu_additem(menu"/yBuy AWP + Kevlar""2"0);
        
menu_additem(menu"/yBuy M249 + Deagle/Smoke""3"0);
        
        new 
buffer[15];    //allows us to format the color based on admin or not
        
formatex(buffercharsmax(buffer), "%sBuy Super M3", (get_user_flags(id) & ADMIN_ADMIN) ? "/y" "/w");
        
menu_additem(menubuffer"4")

        
menu_setprop(menuMPROP_EXITMEXIT_ALL);

        
menu_display(idmenu0); 
    } else 
client_print(idprint_chat"[AMXX] You Have To Be Alive To Use The Menu.");
}

public 
menu_handler(idmenuitem)
{

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

    new 
data[2], accescallbackkey;
    
menu_item_getinfo(menuitemaccesdata1__callback);

    
key str_to_num(data);
      
    if ( 
key )
    {
        new 
usermoneyusermoney cs_get_user_money(id);
        new 
costcost itemcost[key];
        if ( 
usermoney >= cost )
        {
            
cs_set_user_money(idusermoney cost1);
            if ( 
key == client_print(idprint_chat"[AMXX] Bought Super Weapon Set");
            else 
client_print(idprint_chat"[AMXX] Bought Weapon Set %i"key+1);

            switch(
key)
            {
                case 
0:
                {
                    
sh_give_weapon(idCSW_M4A1true);
                    
sh_give_weapon(idCSW_HEGRENADE);
                }
                case 
1:
                {
                    
sh_give_weapon(idCSW_AK47true);
                    
sh_give_weapon(idCSW_HEGRENADE);
                }

                case 
2:
                {
                    
sh_give_weapon(idCSW_AWPtrue);
                    
set_user_armor(id100);
                }

                case 
3:
                {
                    
sh_give_weapon(idCSW_M249true);
                    
sh_give_weapon(idCSW_DEAGLE);
                    
sh_give_weapon(idCSW_FLASHBANG);
                }

                case 
4:
                {
                    if ( !(
get_user_flags(id) & ADMIN_ADMIN) )
                    {
                        
menu_destroy(menu);
                        
cmd_menu(id);
                        return 
PLUGIN_HANDLED;
                    }
                    
sh_give_weapon(idCSW_M3true);
                    
extradmg[id] = true;
                }
            }
        } else 
client_print(idprint_chat"[AMXX] You Don't Have Enough Money(You Cheap Bastard)");
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

p.s. showed one of the method's for weapon multiplier.
__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-30-2011 , 15:53   Re: My First Attempt to make a menu!
Reply With Quote #9

not are you only great at making static menus but also dynamic ones! TY!

you should be my mentor ;P

i love the the admin check and the wep multiplier! i didn't know you could do it that way ;P

edit:

ok! i have a model for the shotgun but i want to make a check that if the admin drops the m3 or dies the dmgmult and model will go away from the m3 and go back to normal so he have to buy the shotgun again

howto??

Last edited by RollerBlades; 05-30-2011 at 16:18.
RollerBlades is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 05-30-2011 , 16:28   Re: My First Attempt to make a menu!
Reply With Quote #10

Quote:
Originally Posted by G-Dog View Post
he could switch to the older style menu method to do it. Alternatively if the new menu style does support colors properly now(I had problems the first time I tried to use it) then this edit should do the trick
PHP Code:
// Menu - Basics

#define M3MULT 3        // damage multiplier for M3 # admin only.

#include <superheromod>

new const itemcost[5] = { 4000400045006000}
new 
bool:extradmg[SH_MAXSLOTS+1];

public 
plugin_init()
{

      
register_plugin("WeaponMenu""1.0""RB");

      
register_clcmd("say /buy""cmd_menu");
      
register_clcmd("say_team /buy""cmd_menu");
      
      
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage");
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{    
    if (
victim == attacker || !is_user_connected(attacker)) // non-player damage or self damage
        
return HAM_IGNORED;
    
    if ( 
extradmg[attacker] ) SetHamParamFloat(4damage M3MULT);    //basic dmg multiplier
    
    
return HAM_IGNORED;
}

public 
client_disconnect(id)
    
extradmg[id] = false;
    
/* if the damage mult should dissapear upon the player's death then uncomment this function

public sh_client_death(victim, attacker, headshot, const wpnDescription[])
    extradmg[victim] = false;
*/



/*    if the damage mult should only last 1 round then uncomment this function

public sh_round_new()
    arrayset(extradmg, false, SH_MAXSLOTS+1);
*/

public cmd_menu(id)
{

    if ( 
is_user_alive(id) )
    {
        new 
menu menu_create("Choose Your Weapon Set""menu_handler");
        
menu_additem(menu"/yBuy M4A1 + HE""0"0);
        
menu_additem(menu"/yBuy AK47 + HE""1"0);
        
menu_additem(menu"/yBuy AWP + Kevlar""2"0);
        
menu_additem(menu"/yBuy M249 + Deagle/Smoke""3"0);
        
        new 
buffer[15];    //allows us to format the color based on admin or not
        
formatex(buffercharsmax(buffer), "%sBuy Super M3", (get_user_flags(id) & ADMIN_ADMIN) ? "/y" "/w");
        
menu_additem(menubuffer"4")

        
menu_setprop(menuMPROP_EXITMEXIT_ALL);

        
menu_display(idmenu0); 
    } else 
client_print(idprint_chat"[AMXX] You Have To Be Alive To Use The Menu.");
}

public 
menu_handler(idmenuitem)
{

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

    new 
data[2], accescallbackkey;
    
menu_item_getinfo(menuitemaccesdata1__callback);

    
key str_to_num(data);
      
    if ( 
key )
    {
        new 
usermoneyusermoney cs_get_user_money(id);
        new 
costcost itemcost[key];
        if ( 
usermoney >= cost )
        {
            
cs_set_user_money(idusermoney cost1);
            if ( 
key == client_print(idprint_chat"[AMXX] Bought Super Weapon Set");
            else 
client_print(idprint_chat"[AMXX] Bought Weapon Set %i"key+1);

            switch(
key)
            {
                case 
0:
                {
                    
sh_give_weapon(idCSW_M4A1true);
                    
sh_give_weapon(idCSW_HEGRENADE);
                }
                case 
1:
                {
                    
sh_give_weapon(idCSW_AK47true);
                    
sh_give_weapon(idCSW_HEGRENADE);
                }

                case 
2:
                {
                    
sh_give_weapon(idCSW_AWPtrue);
                    
set_user_armor(id100);
                }

                case 
3:
                {
                    
sh_give_weapon(idCSW_M249true);
                    
sh_give_weapon(idCSW_DEAGLE);
                    
sh_give_weapon(idCSW_FLASHBANG);
                }

                case 
4:
                {
                    if ( !(
get_user_flags(id) & ADMIN_ADMIN) )
                    {
                        
menu_destroy(menu);
                        
cmd_menu(id);
                        return 
PLUGIN_HANDLED;
                    }
                    
sh_give_weapon(idCSW_M3true);
                    
extradmg[id] = true;
                }
            }
        } else 
client_print(idprint_chat"[AMXX] You Don't Have Enough Money(You Cheap Bastard)");
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

p.s. showed one of the method's for weapon multiplier.
I just said that he couldnt use sh_set_hero_dmgmult.

Well, what can I say, there it is, masterly executed and all Basically what I told him to do just that I was too lazy and not good enough to make it that way :p

EDIT: Oh, its hamParam. Oh gosh.
__________________
The Art of War is offline
Reply


Thread Tools
Display Modes

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 18:58.


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