•  
     

Best Round Players Top 3 - AMXX

Código: Selecionar todos

#include <amxmodx>
#include <csx>

#define PLUGIN "Best Round Players Top 3"
#define VERSION "0.0.2"

enum _:CSX_STATS
{
    STATS_KILLS,
    STATS_DEATHS,
    STATS_HS,
    STATS_TKS,
    STATS_SHOTS,
    STATS_HITS,
    STATS_DAMAGE,
    STATS_DUMMY
}

enum _:mDatas
{
    m_iPlayerIndex,
    m_iPlayerStats[CSX_STATS]
}

public plugin_init()
{
    register_plugin( PLUGIN, VERSION, "ConnorMcLeod" )
    register_logevent("Event_Round_End", 2, "1=Round_End")
}

public Event_Round_End()
{
    new playersStats[32][mDatas]
    new players[32], num, player, i, stats[CSX_STATS], bodyhits[8]
    get_players(players, num, "ch")
    if( !num )
    {
        return
    }

    for(i=0; i<num; i++)
    {
        player = players[i]
        get_user_stats(player, stats, bodyhits)
        playersStats[i][m_iPlayerIndex] = player
        playersStats[i][m_iPlayerStats] = stats
    }

    SortCustom2D(playersStats, num, "SortHandler")

    if( num > 3 )
    {
        num = 3
    }

    new szMsg[512], szName[32], n = formatex(szMsg, charsmax(szMsg), "Best Round Players :^n^n")
    
    for(i=0; i<num; i++)
    {
        get_user_name(playersStats[i][m_iPlayerIndex], szName, charsmax(szName))
        n += formatex(szMsg[n], charsmax(szMsg)-n, "%d. ^"%s^" (%d Kills) (%d Damage)^n", i+1, szName, playersStats[i][m_iPlayerStats][STATS_KILLS], playersStats[i][m_iPlayerStats][STATS_DAMAGE])
    }
    set_hudmessage(0, 80, 180, -1.0, 0.10, 0, 0.1, 5.0, 0.1, 0.1, -1)
    show_hudmessage(0, szMsg)
}

public SortHandler(elem1[mDatas], elem2[mDatas], tempPlayersStats[32][mDatas])
{
    new kills1 = elem1[m_iPlayerStats][STATS_KILLS], kills2 = elem2[m_iPlayerStats][STATS_KILLS]
    if( kills1 > kills2 )
    {
        return -1
    }
    else if( kills1 < kills2 )
    {
        return 1
    }

    new dmg1 = elem1[m_iPlayerStats][STATS_DAMAGE], dmg2 = elem2[m_iPlayerStats][STATS_DAMAGE]
    if( dmg1 > dmg2 )
    {
        return -1
    }
    else if( dmg1 < dmg2 )
    {
        return 1
    }

    return 0
}