Raised This Month: $ Target: $400
 0% 

Solved Menu_additem, and menu handler error.


Post New Thread Reply   
 
Thread Tools Display Modes
ZaX
Senior Member
Join Date: Jan 2015
Old 04-13-2019 , 07:33   Re: Menu_additem, and menu handler error.
Reply With Quote #11

I already know how to give gun, I registered the natives and I have them, look to @Airkish code, it uses give_item only in his loop. I need to use switch to do it, or check if item equal the item has the native
ZaX is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 04-13-2019 , 09:15   Re: Menu_additem, and menu handler error.
Reply With Quote #12

Whatever dude, it seems like you don't want to understand the code I gave.
Here's your code should work:

PHP Code:
    new iMenu menu_create("\wChoose Guns""iMenuHandler")
    new 
szString[4];

    for(new 
0sizeof g_szWeaponsPrimaryListi++)
    {
        switch(
crxranks_get_user_level(id))
        {
            case 
0
            { 
                
formatex(szString3"0");
                
menu_additem(iMenug_szWeaponsPrimaryList[0], szString// case 0
                
break;
            }
            case 
1:
            {
                
formatex(szString3"1");
                
menu_additem(iMenug_szWeaponsPrimaryList[1], szString// case 1
                
break;
            }
            case 
2:
            {
                
formatex(szString3"2");
                
menu_additem(iMenug_szWeaponsPrimaryList[2], szString// case 2
                
break;
            }
            case 
3:
            {
                
formatex(szString3"3");
                
menu_additem(iMenug_szWeaponsPrimaryList[3], szString// case 3
                
break;
            }
        }  
    }



public 
iMenuHandler(idiMenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[9], name[64], Key;
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdatacharsmax(data), namecharsmax(name), callback);

    
Key str_to_num(data);

    switch(
Key)
    {
        case 
0:
        {
            if((
cs_get_user_team(id) == CS_TEAM_CT) && (crxranks_get_user_level(id) >= 0))
            {
                
strip_weapons(idPRIMARY_ONLY)
                
strip_weapons(idSECONDARY_ONLY)

                
give_item(id"weapon_tmp")
                
cs_set_user_bpammo(idCSW_TMP200)
            }
        }
        case 
1:
        {
            if((
cs_get_user_team(id) == CS_TEAM_CT) && (crxranks_get_user_level(id) >= 1))
            {
                
strip_weapons(idPRIMARY_ONLY)
                
strip_weapons(idSECONDARY_ONLY)

                
give_item(id"weapon_mac10")
                
cs_set_user_bpammo(idCSW_MAC10200)
            }
        }
        case 
2:
        {
            if((
cs_get_user_team(id) == CS_TEAM_CT) && (crxranks_get_user_level(id) >= 2))
            {
                
strip_weapons(idPRIMARY_ONLY)
                
strip_weapons(idSECONDARY_ONLY)

                
give_item(id"weapon_ump45")
                
cs_set_user_bpammo(idCSW_UMP45200)

            }
        }
        case 
3:
        {
            if((
cs_get_user_team(id) == CS_TEAM_CT) && (crxranks_get_user_level(id) >= 3))
            {
                
strip_weapons(idPRIMARY_ONLY)
                
strip_weapons(idSECONDARY_ONLY)

                
give_item(id"weapon_m3")
                
cs_set_user_bpammo(idCSW_M3200)
            }
        }  
    }

__________________

Last edited by Airkish; 04-13-2019 at 09:15.
Airkish 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 08:10.


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