statsmarquee.amxx statsx_sql

AXM

Сообщения
85
Реакции
2
https://hl-servers.ru/uploads/posts/2017-10/thumbs/1509389274_56565466666.png
плагин Stats Marquee. Который покажет ТОП лучших игроков на сервере в правом нижнем углу экрана.

Товарищи прошу помощи) подскажите как сделать вывод статистики из csstatsx_sql

Код:
#include <amxmodx>
#include <csx>

new statsm, cvPlrAmt, cvFullTime, cvTimeBetw, cvVertLoc

public plugin_init()
{
    register_plugin("Stats Marquee","1.2","Travo");
    register_cvar("travo_statmarquee","v1.2",FCVAR_SERVER|FCVAR_UNLOGGED|FCVAR_SPONLY);
    cvPlrAmt = register_cvar("amx_marqplayeramount","40");
    cvVertLoc = register_cvar("amx_marqvertlocation","2");
    cvFullTime = register_cvar("amx_marqfulltime","600.0");
    cvTimeBetw = register_cvar("amx_marqtimebetween","6.0");
    set_task(15.0,"displayplr",0,"",0,"a",1);
}

public displayplr()
{
    new Stats[8], Body[8], Name[31], Float:VertLoc2;
    new PlrAmt = get_pcvar_num(cvPlrAmt);
    new VertLoc = get_pcvar_num(cvVertLoc);
    new Float:FullTime = get_pcvar_float(cvFullTime);
    new Float:TimeBetw = get_pcvar_float(cvTimeBetw);

    if(VertLoc==1)
    VertLoc2 = -0.74;
    else
    VertLoc2 = 0.77;

    get_stats(statsm, Stats, Body, Name, 31);

    statsm++;
   
    set_hudmessage(0, 240, 10, 0.70, VertLoc2, 0, TimeBetw, TimeBetw, 0.5, 0.15, -1);
    show_hudmessage(0,"Топ %d игроков на сервере^n%s^nРанг <%d> | Фраги - %d | Смерти - %d", PlrAmt, Name, statsm, Stats[0], Stats[1]);  

    if(statsm >= PlrAmt)
    {
        statsm = 0
        set_task(FullTime,"displayplr",0,"",0,"a",1);
    }
    else
    {
        set_task(TimeBetw,"displayplr",0,"",0,"a",1);
    }

    return PLUGIN_CONTINUE
}
 
Последнее редактирование модератором:
Сообщения
775
Реакции
293
Помог
11 раз(а)
AXM, держи в качестве примера
Код:
#include <amxmodx>

#if AMXX_VERSION_NUM < 183
    #include <colorchat>
    #define client_disconnected client_disconnect
    #define client_connected client_connect
#endif

#define DISABLED_BY_DEFAULT            // Закомментировать, чтобы было выключено по default
#define SQL                            // Закомментировать, если используется статистика csstats.dat

#if defined SQL
    #include <csstatsx_sql>
#else
    #include <csx>
#endif

#define MAX_PLAYERS 32


new bool:g_RestartAttempt[MAX_PLAYERS+1]

new g_oldrank[MAX_PLAYERS+1]

#if defined DISABLED_BY_DEFAULT
new bool:disabled[MAX_PLAYERS+1] = {false, ...}
#else
new bool:disabled[MAX_PLAYERS+1]
#endif

new inforank

public plugin_init()
{
    register_plugin("Info Rank", "0.2", "maFFyoZZyk")

    inforank = register_cvar("amx_inforank", "1")

    register_event("TextMsg", "eRestartAttempt", "a", "2=#Game_will_restart_in")
    register_event("ResetHUD", "eResetHUD", "be")

    register_clcmd("say /inforank","switchCmd", 0, "- enable/disable info rank messages")
    register_clcmd("say_team /inforank","switchCmd", 0, "- enable/disable info rank messages")
    register_clcmd("fullupdate", "fullupdateCmd")
}

public fullupdateCmd()    return PLUGIN_HANDLED_MAIN

public eRestartAttempt()
{
    if(!get_pcvar_num(inforank))    return

    new players[MAX_PLAYERS], num
    get_players(players, num, "a")
    for (new i; i < num; ++i)    g_RestartAttempt[players[i]] = true
}

public eResetHUD(id)
{
    if (g_RestartAttempt[id])
    {
        g_RestartAttempt[id] = false
        return
    }
    
    if(!get_pcvar_num(inforank))return
    if(disabled[id])    return

    event_player_spawn(id)
}
 
public event_player_spawn(id)
{

    new osef[8]
    #if defined SQL
    new rank = get_user_stats_sql(id,osef,osef)
    new maxrank = get_statsnum_sql()
    #else
    new rank = get_user_stats(id, osef, osef)
    new maxrank = get_statsnum()
    #endif
    
    if(g_oldrank[id] == 0)    g_oldrank[id] = rank
    
    new diff = g_oldrank[id] - rank
    g_oldrank[id] = rank
    
    if(diff > 0)    client_print_color(id, -2, "^1[^4GFS^1] Вы ^4поднялись^1 на [^4%i^1] позиций в статистике!", diff)
    else if(diff < 0)    client_print_color(id, -2, "^1[^4GFS^1] Вы ^3опустились^1 на [^4%i^1] позиций в статистике!", abs(diff))
    client_print_color(id, -2, "^1[^4GFS^1] Вы ^4занимаете^1 [^4%i-e^1] место из [^3%i^1]", rank, maxrank)
}

public switchCmd(id)
{
    if(!get_pcvar_num(inforank))
        return PLUGIN_CONTINUE

    if(disabled[id]) {
        disabled[id] = false
        client_cmd(id, "setinfo _ir 1")
        client_print_color(id, -2, "^1[^4GFS^1] Сообщения ^4включены^1.")
    }
    else {
        disabled[id] = true
        client_cmd(id, "setinfo _ir 0")
        client_print_color(id, -2, "^1[^4GFS^1] Сообщения ^3выключены^1.")
    }
    return PLUGIN_CONTINUE
}

public client_connected(id)
{
    new osef[8]
    #if defined SQL
    g_oldrank[id] = get_user_stats_sql(id, osef, osef)
    #else
    g_oldrank[id] = get_user_stats(id, osef, osef)   
    #endif
    new enable[2]
    get_user_info(id, "_ir", enable, 1)
    if(!enable[0])    return

    if(enable[0]=='1')    disabled[id] = false
    else    disabled[id] = true
}

public client_disconnected(id) {
    g_oldrank[id] = 0

#if defined DISABLED_BY_DEFAULT
    disabled[id] = false
#else
    disabled[id] = true
#endif
}
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу