/* * CSB Buy HP * Copyright (C) 2026 counter-strike-boost.com * * A self-contained shop item: spend credits to buy extra health, up to a cap, * with a per-round purchase limit and a HUD confirmation. Credits are earned by * killing, so the plugin works on any server without an external shop core -- * but it exposes csb_hp_give() so a larger shop can grant HP through it too. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. See for details. */ #include #include new const PLUGIN[] = "CSB Buy HP" new const VERSION[] = "1.0.0" new const AUTHOR[] = "counter-strike-boost.com" new g_pEnabled, g_pCost, g_pAmount, g_pMaxHp, g_pLimit, g_pReward new g_iCredits[33] new g_iBoughtThisRound[33] public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_pEnabled = register_cvar("csb_buyhp_enabled", "1") g_pCost = register_cvar("csb_buyhp_cost", "10") g_pAmount = register_cvar("csb_buyhp_amount", "25") g_pMaxHp = register_cvar("csb_buyhp_maxhp", "150") g_pLimit = register_cvar("csb_buyhp_limit", "3") g_pReward = register_cvar("csb_buyhp_reward", "2") register_clcmd("say /buyhp", "cmdBuyHp") register_clcmd("say_team /buyhp", "cmdBuyHp") register_clcmd("say /credits", "cmdCredits") register_event("DeathMsg", "evDeath", "a") register_logevent("evRoundStart", 2, "1=Round_Start") } public client_connect(id) { g_iCredits[id] = 0 g_iBoughtThisRound[id] = 0 } public evRoundStart() { for (new id = 1; id <= 32; id++) g_iBoughtThisRound[id] = 0 } public evDeath() { new killer = read_data(1) new victim = read_data(2) if (killer >= 1 && killer <= 32 && killer != victim && is_user_connected(killer)) g_iCredits[killer] += get_pcvar_num(g_pReward) } public cmdCredits(id) { client_print_color(id, print_team_default, "^x04[CSB]^x01 You have^x04 %d^x01 credits. Type^x04 /buyhp^x01 to buy health.", g_iCredits[id]) return PLUGIN_HANDLED } public cmdBuyHp(id) { if (!get_pcvar_num(g_pEnabled)) { client_print_color(id, print_team_default, "^x04[CSB]^x01 The shop is disabled.") return PLUGIN_HANDLED } if (!is_user_alive(id)) { client_print_color(id, print_team_default, "^x04[CSB]^x01 You must be alive to buy health.") return PLUGIN_HANDLED } new limit = get_pcvar_num(g_pLimit) if (limit > 0 && g_iBoughtThisRound[id] >= limit) { client_print_color(id, print_team_default, "^x04[CSB]^x01 You already bought health^x04 %d^x01 time(s) this round.", limit) return PLUGIN_HANDLED } new cost = get_pcvar_num(g_pCost) if (g_iCredits[id] < cost) { client_print_color(id, print_team_default, "^x04[CSB]^x01 Not enough credits: you have^x04 %d^x01, this costs^x04 %d^x01.", g_iCredits[id], cost) return PLUGIN_HANDLED } new maxHp = get_pcvar_num(g_pMaxHp) new curHp = get_user_health(id) if (curHp >= maxHp) { client_print_color(id, print_team_default, "^x04[CSB]^x01 You are already at the^x04 %d^x01 HP cap.", maxHp) return PLUGIN_HANDLED } g_iCredits[id] -= cost g_iBoughtThisRound[id]++ new added = csb_hp_give(id, get_pcvar_num(g_pAmount)) set_hudmessage(0, 200, 0, -1.0, 0.65, 0, 0.0, 3.0, 0.1, 0.2, -1) show_hudmessage(id, "+%d HP (-%d credits)", added, cost) client_print_color(id, print_team_default, "^x04[CSB]^x01 Bought^x04 +%d^x01 HP. Credits left:^x04 %d^x01.", added, g_iCredits[id]) return PLUGIN_HANDLED } /* Public helper a bigger shop can call: give HP up to the cap, returns added. */ public csb_hp_give(id, amount) { if (!is_user_alive(id)) return 0 new maxHp = get_pcvar_num(g_pMaxHp) new curHp = get_user_health(id) new newHp = curHp + amount if (newHp > maxHp) newHp = maxHp set_user_health(id, newHp) return newHp - curHp }