Member
|
04-02-2020
, 16:42
Health shop [ ONLY FOR CT ]
|
#1
|
So i found this health shop here in alliedmodders i edited the hp amount u can buy and the price to the one i wanted , what i want help with is to make this shop only available for CT , cause i have a basebuilder server and i dont want zombies to be able to buy HP.
Thanks
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"
#define FM_MONEY_OFFSET 115
new health50[200]
new health100[200]
new health200[200]
new health250[200]
new cost_50hp,cost_100hp, cost_200hp, cost_250hp
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /hpshop", "show_menu_buy_hp")
register_clcmd("say_team /hpshop", "show_menu_buy_hp")
register_logevent("Event_Round_Start", 2, "1=Round_Start")
cost_50hp = register_cvar("hs_50hp_cost", "1500")
cost_100hp = register_cvar("hs_100hp_cost", "2700")
cost_200hp = register_cvar("hs_200hp_cost", "4200")
cost_250hp = register_cvar("hs_250hp_cost", "5500")
}
public show_menu_buy_hp(id)
{
new menu = menu_create("\r VIP \yHealth Shop", "handle_buy_hp_menu")
formatex(health50, 199, "+50 Health - $%d", get_pcvar_num(cost_50hp))
menu_additem(menu, health50, "1")
formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp))
menu_additem(menu, health100, "2")
formatex(health200, 199, "+200 Health - $%d", get_pcvar_num(cost_200hp))
menu_additem(menu, health200, "3")
formatex(health250, 199, "+250 Health - $%d", get_pcvar_num(cost_250hp))
menu_additem(menu, health250, "4")
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}
public handle_buy_hp_menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new Data[6];
new Access;
new Callback;
new Name[64];
menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)
new Key = str_to_num(Data);
switch (Key)
{
case 1:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}
new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_50hp)
new Health = get_user_health(id)
if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +50 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+50)
}
}
case 2:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}
new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_100hp)
new Health = get_user_health(id)
if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +100 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+100)
}
}
case 3:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}
new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_200hp)
new Health = get_user_health(id)
if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +200 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+200)
}
}
case 4:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}
new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_250hp)
new Health = get_user_health(id)
if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +250 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+250)
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public Event_Round_Start()
{
client_print(0, print_chat, "To Open Up Health Shop, Type /hpshop in chat")
}
stock fm_set_user_health(index, health)
{
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
return 1
}
stock fm_get_user_money(index)
{
return get_pdata_int(index, FM_MONEY_OFFSET)
}
stock fm_set_user_money(index, money, flash = 1)
{
set_pdata_int(index, FM_MONEY_OFFSET, money);
message_begin(MSG_ONE, get_user_msgid("Money"), _, index);
write_long(money);
write_byte(flash ? 1 : 0);
message_end();
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1053\\ f0\\ fs16 \n\\ par }
*/
Last edited by Pizzadaking; 04-02-2020 at 19:16.
|
|