Иконка ресурса

amxx Top Bomber 0.1.1

Нет прав для скачивания
Для CS 1.6
Автор
Albertio
Исходный код
C++:
#include <amxmodx>
#include <cstrike>
#include <reapi>

new Float:g_KillDeathRatio[MAX_PLAYERS + 1], Float:g_Kills[MAX_PLAYERS + 1], Float:g_Deaths[MAX_PLAYERS + 1];
new g_RoundNum, Float:iMax_KDR;

public plugin_init()
{
    register_plugin("Top Bomber", "0.0.1", "Albertio");

    register_event("HLTV", "Event_RoundStart", "a", "1=0", "2=0");
    register_logevent("LogEvent_RestartGame", 2, "1=Game_Commencing", "1&Restart_Round_");

    bind_pcvar_num(create_cvar("tp_roundnum", "2", FCVAR_NONE, "Раунд с которого начать определять, кому выдать бомбу", true, 2.0), g_RoundNum);

    AutoExecConfig(true, "top_bomber");
}

public client_putinserver(id)
{
    g_KillDeathRatio[id] = 0.0;
}

public Event_RoundStart()
{
    g_RoundNum++;
    if(g_RoundNum >= 2)
    {
        remove_task(1);
        set_task(1.0, "get_top_bomber", 1);
    }
}

public LogEvent_RestartGame()
{
    g_RoundNum = 0;
}

public get_top_bomber()
{
    new iPlayers[32], iPlayersNum, id, iOldBomber;
    new Float:top_player_kdr[3] = {0.0, 0.0, 0.0}, top_player_id[3] = {0, 0, 0};
    get_players(iPlayers, iPlayersNum, "ceh", "TERRORIST");
    for(new i = 0; i < iPlayersNum; i++)
    {
        id = iPlayers[i];
        if(rg_has_item_by_name(id, "weapon_c4"))
        {
            iOldBomber = id;
        }
        g_Kills[id] = float(get_user_frags(id));
        g_Deaths[id] = float(get_user_deaths(id));
        if(g_Kills[id] > 0)
        {
            if(g_Deaths[id] == 0)
            {
                g_KillDeathRatio[id] = g_Kills[id];
            }
            else if(g_Deaths[id] > 0)
            {
                g_KillDeathRatio[id] = g_Kills[id] / g_Deaths[id];
            }
            if(g_KillDeathRatio[id] >= iMax_KDR)
            {
                iMax_KDR = g_KillDeathRatio[id];
                if(iMax_KDR >= top_player_kdr[0])
                {
                    top_player_id[2] = top_player_id[1];
                    top_player_kdr[2] = top_player_kdr[1];
                    top_player_id[1] = top_player_id[0];
                    top_player_kdr[1] = top_player_kdr[0];
                    top_player_id[0] = id;
                    top_player_kdr[0] = iMax_KDR;
                }
                else if(iMax_KDR < top_player_kdr[0])
                {
                    if(iMax_KDR < top_player_kdr[1])
                    {
                        top_player_id[2] = id;
                        top_player_kdr[2] = iMax_KDR;
                    }
                    top_player_id[2] = top_player_id[1];
                    top_player_kdr[2] = top_player_kdr[1];
                    top_player_id[1] = id;
                    top_player_kdr[1] = iMax_KDR;
                }
            }
            else if(g_KillDeathRatio[id] < iMax_KDR)
            {
                if(g_KillDeathRatio[id] >= top_player_kdr[0])
                {
                    top_player_id[2] = top_player_id[1];
                    top_player_kdr[2] = top_player_kdr[1];
                    top_player_id[1] = top_player_id[0];
                    top_player_kdr[1] = top_player_kdr[0];
                    top_player_id[0] = id;
                    top_player_kdr[0] = g_KillDeathRatio[id];
                }
                else if(g_KillDeathRatio[id] < top_player_kdr[0])
                {
                    if(g_KillDeathRatio[id] < top_player_kdr[1])
                    {
                        top_player_id[2] = id;
                        top_player_kdr[2] = g_KillDeathRatio[id];
                    }
                    top_player_id[2] = top_player_id[1];
                    top_player_kdr[2] = top_player_kdr[1];
                    top_player_id[1] = id;
                    top_player_kdr[1] = g_KillDeathRatio[id];
                }
            }           
        }
    }
    new iNumTops;
    for(new i; i < charsmax(top_player_id); i++)
    {
        if(top_player_id[i])
        {
            iNumTops++;
        }
    }
    switch(iNumTops)
    {
        case 0: return;
        case 1:
        {
            if(iOldBomber != top_player_id[0])
            {
                rg_transfer_c4(iOldBomber, top_player_id[0]);
            }
        }
        case 2:
        {
            rg_transfer_c4(iOldBomber, top_player_id[random(1)]);
        }
        case 3:
        {
            rg_transfer_c4(iOldBomber, top_player_id[random(2)]);
        }
    }
}
P
Поддержка русского языка
Да
Совместимость
  1. HLDS
  2. REHLDS
Сверху Снизу