const MIN_FRAGS = 10; // minimum number of frags for unlock client (default: 10)
const Float:GET_STATS_DELAY = 1.0;
new g_Frags[MAX_CLIENTS + 1];
register_plugin("Voice protection", "0.3", "AMXX.Shop");
register_dictionary("voice_protection.txt");
set_fail_state("VTC is required for plugin work!");
RegisterHookChain(RG_CBasePlayer_Killed, "RGCBasePlayerKilledPost", true);
register_clcmd("say", "CmdSay");
register_clcmd("say_team", "CmdSay");
g_HudSyncObj = CreateHudSyncObj();
public client_putinserver(id) {
if(is_user_bot(id) || is_user_hltv(id)) {
if(get_user_flags(id) & USE_IMMUNITY) {
set_task(GET_STATS_DELAY, "GetStats", id);
set_task(GET_STATS_DELAY, "GetStats", id);
public client_disconnect(id) {
public GetStats(const id) {
new Stats[8], BodyHits[8];
get_user_stats(id, Stats, BodyHits);
if((g_Frags[id] = Stats[0]) < MIN_FRAGS) {
public RGCBasePlayerKilledPost(const Victim, const Attacker) {
if(!is_user_connected(Attacker) || g_Frags[Attacker] >= MIN_FRAGS || Victim == Attacker) {
if(++g_Frags[Attacker] == MIN_FRAGS) {
VTC_UnmuteClient(Attacker);
set_hudmessage(128, 128, 128, _, 0.25, _, _, 10.0, _, _, -1);
ShowSyncHudMsg(Attacker, g_HudSyncObj, "%L^n%L", Attacker, "VP_TO_BEGIN", Attacker, "VP_NEED_YET", MIN_FRAGS - g_Frags[Attacker]);
public CmdSay(const id) {
if(!is_user_connected(id)) {
read_args(Args, charsmax(Args));
return PLUGIN_HANDLED_MAIN;
if(g_Frags[id] < MIN_FRAGS) {
client_print(id, print_chat, "%L %L", id, "VP_TO_BEGIN", id, "VP_NEED_YET", MIN_FRAGS - g_Frags[id]);