/* Plugin generated by AMXX-Studio */ #include #include #include #include #define PLUGIN "AlMod's Buying HP" #define VERSION "1.1" #define AUTHOR "AlMod" new c_Mod, g_Mod new c_Amount, g_Amount new c_Count, g_Count new c_Cost, g_Cost new g_PurchasedHP[33] = 0 new BuySound[] = "items/gunpickup2.wav" new UseSound[] = "items/smallmedkit2.wav" public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) c_Mod = register_cvar("sv_buyinghp","1") c_Amount = register_cvar("bhp_amount","35") c_Count = register_cvar("bhp_count","3") c_Cost = register_cvar("bhp_cost","1500") register_clcmd("buy_hp","cmd_buy") register_clcmd("use_hp","cmd_use") register_event("DeathMsg","on_DeathMsg","a") } public plugin_cfg() { read_settings() } public plugin_precache() { precache_sound(BuySound) precache_sound(UseSound) } public client_connect(id) { g_PurchasedHP[id]=0 } public read_settings() { g_Mod = get_pcvar_num(c_Mod) g_Amount = get_pcvar_num(c_Amount) g_Count = get_pcvar_num(c_Count) g_Cost = get_pcvar_num(c_Cost) } public cmd_buy(id) { if (!g_Mod) return PLUGIN_CONTINUE if (!is_user_alive(id)) return PLUGIN_CONTINUE new in_zone = cs_get_user_buyzone(id) if (in_zone) { new money = cs_get_user_money(id) if (money>=g_Cost) { g_PurchasedHP[id]++ if ((g_PurchasedHP[id]<=g_Count) || (g_Count==0)) { emit_sound(id,CHAN_AUTO,BuySound,0.9,ATTN_NORM,0,PITCH_NORM) cs_set_user_money(id,money-g_Cost) if (g_Count!=0) client_print(id,print_center,"You have got [%d] of [%d] medkits!",g_PurchasedHP[id],g_Count) else client_print(id,print_center,"You have got [%d] medkits!",g_PurchasedHP[id]) } else { client_print(id,print_center,"You can't carry anymore!") g_PurchasedHP[id]-- } } else { client_print(id,print_center,"You have insufficient funds!") } } else { client_print(id,print_center,"You must be in a buyzone to purchase that item!") } return PLUGIN_HANDLED } public cmd_use(id) { if (!g_Mod) return PLUGIN_CONTINUE if (!is_user_alive(id)) return PLUGIN_CONTINUE if (g_PurchasedHP[id]==0) { client_print(id,print_center,"You have no medkits left") return PLUGIN_HANDLED } new hp = get_user_health(id) if (hp==100) { client_print(id,print_center,"You already have full HP") return PLUGIN_HANDLED } new new_hp = hp+g_Amount if (new_hp>100) { set_user_health(id,100) } else { set_user_health(id,new_hp) } g_PurchasedHP[id]-- client_print(id,print_center,"You have [%d] medkits left",g_PurchasedHP[id]) emit_sound(id,CHAN_AUTO,UseSound,0.9,ATTN_NORM,0,PITCH_NORM) return PLUGIN_HANDLED } public on_DeathMsg() { new id = read_data(2) g_PurchasedHP[id] = 0 }