AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with Menu (https://forums.alliedmods.net/showthread.php?t=153684)

Fry! 03-27-2011 14:10

Problem with Menu
 
Hey again,

So i today made a small plagin which includes menu and some items, everything compiled ok, but in game when i tested i could open menu but when chosed what to buy nothing happened... Did i miss anything? Please correct it.

PHP Code:

new menu[512]
const 
KEYS MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4


public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say /kshop""opens_shop")
    
register_clcmd("say /kmshop""opens_shop")
    
    
register_clcmd("say !kshop""opens_shop")
    
register_clcmd("say !kmshop""opens_shop")

        
register_menucmd(register_menuid("Knife Mod Shop"), KEYS"kmshop")
}

public 
opens_shop(player)
{
    
CreateMenu(player)
}

public 
CreateMenu(player)
{
    new 
len format(menu511"\yKnife Mod Shop:^n")
    
len += format(menu[len], 511 len"^n\w1. Health Pack ($ %d)"get_pcvar_num(g_hp_cost))
    
len += format(menu[len], 511 len"^n\w2. Armor ($ %d)"get_pcvar_num(g_armor_cost))
    
len += format(menu[len], 511 len"^n\w3. Respawn ($ %d)"get_pcvar_num(g_respawn_cost))
     
len += format(menu[len], 511 len"^n^n\w4. Exit")

    
show_menu(idkeysmenu, -1)
    
    return 
PLUGIN_HANDLED       
}

public 
kmshop(playerKEYS)
{
    switch (
KEYS)
    {
        case 
0:
        {    
            if (!
is_user_alive(player))
            {
                
client_print(playerprint_chat"[KMS] Dead players cant buy this")
                return 
PLUGIN_HANDLED
            
}
                
            new 
cost1 get_pcvar_num(g_hp_cost)
            new 
current_cash cs_get_user_money(player)
            
            if (
cost1 current_cash)
            {
                
client_print(playerprint_chat"[KMS] You dont have enough money to buy Health"cost1)
                return 
PLUGIN_HANDLED
            
}
            
            
g_hasHP[player] = true
            
            fm_set_user_health
(player100)
            
cs_set_user_money(playercurrent_cash cost1)
            
            
client_print(playerprint_chat"[KMS] You have successfully bought Health Pack")
        }
        
        case 
1:
        {
            if (!
is_user_alive(player))
            {
                
client_print(playerprint_chat"[KMS] Dead players cant buy this")
                return 
PLUGIN_HANDLED
            
}
                
            new 
cost2 get_pcvar_num(g_armor_cost)
            new 
current_cash cs_get_user_money(player)
            
            if (
cost2 current_cash)
            {
                
client_print(playerprint_chat"[KMS] You dont have enough money to buy Armor"cost2)
                return 
PLUGIN_HANDLED
            
}
            
            
cs_set_user_armor(player100CS_ARMOR_VESTHELM)
            
cs_set_user_money(playercurrent_cash cost2)
            
            
client_print(playerprint_chat"[KMS] You have successfully bought Armor")
        }
        
        case 
2:
        {
            if (
is_user_alive(player))
                return 
PLUGIN_HANDLED
                
            
new cost3 get_pcvar_num(g_respawn_cost)
            new 
current_cash cs_get_user_money(player)
            
            if (
cost3 current_cash)
            {
                
client_print(playerprint_chat"[KMS] You dont have enough money to respawn")
                return 
PLUGIN_HANDLED
            
}
            
            
g_hasRespawned[player] = true
            
            ExecuteHamB
(Ham_CS_RoundRespawnplayer)
            
cs_set_user_money(playercurrent_cash cost3)
            
            
client_print(playerprint_chat"[KMS] You are now RESPAWNED")
        }
        
        case 
3:
        {
            return 
PLUGIN_HANDLED
        
}
    }
    
    return 
PLUGIN_HANDLED



Emp` 03-27-2011 14:14

Re: Problem with Menu
 
For show_menu you should use KEYS, but in kmshop you should have a separate variable for which key is pressed (most people use key).

Fry! 03-27-2011 15:24

Re: Problem with Menu
 
Quote:

Originally Posted by Emp` (Post 1440267)
For show_menu you should use KEYS, but in kmshop you should have a separate variable for which key is pressed (most people use key).

hm yea about first one forgot to change it with caps, and in kmshop did you meant I should add like
PHP Code:

new Key1 MENU_KEY_1, new Key2 MENU_KEY_2 

and so on in each CASE statement?

By the way if im wrong, then please show me, cause i dont remember much anymore.. ;((

Emp` 03-27-2011 16:15

Re: Problem with Menu
 
Code:

public kmshop(player, KEYS)
{
    switch (KEYS)
    {

->
Code:

public kmshop(player, key)
{
    switch (key)
    {


Fry! 03-28-2011 13:36

Re: Problem with Menu
 
Quote:

Originally Posted by Emp` (Post 1440331)
Code:

public kmshop(player, KEYS)
{
    switch (KEYS)
    {

->
Code:

public kmshop(player, key)
{
    switch (key)
    {



oopss... :oops: I thought i tried that. I guess i didn't. Thanks.


All times are GMT -4. The time now is 14:39.

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