#include < amxmodx >
#include < cstrike >
#include < fakemeta >
#include < hamsandwich >
#define PLUGIN "[All Mod] Life Menu"
#define VERSION "0.1"
#define AUTHOR "Opo4uMapy"
new g_life[33] = 0
const buy_life = 8000 //Сколько отнимать денег за покупку жизни
const sale_life = 4000 //Сколько давать денег за продажу жизни
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /life", "life_menu")
register_dictionary("lifemenu.txt")
}
public life_menu(id)
{
new Text[512]
formatex(Text, charsmax(Text), "%L", id, "MENU_NAME", g_life[id], cs_get_user_money(id))
new menu = menu_create(Text, "menu_handler")
formatex(Text, charsmax(Text), "%L", id, "MENU_ITEM_1", buy_life)
menu_additem(menu, Text, "1")
formatex(Text, charsmax(Text), "%L", id, "MENU_ITEM_2", sale_life)
menu_additem(menu, Text, "2")
formatex(Text, charsmax(Text), "%L", id, "MENU_ITEM_3")
menu_additem(menu, Text, "3")
formatex(Text, charsmax(Text), "%L", id, "MENU_ITEM_4")
menu_additem(menu, Text, "4")
menu_setprop(menu, MPROP_EXITNAME, "Выход")
menu_display(id,menu,0);
return PLUGIN_HANDLED
}
public menu_handler(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:
{
if(cs_get_user_money(id) < buy_life)
{
color_chat(id, "%L", id, "ITEM_NO_MONEY")
return PLUGIN_HANDLED
}
g_life[id]++
cs_set_user_money(id, cs_get_user_money(id) - buy_life)
color_chat(id, "%L", id, "MENU_ITEM_1_1")
client_cmd(id, "say /life")
}
case 2:
{
if(g_life[id] > 0)
{
g_life[id]--
cs_set_user_money(id, cs_get_user_money(id) + buy_life)
color_chat(id, "%L", id, "MENU_ITEM_2_2")
client_cmd(id, "say /life")
}
else
{
color_chat(id, "%L", id, "ITEM_NO_LIFE")
client_cmd(id, "say /life")
}
}
case 3:
{
if(g_life[id] > 0)
{
g_life[id]--
ExecuteHamB(Ham_CS_RoundRespawn, id)
color_chat(id, "%L", id, "MENU_ITEM_3_3")
client_cmd(id, "say/ life")
}
else
{
color_chat(id, "%L", id, "ITEM_NO_LIFE")
client_cmd(id, "say /life")
}
}
case 4:
if(g_life[id] > 0)
transmit_life(id)
}
return PLUGIN_HANDLED
}
public transmit_life(id)
{
new Text[512]
formatex(Text, charsmax(Text), "%L", id, "MENU_2_NAME")
new i_Menu = menu_create(Text, "menu_transmit")
new s_Players[32], i_Num, i_Player
new s_Name[32], s_Player[10]
get_players(s_Players, i_Num)
for(new i; i < i_Num; i++)
{
i_Player = s_Players[i];
if(is_user_connected(i_Player))
{
get_user_name(i_Player, s_Name, charsmax(s_Name));
num_to_str(i_Player, s_Player, charsmax(s_Player));
menu_additem(i_Menu, s_Name, s_Player, 0);
}
}
menu_setprop(i_Menu, MPROP_NEXTNAME, "Далее")
menu_setprop(i_Menu, MPROP_BACKNAME, "Назад")
menu_setprop(i_Menu, MPROP_EXITNAME, "Выход")
menu_setprop(i_Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, i_Menu, 0)
return PLUGIN_CONTINUE
}
public menu_transmit(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new s_Data[6], s_Name[64], i_Access, i_Callback
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
new i_Player = str_to_num(s_Data)
new name[32], name_player[32]
get_user_name(id, name, charsmax(name))
get_user_name(i_Player, name_player, charsmax(name_player))
if(is_user_connected(i_Player) && g_life[id] > 0)
{
g_life[id]--
g_life[i_Player]++
color_chat(0, "%L", 0, "MENU_ITEM_4_4", name, name_player)
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
stock color_chat(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4");
replace_all(msg, 190, "!y", "^1");
replace_all(msg, 190, "!t", "^3");
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/