Raised This Month: $51 Target: $400
 12% 

My First Attempt to make a menu!


Post New Thread Reply   
 
Thread Tools Display Modes
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-30-2011 , 21:17   Re: My First Attempt to make a menu!
Reply With Quote #11

Quote:
Originally Posted by RollerBlades View Post
not are you only great at making static menus but also dynamic ones! TY!
Well dynamic menu is easy to do.
Your previous menu, as a static was bad.
Why ? create a global var gBlablaMenu for example.
Set the menu properties in plugin_init.

menu_display on the global var to display the menu.
But DO NOT use menu_destroy in the callback of this kind of menu.


and G-Dog why do you use menu_item_getinfo ? useless here.
just use item
with
#define MENU_EXIT -3
#define MENU_BACK -2
#define MENU_MORE -1
0 key 1
1 key 2
2 key 3
and so on.

Last edited by Fr33m@n; 05-30-2011 at 21:42.
Fr33m@n is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-31-2011 , 01:43   Re: My First Attempt to make a menu!
Reply With Quote #12

Quote:
Originally Posted by The Art of War View Post
EDIT: Oh, its hamParam. Oh gosh.

i believe you've seen this multiplier many times. right?

SetHamParamFloat is good?

Edit: is /w gray?

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

Quote:
Originally Posted by RollerBlades View Post
i believe you've seen this multiplier many times. right?

SetHamParamFloat is good?

Edit: is /w gray?
White, actually..

Well I dont know, I guess I like using SH includes only :p But then if you dont want sh_extra_damage with multiplier as damagetype that is indeed the way to go!
__________________
The Art of War is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-31-2011 , 09:09   Re: My First Attempt to make a menu!
Reply With Quote #14

and /y for yellow?

sh_extra_damage kinda how do i say...... sucks a bit... there should be sh_extra_dmgmult you know... way easier

Last edited by RollerBlades; 05-31-2011 at 10:51.
RollerBlades is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-31-2011 , 10:29   Re: My First Attempt to make a menu!
Reply With Quote #15

Final Code???

Code:
// Menu - Basics

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

#include <superheromod>

new const itemcost[6] = { 4000, 4000, 4500, 6000, 6000, 0 }
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(victim, inflictor, attacker, Float:damage, damage_type)
{    
    if (victim == attacker || !is_user_connected(attacker)) // non-player damage or self damage
        return HAM_IGNORED;
    
    if ( extradmg[attacker] ) SetHamParamFloat(4, damage * M3MULT);    //basic dmg multiplier
    
    return HAM_IGNORED;
}
/*======================================================================
            DAMAGE MULT OPTIONS
======================================================================*/
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);
*/
/*======================================================================
            DAMAGE MULT OPTIONS 
======================================================================*/
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/Flash", "3", 0);
        menu_additem(menu, "/yBuy CSW_G3SG1", "4", 0);
        
        new buffer[15];    //allows us to format the color based on admin or not
        formatex(buffer, charsmax(buffer), "%sBuy Super M3", (get_user_flags(id) & ADMIN_ADMIN) ? "/y" : "/w");
        menu_additem(menu, buffer, "5")

        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[2], acces, callback, key;
    menu_item_getinfo(menu, item, acces, data, 1, _, _, callback);

    key = str_to_num(data);
      
    if ( 0 < key < 6 )
    {
        new usermoney; usermoney = cs_get_user_money(id);
        new cost; cost = itemcost[key];
        if ( usermoney >= cost )
        {
            cs_set_user_money(id, usermoney - cost, 1);
            if ( key == 6 ) client_print(id, print_chat, "[AMXX] Bought Super M3");
            else client_print(id, print_chat, "[AMXX] Bought Weapon Set %i", key+1);

            switch(key)
            {
                case 0: // M4A1 + HE
                {
                    sh_give_weapon(id, CSW_M4A1, true);
                    sh_give_weapon(id, CSW_HEGRENADE);
                }
                case 1: // AK47 + HE
                {
                    sh_give_weapon(id, CSW_AK47, true);
                    sh_give_weapon(id, CSW_HEGRENADE);
                }

                case 2: // AWP + Kevlar
                {
                    sh_give_weapon(id, CSW_AWP, true);
                    set_user_armor(id, 100);
                }

                case 3: // M249 + Deagle/Flash
                {
                    sh_give_weapon(id, CSW_M249, true);
                    sh_give_weapon(id, CSW_DEAGLE);
                    sh_give_weapon(id, CSW_FLASHBANG);
                }

                case 4: sh_give_weapon(id, CSW_G3SG1, true); // G3SG1

                case 5: // The Super Shotgun(ADMIN)
                {
                    if ( !(get_user_flags(id) & ADMIN_ADMIN) )
                    {
                        menu_destroy(menu);
                        cmd_menu(id);
                        return PLUGIN_HANDLED;
                    }
                    sh_give_weapon(id, CSW_M3, true);
                    extradmg[id] = true;
                }
            }
        } else client_print(id, print_chat, "[AMXX] You Don't Have Enough Money(You Cheap Bastard)");
    }
    menu_destroy(menu);
    return PLUGIN_HANDLED;
}
Edited: Accidently said that you get smoke but you get a flash so changed to flash!!
added comment on each case
uncomment the function to lose dmg mult on death......
made a notification for players about the damage mult options....
added new weapon


Quote:
Originally Posted by Fr33m@n View Post
Well dynamic menu is easy to do.
Your previous menu, as a static was bad.
Why ? create a global var gBlablaMenu for example.
Set the menu properties in plugin_init.

menu_display on the global var to display the menu.
But DO NOT use menu_destroy in the callback of this kind of menu.

when did i say i made a static one???? this one i dynamic lol.....

Last edited by RollerBlades; 06-01-2011 at 06:28.
RollerBlades is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-31-2011 , 11:40   Re: My First Attempt to make a menu!
Reply With Quote #16

well no, your menu (main post) don't change at all in the time so it's a static.
but it's not the good way for using a static menu.
Fr33m@n is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 05-31-2011 , 11:45   Re: My First Attempt to make a menu!
Reply With Quote #17

i know!!! but its my first time so i dont really have any ideas for dynamic ones.....

though G-dog made a static menu in the vip thread... the one i requested.. so i know how a static one should look but i dont want to do that right now...
RollerBlades is offline
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 04:09.


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