
   #include <amxmod>
   #include <amxmisc>
   // A killstreak plugin for AMX.
   //
   // CVARs:
   //
   // pd_streak_mode - default "abe"
   // a - announce to all players by sound
   // b - announce to all players by hud message
   // c - announce to scorer by sound
   // d - announce to scorer by hud message
   // e - announce current death/killstreak at round start
   //
   // pd_streak_color - default "000100200"
   //
   // Server commands:
   //
   // pd_streak_level <# kills> <sound> <message> [color in RRRGGGBBB]
   //
   //  Add  something  like  this to admin.cfg or server.cfg or elsewhere
   appropiate:
   //
   // pd_streak_level 3 "misc/multikill" "%s: Multi-Kill!"
   // pd_streak_level 5 "misc/ultrakill" "%s: Ultra-Kill!!!"
   // pd_streak_level 7 "misc/dominating" "%s: Dominating!!!"
   // pd_streak_level 8 "misc/killingspree" "%s IS ON A KILLING SPREE!!!"
   //   pd_streak_level   9   "misc/unstoppable"   "%s:   Unstoppable!!!"
   "000255000"
   // pd_streak_level 10 "misc/godlike" "%s IS GODLIKE." "255000000"
   //
   // And for a UT killing spree:
   //
   // pd_streak_level 2 "misc/doublekill" "%s: DOUBLE-KILL!!!"
   // pd_streak_level 5 "misc/killingspree" "%s IS ON A KILLING SPREE!!!"
   // pd_streak_level 6 "misc/rampage" "%s IS ON A RAMPAGE!!!"
   // pd_streak_level 7 "misc/dominating" "%s IS DOMINATING!!!"
   // pd_streak_level 8 "misc/unstoppable" "%s IS UNSTOPPABLE!!!"
   // pd_streak_level 10 "misc/godlike" "%s IS GODLIKE!!!"
   //
   // You may skip the last parameter for the color - in that case
   // the default color from pd_streak_color is used.
   new current_level = 0;
   new kills[33] = {0,...};
   new deaths[33] = {0,...};
   #define MAX_LEVELS 16
   #define MAX_SOUND_LENGTH 32
   #define MAX_MSG_LENGTH 32
   new levels[MAX_LEVELS]; //  = {3, 5, 7, 8, 9, 10};
   new sounds[MAX_LEVELS][MAX_SOUND_LENGTH];
   new messages[MAX_LEVELS][MAX_MSG_LENGTH];
   new colors[MAX_LEVELS][3];
   is_mode_set(bits) {
       new mode[9];
       get_cvar_string("pd_streak_mode", mode, 8);
       return read_flags(mode) & bits;
   }
   public death_event(id) {
       new killer = read_data(1);
       new victim = read_data(2);
       kills[killer] += 1;
       kills[victim] = 0;
       deaths[killer] = 0;
       deaths[victim] += 1;
       for (new i = 0; i < current_level; i++) {
           if (kills[killer] == levels[i]) {
               announce(killer, i);
               return PLUGIN_CONTINUE;
           }
       }
       return PLUGIN_CONTINUE;
   }
   announce(killer, level) {
       new name[33];
       get_user_name(killer, name, 32);
       set_hudmessage(colors[level][0],                 colors[level][1],
   colors[level][2], 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);
       if (is_mode_set(2)) {
           show_hudmessage(0, messages[level], name);
       } else if (is_mode_set(8)) {
           show_hudmessage(killer, messages[level], name);
       }
       if (is_mode_set(1)) {
           client_cmd(0, "spk %s", sounds[level]);
       } else if (is_mode_set(4)) {
           client_cmd(killer, "spk %s", sounds[level]);
       }
   }
   public reset_hud(id) {
       if (is_mode_set(16)) {
           if (kills[id] > levels[0]) {
               client_print(id, print_chat,
                            "* You are on a killstreak with %d kills.",
                            kills[id]);
           } else if (deaths[id] > 1) {
               client_print(id, print_chat,
                            "*  Take  care, you are on a deathstreak with
   %d deaths in a row.",
                            deaths[id]);
           }
       }
   }
   public add_level(id, level, cid) {
       if (! cmd_access(id, level, cid, 3))
           return PLUGIN_HANDLED;
       if (current_level >= MAX_LEVELS) {
           console_print(id, "Maximum levels reached!");
           return PLUGIN_HANDLED;
       }
       new tmp[10];
       read_argv(1, tmp, 9);
       levels[current_level] = strtonum(tmp);
       read_argv(2, sounds[current_level], MAX_SOUND_LENGTH-1);
       read_argv(3, messages[current_level], MAX_MSG_LENGTH-1);
       if (read_argc() > 4) {
           read_argv(4, tmp, 9);
       } else {
           get_cvar_string("pd_streak_color", tmp, 9);
       }
       colors[current_level][2] = strtonum(tmp[6]);
       tmp[6] = 0;
       colors[current_level][1] = strtonum(tmp[3]);
       tmp[3] = 0;
       colors[current_level][0] = strtonum(tmp[0]);
       current_level++;
       return PLUGIN_HANDLED;
   }
   public client_connect(id) {
       kills[id] = 0;
       deaths[id] = 0;
   }
   public plugin_init() {
       register_plugin("PsychoStreak", "0.9.2", "PsychoGuard");
       register_cvar("pd_streak_mode", "abe");
       register_cvar("pd_streak_color", "000100200");
       register_srvcmd("pd_streak_level",   "add_level",  0,  "<#  kills>
   <sound> <message> [color in RRRGGGBBB]");
       register_event("ResetHUD", "reset_hud", "b");
       register_event("DeathMsg", "death_event", "a");
       return PLUGIN_CONTINUE;
   }
