View Single Post
drakunovu6
Member
Join Date: Sep 2017
Old 09-16-2020 , 14:17   Re: [REQ] 1v1 countdown before kill
Reply With Quote #2

Here it is:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

new cvar_countdowng_countdowng_countdown_hud;

enum (+= 100)
{
    
TASK_COUNTDOWN
}

public 
plugin_init()
{
    
register_plugin("Countdown when 1v1""1.0""Drakunovu");
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled");
    
    
cvar_countdown register_cvar("countdown_time""30");
    
    
g_countdown_hud CreateHudSyncObj();
}

public 
event_new_round()
    
remove_task(TASK_COUNTDOWN);

public 
fw_PlayerKilled(victimattackershouldgib)
{
    new 
num;
    static 
players[32];
    
get_players(playersnum"ah");

    switch(
num)
    {
        case 
1remove_task(TASK_COUNTDOWN);
        case 
2:
        {
            if (
cs_get_user_team(players[0]) == cs_get_user_team(players[1])) return HAM_IGNORED;

            
g_countdown get_pcvar_num(cvar_countdown);
            
set_task(1.0"countdown"TASK_COUNTDOWN__"b");
        }
    }

    return 
HAM_IGNORED;
}

public 
countdown()
{
    
set_hudmessage(02550, -1.00.2820.021.00.010.110);
    
ShowSyncHudMsg(0g_countdown_hud"Kill each other in %d or slay!"g_countdown);

    new 
number[20];
    
num_to_word(g_countdownnumbercharsmax(number));
    
client_cmd(0"spk ^"fvox/%s^""number); // you can change the sound right here.

    
g_countdown--;

    if (
g_countdown 0)
    {
        
remove_task(TASK_COUNTDOWN);

        new 
num;
        static 
players[32];
        
get_players(playersnum"ah");

        if (
num == 2)
        {
            
user_kill(players[0]);
            
user_kill(players[1]);
        }

        return;
    }

drakunovu6 is offline