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

Problem with Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fry!
Veteran Member
Join Date: Apr 2008
Location: Latvia
Old 03-27-2011 , 14:10   Problem with Menu
Reply With Quote #1

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

__________________
Quote:
Originally Posted by wisam187
why all the great scriptors..... always.... leave and let their works go into oblivion ???
i miss your way in making outstanding plugins...
this forum needs lots of the likes of you..... and less of the idiots that spread right now.
Fry! is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-27-2011 , 14:14   Re: Problem with Menu
Reply With Quote #2

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).
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Fry!
Veteran Member
Join Date: Apr 2008
Location: Latvia
Old 03-27-2011 , 15:24   Re: Problem with Menu
Reply With Quote #3

Quote:
Originally Posted by Emp` View Post
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.. ;((
__________________
Quote:
Originally Posted by wisam187
why all the great scriptors..... always.... leave and let their works go into oblivion ???
i miss your way in making outstanding plugins...
this forum needs lots of the likes of you..... and less of the idiots that spread right now.

Last edited by Fry!; 03-27-2011 at 15:30. Reason: edit
Fry! is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-27-2011 , 16:15   Re: Problem with Menu
Reply With Quote #4

Code:
public kmshop(player, KEYS)
{
    switch (KEYS)
    {
->
Code:
public kmshop(player, key)
{
    switch (key)
    {
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Fry!
Veteran Member
Join Date: Apr 2008
Location: Latvia
Old 03-28-2011 , 13:36   Re: Problem with Menu
Reply With Quote #5

Quote:
Originally Posted by Emp` View Post
Code:
public kmshop(player, KEYS)
{
    switch (KEYS)
    {
->
Code:
public kmshop(player, key)
{
    switch (key)
    {

oopss... I thought i tried that. I guess i didn't. Thanks.
__________________
Quote:
Originally Posted by wisam187
why all the great scriptors..... always.... leave and let their works go into oblivion ???
i miss your way in making outstanding plugins...
this forum needs lots of the likes of you..... and less of the idiots that spread right now.
Fry! 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 10:46.


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