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(PLUGIN, VERSION, AUTHOR)
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(menu, 511, "\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(id, keys, menu, -1)
return PLUGIN_HANDLED
}
public kmshop(player, KEYS)
{
switch (KEYS)
{
case 0:
{
if (!is_user_alive(player))
{
client_print(player, print_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(player, print_chat, "[KMS] You dont have enough money to buy Health", cost1)
return PLUGIN_HANDLED
}
g_hasHP[player] = true
fm_set_user_health(player, 100)
cs_set_user_money(player, current_cash - cost1)
client_print(player, print_chat, "[KMS] You have successfully bought Health Pack")
}
case 1:
{
if (!is_user_alive(player))
{
client_print(player, print_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(player, print_chat, "[KMS] You dont have enough money to buy Armor", cost2)
return PLUGIN_HANDLED
}
cs_set_user_armor(player, 100, CS_ARMOR_VESTHELM)
cs_set_user_money(player, current_cash - cost2)
client_print(player, print_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(player, print_chat, "[KMS] You dont have enough money to respawn")
return PLUGIN_HANDLED
}
g_hasRespawned[player] = true
ExecuteHamB(Ham_CS_RoundRespawn, player)
cs_set_user_money(player, current_cash - cost3)
client_print(player, print_chat, "[KMS] You are now RESPAWNED")
}
case 3:
{
return PLUGIN_HANDLED
}
}
return PLUGIN_HANDLED
}
__________________