AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu not showing up (https://forums.alliedmods.net/showthread.php?t=159408)

JRISETH 06-16-2011 18:00

Menu not showing up
 
Hello guys,

So i've made small VIP menu today and when I tested it, it doesn't show up.

Code:
Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <colorchat>
#include <cstrike>
#include <csx>
#include <fun>

public plugin_init() {
    register_plugin("V.I.P", "1.0", "JRISETH");

    register_clcmd("say /osta", "ostaHandler");
    register_clcmd("say_team /osta", "ostaHandler");
    register_clcmd("say /vipid", "vipidHandler");
    register_clcmd("say_team /vipid", "vipidHandler");
    register_clcmd("say /vipmenu", "showPrimaryWeaponMenu");

    register_logevent("roundStart",2,"0=World triggered","1=Round_Start")
}

public ostaHandler(id) {
    show_motd(id, "adminvipbuy.txt");
}

public roundStart() {
    new players[32], player, pnum;
    get_players(players, pnum, "a");
    for(new i = 0; i < pnum; i++) {
        player = players[i];
        if (get_user_flags(player) & ADMIN_LEVEL_B) {
            showPrimaryWeaponMenu(player);
        }
        else {
            ColorChat(player, NORMAL, "^x04[GamersDestiny]:^x01 Sa ei ole^x04 V.I.P!^x01 Osta juba täna, kirjuta^x04 /osta");
        }
    }
}

public showPrimaryWeaponMenu(id) {
    new menu = menu_create("Vali primaarne relv:", "primaryWeaponMenuHandler");

    menu_additem(menu, "M4A1", "1", 0);
    menu_additem(menu, "AK47", "2", 0);
    menu_additem(menu, "FAMAS", "3", 0);
    menu_additem(menu, "GALIL", "4", 0);
    menu_additem(menu, "M3", "5", 0);
    menu_additem(menu, "M249", "6", 0);

    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    menu_display(id, menu, 0);
}

public primaryWeaponMenuHandler(id, menu, item) {
    if(item == MENU_EXIT) {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }
   
    new data[6], iName[64], access, callback;
   
    menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback);
    new key = str_to_num(data);
    switch(key) {
        case 1: {
            give_item(id, "weapon_m4a1");
            cs_set_user_bpammo(id, CSW_M4A1, 90);
        }
        case 2: {
            give_item(id, "weapon_ak47");
            cs_set_user_bpammo(id, CSW_AK47, 90);
        }
        case 3: {
            give_item(id, "weapon_famas");
            cs_set_user_bpammo(id, CSW_FAMAS, 90);
        }
        case 4: {
            give_item(id, "weapon_galil");
            cs_set_user_bpammo(id, CSW_GALIL, 90);
        }
        case 5: {
            give_item(id, "weapon_m3");
            cs_set_user_bpammo(id, CSW_M3, 32);
        }
        case 6: {
            give_item(id, "weapon_m249");
            cs_set_user_bpammo(id, CSW_M249, 200);
        }
    }
    menu_destroy(menu);

    showSecondaryWeaponMenu(id);
   
    return PLUGIN_HANDLED;
}

public showSecondaryWeaponMenu(id) {
    new menu = menu_create("Vali sekundaarne relv:", "secondaryWeaponHandler");

    menu_additem(menu, "GLOCK", "1", 0);
    menu_additem(menu, "USP", "2", 0);
    menu_additem(menu, "ELITE", "3", 0);
    menu_additem(menu, "FIVESEVEN", "4", 0);
    menu_additem(menu, "DEAGLE", "5", 0);

    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    menu_display(id, menu, 0);
}

public secondaryWeaponHandler(id, menu, item) {
    if(item == MENU_EXIT) {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }
   
    new data[6], iName[64], access, callback;
   
    menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback);
    new key = str_to_num(data);
    switch(key) {
        case 1: {
            give_item(id, "weapon_glock18");
            cs_set_user_bpammo(id, CSW_GLOCK18, 120);
        }
        case 2: {
            give_item(id, "weapon_usp");
            cs_set_user_bpammo(id, CSW_USP, 100);
        }
        case 3: {
            give_item(id, "weapon_elite");
            cs_set_user_bpammo(id, CSW_ELITE, 30);
        }
        case 4: {
            give_item(id, "weapon_fiveseven");
            cs_set_user_bpammo(id, CSW_FIVESEVEN, 50);
        }
        case 5: {
            give_item(id, "weapon_deagle");
            cs_set_user_bpammo(id, CSW_DEAGLE, 35);
        }
    }
    menu_destroy(menu);

    give_item(id, "weapon_flashbang");
    give_item(id, "weapon_flashbang");
    give_item(id, "weapon_hegrenade");
    give_item(id, "weapon_smokegrenade");

    return PLUGIN_HANDLED;
}


drekes 06-16-2011 18:47

Re: Menu not showing up
 
I'm not sure but i think it's because you use this:
PHP Code:

register_clcmd("say /vipid""vipidHandler"); 
register_clcmd("say_team /vipid""vipidHandler"); 

but you never use vipidHandler() anywhere in the code,
which could cause a runtime error and should be in the error logs.

MeRcyLeZZ 06-16-2011 23:00

Re: Menu not showing up
 
When does it not show up? On round start or when they type /vipmenu ?

Erox902 06-17-2011 04:02

Re: Menu not showing up
 
I think it's cuz you namned both menus "menu" I don't think you can do that.

JRISETH 06-17-2011 04:50

Re: Menu not showing up
 
Quote:

Originally Posted by drekes (Post 1489655)
I'm not sure but i think it's because you use this:
PHP Code:

register_clcmd("say /vipid""vipidHandler"); 
register_clcmd("say_team /vipid""vipidHandler"); 

but you never use vipidHandler() anywhere in the code,
which could cause a runtime error and should be in the error logs.

Thanks, fixed :)

Erox902 06-17-2011 05:13

Re: Menu not showing up
 
Quote:

Originally Posted by drekes (Post 1489655)
I'm not sure but i think it's because you use this:
PHP Code:

register_clcmd("say /vipid""vipidHandler"); 
register_clcmd("say_team /vipid""vipidHandler"); 

but you never use vipidHandler() anywhere in the code,
which could cause a runtime error and should be in the error logs.

lol didn't see that xD

but I still don't think you should name the menus the same name:mrgreen:

drekes 06-17-2011 08:47

Re: Menu not showing up
 
Quote:

Originally Posted by Erox902 (Post 1489852)
but I still don't think you should name the menus the same name:mrgreen:

It's okay if he wants to do the exacty same thing for both commands.

fysiks 06-17-2011 16:26

Re: Menu not showing up
 
Quote:

Originally Posted by Erox902 (Post 1489831)
I think it's cuz you namned both menus "menu" I don't think you can do that.

They are both local variables (to different functions) and will not affect eachother.

Erox902 06-17-2011 17:36

Re: Menu not showing up
 
won't they get screwed up in the handler I mean when you:
PHP Code:

public menuHandler(idmenuitem

? :?

fysiks 06-17-2011 17:48

Re: Menu not showing up
 
Quote:

Originally Posted by Erox902 (Post 1490367)
won't they get screwed up in the handler I mean when you:
PHP Code:

public menuHandler(idmenuitem

? :?

No. Those are local variables also. You can think about it like this: The variables in the function declaration are newly created local variables that are auto-populated by the calling function. So, when menuHandler() is called, it creates the three variables id, menu, and item. Then it sets their value as supplied by the function that is calling it (the new menu system).

So, the variable "menu" will contain the menu pointer of the menu that just had an option chosen from it.


All times are GMT -4. The time now is 23:31.

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