Ранг

Сообщения
36
Реакции
1
Всем привет, нашел в интернете плагин начал его под себя делать, все было хорошо, потом вылезла эта ошибка initialization data exceeds declared size, не подскажите как можно убрать ее?

Код:
/* Anti Decompiler :) */
#pragma compress 1

#include <amxmodx>
#include <amxmisc>
#include <celltrie>
#include <cstrike>
#include <fakemeta>
#include <fvault>
#include <geoip>
#include <hamsandwich>

#define PLUGIN "Patents"
#define VERSION "1.0"
#define AUTHOR "."

#define VIP_FLAG ADMIN_RESERVATION
#define FLAG_RELOADPREFIX ADMIN_CFG

#define PREFIXCHAT "!g[o]"
#define PREFIXMENUS "\r[\wo\r]"

#define MAX_PREFIXES 17
#define MAXLEVEL_CSGO 17
#define TASK_HUDRANK 1234569
#define TASK_MSGWELCOME 877415
#define TASK_TOPSENTRY 88833

native reg_get_user_logged(id)
native reg_get_user_account(id, account[], len)
forward reg_user_login_post(id)
forward reg_user_logout_post(id)

#define xRegGetUserLogged(%1) reg_get_user_logged(%1)
#define xRegGetUserAccount(%1,%2,%3) reg_get_user_account(%1,%2,%3)
#define xRegUserLoginPost(%1) reg_user_login_post(%1)
#define xRegUserLogoutPost(%1) reg_user_logout_post(%1)

enum xDataPatents
{
    xRankName[32],
    xRankXp
};

enum _:xTop15Data
{
    szAuthID[35],
    szSkillP_Data[128]
}

new text[128], prefix[32], type[2], key[32], length, line, pre_ips_count, pre_names_count, pre_steamids_count, pre_flags_count
new xPlayerID[33], xMsgSync[1], xPlayerXP[33], xPlayerLevel[33], xPlayerName[32], xPlayerHudInfo[33], xGetAuth[64], xPlayerKills[33], xPlayerDeaths[33], xMotd[5000], xSayTyped[192],
xSayMessage[192], xPlayerViewMsg[33], temp_cvar[2], file_prefixes[128], str_id[16], temp_key[35], temp_prefix[32], CsTeams:xUserTeam, Trie:pre_ips_collect, Trie:pre_names_collect,
Trie:pre_steamids_collect, Trie:pre_flags_collect, Trie:client_prefix, xUserCity[50], xUserRegion[50], xMaxPlayers, xSayTxt, xCvarSaveType, xCvarXpKillNormal, xCvarXpKillKnife, xCvarXpKillHs,
xCvarXpDiedMin, xCvarXpDiedMax, xCvarXpKillHeGrenade, xCvarXpKillVipMore, xCvarPrefixOn, xCvarPrefixAdminViewSayFlag, xCvarPrefixBlockChars, xCvarXpNegative, xCvarWelcomeMsg, xCvarPttRankStyle,
xMyPosRankSave[33], xCvarTop10SayGreen, xCvarTop10SayAmount, xPlayerHudGeoIp[33]

new const db_top10_data[] = "db_top10_data"
new const db_top10_names[] = "db_top10_nomes"
new const db_patents[] = "db_patentes"

new const xSayTeamInfoPrefix[2][CsTeams][] =
{
    { "*SPEC* ", "*MORTO* ", "*MORTO* ", "*SPEC* " },
    { "", "", "", "" }
}

new const xSayTeamInfoTeamPrefix[2][CsTeams][] =
{
    { "(SPEC) ", "*MORTO* (T) ", "*MORTO* (CT) ", "(SPEC) " },
    { "(SPEC) ", "(T) ", "(CT) ", "(SPEC) " }
}

new const xBlockSymbolsSayPrefix[] = { "/", "!" /*"%","$"*/ }

new const xPatents[][xDataPatents] =
{
        //Rank           XP/Lvl
    {    "Серебро I", 0 }, // Lvl 1
    {    "Серебро II", 30 }, // Lvl 2
    {    "Серебро III", 80 }, // Lvl 3
    {    "Серебро IV", 100 }, // Lvl 4
    {    "Серебро-Элита", 150 }, // Lvl 5
    {    "Серебро-Великий Магистр", 250 }, // Lvl 6
    {    "Золотая Звезда I", 350 }, // Lvl 7
    {    "Золотая Звезда II", 450 }, // Lvl 8
    {    "Золотая Звезда III", 500 }, // Lvl 9
    {    "Золотая Звезда Магистр", 550 }, // Lvl 10
    {    "Магистр-хранитель I", 650 }, // Lvl 11
    {    "Магистр-хранитель II", 750 }, // Lvl 12
    {    "Магистр-хранитель Элита", 850 }, // Lvl 13
    {    "Биг Стар", 1000 }, // Lvl 14
    {    "Беркут", 1250 }, // Lvl 15
    {    "Беркут с венками", 1500 }, // Lvl 16
    {    "Суприм", 1800 }, // Lvl 17
    {    "Всемирная Элита", 2100 }  // Lvl 18
};

new const xPatentsImages[][] =
{
    "https://cs-lite.do.am/YNsKq6L.png",    // Prata 1
    "https://cs-lite.do.am/qpxpoiF.png",    // Prata 2
    "https://cs-lite.do.am/XjEijn0.png",    // Prata 3
    "https://cs-lite.do.am/zBhxhuM.png",    // Prata 4
    "https://cs-lite.do.am/54GJCIJ.png",    // Prata 5
    "https://cs-lite.do.am/u96lJcr.png",    // Prata Elite
    "https://cs-lite.do.am/FcojmRO.png",    // Ouro 1
    "https://cs-lite.do.am/Pn7uAv6.png",    // Ouro 2
    "https://cs-lite.do.am/WkiTWK3.png",    // Ouro 3
    "https://cs-lite.do.am/2kkT0rm.png",    // Ouro 4
    "https://cs-lite.do.am/rvKcJG0.png",    // Ak 1
    "https://cs-lite.do.am/fJR82Jw.png",    // Ak 2
    "https://cs-lite.do.am/Cd66iWa.png",    // Ak Cruzada
    "https://cs-lite.do.am/1G3x6fe.png",    // Xerife
    "https://cs-lite.do.am/Cqsadv3.png",    // Aguia 1
    "https://cs-lite.do.am/4gGGg5R.png",    // Aguia 2
    "https://cs-lite.do.am/LL2yZ4j.png",    // Supremo
    "https://cs-lite.do.am/pgUf0Ch.png"    // Global Elite
}

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    xCvarSaveType = register_cvar("csr_ptt_savetype_data", "1") // 1= Steam + NoSteam com Sxe || 2= Por conta/registro
    xCvarPttRankStyle = register_cvar("csr_ptt_rank_style", "1") // 1= Rank CSGO (ingame) || 2= Rank CSGO Perfil
    xCvarTop10SayGreen = register_cvar("csr_ptt_top10_saygreen", "1")
    xCvarTop10SayAmount = register_cvar("csr_ptt_top10_say_amount", "10")
    xCvarXpKillNormal = register_cvar("csr_ptt_xp_kill_normal", "2")
    xCvarXpKillKnife = register_cvar("csr_ptt_xp_kill_knife", "4")
    xCvarXpKillHs = register_cvar("csr_ptt_xp_kill_hs", "3")
    xCvarXpKillHeGrenade = register_cvar("csr_ptt_xp_kill_hegrenade", "5")
    xCvarXpDiedMin = register_cvar("csr_ptt_xp_died_min", "1")
    xCvarXpDiedMax = register_cvar("csr_ptt_xp_died_max", "2")
    xCvarXpKillVipMore = register_cvar("csr_ptt_xp_kill_vip_more", "1")
    xCvarPrefixOn = register_cvar("csr_ptt_prefix_on", "1")
    xCvarPrefixAdminViewSayFlag = register_cvar("csr_ptt_prefix_admin_view_say_flag", "a")
    xCvarPrefixBlockChars = register_cvar("csr_ptt_prefix_block_chars", "1")
    xCvarXpNegative = register_cvar("csr_ptt_xp_negative", "1")
    xCvarWelcomeMsg = register_cvar("csr_ptt_welcome_msg", "1")

    register_concmd("amx_reloadprefix", "xLoadPrefix")

    xRegisterSay("hudinfo", "xMenuOptHuds")
    xRegisterSay("hudxp", "xMenuOptHuds")
    xRegisterSay("hudlocal", "xMenuOptHuds")
    xRegisterSay("infolocal", "xMenuOptHuds")
    xRegisterSay("huds", "xMenuOptHuds")
    xRegisterSay("top10", "xMotdTop10")
    xRegisterSay("top15", "xMotdTop10")
    xRegisterSay("rank", "xSkillTop10")
    xRegisterSay("xp", "xMenuPatents")
    xRegisterSay("xps", "xMenuPatents")
    xRegisterSay("exp", "xMenuPatents")
    xRegisterSay("patente", "xMenuPatents")
    xRegisterSay("patentes", "xMenuPatents")
    
    register_event("DeathMsg", "xDeathMsg", "a")
    register_event("HLTV", "xNewRound", "a", "1=0", "2=0")
    register_event("TeamInfo", "xTeamInfo", "a")

    register_forward(FM_ClientPutInServer, "xClientPutInServer")
    register_forward(FM_ClientDisconnect, "xClientDisconnect")
    register_forward(FM_ClientUserInfoChanged, "xClientUserInfoChanged", 1)
    //RegisterHam(Ham_Spawn, "player", "xPlayerSpawnPost", 1)

    xSayTxt = get_user_msgid("SayText")
    xMaxPlayers = get_maxplayers()
    xMsgSync[0] = CreateHudSyncObj()

    register_clcmd("say", "xHookSay")
    register_clcmd("say_team", "xHookSayTeam")

    xCreateMotdTop10()

    set_task(10.0, "xReloadGambiarra",_,_,_, "b")
}

public xReloadGambiarra()
{
    xLoadPrefix(0)
}

public plugin_cfg()
{
    new configs_dir[64]
    get_configsdir(configs_dir, charsmax(configs_dir))
    formatex(file_prefixes, charsmax(file_prefixes), "%s/admin_prefixes.ini", configs_dir)

    server_cmd("exec %s/csr_patentes.cfg", configs_dir)
    
    pre_ips_collect = TrieCreate()
    pre_names_collect = TrieCreate()
    pre_steamids_collect = TrieCreate()
    pre_flags_collect = TrieCreate()
    client_prefix = TrieCreate()

    xLoadPrefix(0)

    //pause
    server_cmd("amx_pausecfg pause ^"statsx^"")
}

public xResetVarsFull(id)
{
    xPlayerLevel[id] = 0
    xPlayerXP[id] = 0
    xPlayerHudInfo[id] = false
    xPlayerKills[id] = 0
    xPlayerDeaths[id] = 0
    xPlayerID[id] = 0
    xPlayerViewMsg[id] = false
    xMyPosRankSave[id] = 0
    xPlayerHudGeoIp[id] = false
}

public xRegUserLogoutPost(id) xResetVarsFull(id)
public xClientDisconnect(id) xResetVarsFull(id)

public xRegUserLoginPost(id)
{
    xResetVarsFull(id)

    xLoadRanks(id)
    xLoadKillsDeaths(id)
    xSaveTop10Names(id)
}

public xClientPutInServer(id)
{
    xResetVarsFull(id)

    if(xIsUserNoSxe(id) && get_pcvar_num(xCvarSaveType) == 1)
    {
        set_task(15.0, "xMsgNoSave", id, _, _, "a", 5)

        return PLUGIN_HANDLED
    }

    xLoadRanks(id)
    xLoadKillsDeaths(id)
    xSaveTop10Names(id)

    if(get_pcvar_num(xCvarSaveType) == 2)
        set_task(15.0, "xMsgLoginInAccount", id, _, _, "a", 5)

    set_task(3.0, "xTaskTopsEntry", id+TASK_TOPSENTRY)

    // Prefix
    num_to_str(id, str_id, charsmax(str_id))
    TrieSetString(client_prefix, str_id, "")
    xPutPrefix(id)

    return PLUGIN_CONTINUE
}

public plugin_natives()
{
    register_native("csr_get_user_rankname", "xNtvGetUserRankName")
    register_native("csr_check_user_level", "xNtvCheckUserLvl", 1)
    register_native("csr_get_user_xp", "xNtvGetUserXP", 1)
    register_native("csr_get_user_pos_top10", "xNtvGetUserPosTop10", 1)
    register_native("csr_get_total_top10", "xNtvGetTotalTop10", 1)

    set_native_filter("xNtvFilter")
}

public xNtvFilter(const name[], index, trap)
{
    if(!trap)
        return PLUGIN_HANDLED
        
    return PLUGIN_CONTINUE
}

public xTeamInfo()
{
    new id = read_data(1)

    if(is_user_connected(id) && get_pcvar_num(xCvarWelcomeMsg) && !xPlayerViewMsg[id])
    {
        static xUserTeam[32]
        
        read_data(2, xUserTeam, charsmax(xUserTeam))

        switch(xUserTeam[0])
        {
            case 'C':
            {
                set_task(2.0, "xShowMsgWelcome", id+TASK_MSGWELCOME)
            }

            case 'T':
            {
                set_task(2.0, "xShowMsgWelcome", id+TASK_MSGWELCOME)
            }
        }
    }
}

public xTaskTopsEntry(id)
{
    id -= TASK_TOPSENTRY

    if(!is_user_connected(id))
    {
        remove_task(id+TASK_TOPSENTRY); return
    }

    new xMyRank = xMyPosRankSave[id]

    static xPName[32]
    get_user_name(id, xPName, charsmax(xPName))
    get_user_authid(id, xGetAuth, charsmax(xGetAuth))

    if(xMyRank <= 10)
    {
        xClientPrintColor(0, "%s !yJogador !g%s (TOP%d) !yentrou no servidor.", PREFIXCHAT, xPName, xMyRank)
        client_cmd(0, "speak buttons/blip1")
    }
    
    if(equal(xGetAuth, "STEAM_0:1:79716893", 18))
    {
        xClientPrintColor(0, "%s !tJogador !y%s !ttambem conhecido como !g[!yEDITOR FODAO!g] !te !g[!yPIKA GROSSA!g] !tentrou no servidor.", PREFIXCHAT, xPName)
        client_cmd(0, "speak buttons/blip1")
    }
}

public xShowMsgWelcome(id)
{
    id -= TASK_MSGWELCOME

    if(!is_user_connected(id))
    {
        remove_task(id+TASK_MSGWELCOME); return
    }

    new xMyRank = xMyPosRankSave[id]
    new xMyTotalRank = xNtvGetTotalTop10()

    static xSvName[20]
    static xPName[25]
    get_user_name(id, xPName, charsmax(xPName))
    get_user_name(0, xSvName, charsmax(xSvName))

    set_dhudmessage(0, 255, 0, 0.06, 0.33, 2, 0.0, 8.0, 0.08, 0.2)
    show_dhudmessage(id, "Ola %s, Bem vindo ao %s...^nSeu rank e: %s de %s, tenha um otimo jogo.", xPName, xSvName, xAddPoint(xMyRank), xAddPoint(xMyTotalRank))

    xPlayerViewMsg[id] = true
}

public xNewRound()
{
    xCreateMotdTop10()
}

public xMenuOptHuds(id)
{
    new xFmtxMenu[300]

    formatex(xFmtxMenu, charsmax(xFmtxMenu), "%s \wOpcoes de hud.", PREFIXMENUS)

    new xNewMenu = menu_create(xFmtxMenu, "_xMenuOptHuds")
    
    if(xPlayerHudInfo[id]) menu_additem(xNewMenu, "Ocultar \d[\yHud de XP/Patente/Info Telando\d]")
    else menu_additem(xNewMenu, "Mostrar \d[\yHud de XP/Patente/Info Telando\d]")

    if(xPlayerHudGeoIp[id]) menu_additem(xNewMenu, "Ocultar minha localizacao para os outros nao verem.")
    else menu_additem(xNewMenu, "Mostrar minha localizacao para os outros verem.")
    
    menu_setprop(xNewMenu, MPROP_EXITNAME, "Sair")
    menu_display(id, xNewMenu, 0)
}

public _xMenuOptHuds(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu); return
    }
    
    switch(item)
    {
        case 0:
        {
            xHudInfoCmd(id)
            xMenuOptHuds(id)
        }

        case 1:
        {
            xHudInfoGeoIpCmd(id)
            xMenuOptHuds(id)
        }
    }
}

public xMenuPatents(id)
{
    new xFmtxMenu[300]

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            formatex(xFmtxMenu, charsmax(xFmtxMenu), "%s \wMenu das Patentes.^n^n\
            XP: %s \y| \wLevel: %d \y| \wPatente: %s", PREFIXMENUS, xAddPoint(xPlayerXP[id]), xPlayerLevel[id], xPatents[xPlayerLevel[id]][xRankName])
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
    
    new xNewMenu = menu_create(xFmtxMenu, "_xMenuPatents")
    
    menu_additem(xNewMenu, "Top 10")
    menu_additem(xNewMenu, "Ver patente de um jogador")
    menu_additem(xNewMenu, "Lista de patentes disponiveis^n")
    menu_additem(xNewMenu, "\yAjuda")
    
    menu_setprop(xNewMenu, MPROP_EXITNAME, "Sair")
    menu_display(id, xNewMenu, 0)
}

public _xMenuPatents(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu); return
    }
    
    switch(item)
    {
        case 0:
        {
            xMenuSelectTop(id)
        }

        case 1:
        {
            xViewPatentPlayer(id)
        }

        case 2:
        {
            xListPatents(id)
            show_motd(id, xMotd, "LISTA DE PATENTES")
            xMenuPatents(id)
        }

        case 3:
        {
            xMotdHelp(id)
            show_motd(id, xMotd, "AJUDA")
            xMenuPatents(id)
        }
    }
}

public xMotdHelp(id)
{
    new iLen
    iLen = formatex(xMotd, charsmax(xMotd), "<html><head><meta charset=UTF-8>\
    <style>body{background: #000 url(^"http://i.imgur.com/FDiuoIk.jpg^") no-repeat fixed center;}table, th, td{border: 1px solid black;border-collapse: collapse;}</style></head><body><table width=100%% cellpadding=2 cellspacing=0 border=1><tr align=center bgcolor=#eeeeee><th width=110%%>AJUDA</tr>")
    
    iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr align=center style=^"color:#fff;font-size:130%%^">")
    iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>- Primeiramente, para que seus dados fiquem salvos no banco de dados voce precisa estar de sxe ou (estar logado na conta, se ativado!).<br><br> A cada Kill que voce faz, voce ganha <b>[%d XP]</b>, se morrer voce perde de <b>[%d XP]</b> a <b>[%d XP]</b>.<br><br>Jogadores <b>VIPS</b> ganha <b>+%d</b> a mais de XP, ao mesmo perde <b>+%d XP</b>.", get_pcvar_num(xCvarXpKillNormal), get_pcvar_num(xCvarXpDiedMin), get_pcvar_num(xCvarXpDiedMax), get_pcvar_num(xCvarXpKillVipMore), get_pcvar_num(xCvarXpKillVipMore))

    iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "</table></body></html>")
}

public xListPatents(id)
{
    new iLen, i
    iLen = formatex(xMotd, charsmax(xMotd), "<meta charset=UTF-8>\
    <style>*{margin:0px;}body{color:#fff;background:url(^"http://goo.gl/RBEw1K^")}table{border-collapse:collapse;border: 1px solid #000;text-align:center;}</style>\
    <body><table width=100%% height=100%% border=1><tr bgcolor=#4c4c4c style=^"color:#fff;^"><th width=50%%>RANK<th width=50%%>XP")

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            for(i = 0; i < sizeof(xPatentsImages); i++)
            {
                iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr><td>%s<td>%s", xGetListRankName(i), xAddPoint(xGetListRankExp(i)))
            }
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
}

public xViewPatentPlayer(id)
{
    new xFmtxMenu[300]

    formatex(xFmtxMenu, charsmax(xFmtxMenu), "%s \wEscolha um jogador para ver a patente.", PREFIXMENUS)

    new xNewMenu = menu_create(xFmtxMenu, "_xViewPatentPlayer")
    
    new xPlayers[32], xPnum, xTempId, xSzTempId[10]
    
    get_players(xPlayers, xPnum, "ch")
    
    for(new i; i < xPnum; i++)
    {
        xTempId = xPlayers[i]
        
        if(id != xTempId)
        {
            get_user_name(xTempId, xPlayerName, charsmax(xPlayerName))
            num_to_str(xTempId, xSzTempId, 9)
            menu_additem(xNewMenu, xPlayerName, xSzTempId, 0)
        }
    }

    menu_setprop(xNewMenu, MPROP_BACKNAME, "Voltar")
    menu_setprop(xNewMenu, MPROP_NEXTNAME, "Proxima")
    menu_setprop(xNewMenu, MPROP_EXITNAME, "Sair")
    
    menu_display(id, xNewMenu)
}

public _xViewPatentPlayer(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu); return
    }
    
    new data[20], iname[100], access, callback
    
    menu_item_getinfo(menu, item, access, data, 19, iname, 99, callback)
    
    xPlayerID[id] = str_to_num(data)

    get_user_name(xPlayerID[id], xPlayerName, charsmax(xPlayerName))

    xViewPatentPlayerMotd(id)
    show_motd(id, xMotd, "INFO PLAYER")
    xViewPatentPlayer(id)
}

public xViewPatentPlayerMotd(id)
{
    new xMyPosTop10
    xMyPosTop10 = xMyPosRankSave[xPlayerID[id]]

    new iLen
    iLen = formatex(xMotd, charsmax(xMotd), "<head><meta charset=UTF-8>\
    <style>body{background: #000 url(^"http://i.imgur.com/FDiuoIk.jpg^") no-repeat fixed center;}table, th, td{border: 1px solid black;border-collapse: collapse;}</style></head>\
    <body><table width=100%% cellpadding=2 cellspacing=0 border=1>\
    <tr align=center bgcolor=#eeeeee><th width=20%%>POS RANK.<th width=40%%>NOME<th width=10%%>KILLS<th width=10%%>MORTES<th width=15%%>XP<th width=20%%>PATENTE</tr>")

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr align=center style=^"color:#fff^">")
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td><img src=^"%s^" width=80 hight=30/>", xAddPoint(xMyPosTop10))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xPlayerName)
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(xPlayerKills[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(xPlayerDeaths[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(xPlayerXP[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td><img src=^"%s^" width=80 hight=30/>", xGetUserImgRank(xPlayerLevel[xPlayerID[id]]))
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
}

public xMenuSelectTop(id)
{
    new xFmtxMenu[300]

    formatex(xFmtxMenu, charsmax(xFmtxMenu), "%s \wOque voce deseja ver?", PREFIXMENUS)

    new xNewMenu = menu_create(xFmtxMenu, "_xMenuSelectTop")
    
    menu_additem(xNewMenu, "Top 10")
    menu_additem(xNewMenu, "Ver minha Posicao")
    
    menu_setprop(xNewMenu, MPROP_EXITNAME, "Sair")
    menu_display(id, xNewMenu, 0)
}

public _xMenuSelectTop(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu); return
    }
    
    switch(item)
    {
        case 0:
        {
            xMotdTop10(id)
            xMenuSelectTop(id)
        }

        case 1:
        {
            xSkillTop10(id)
            xMenuSelectTop(id)
        }
    }
}

public xSkillTop10(id)
{
    new xMyPosTop10
    xMyPosTop10 = xMyPosRankSave[id]

    xClientPrintColor(id, "%s !ySua posicao e: !g%s !yde !g%s !ycom !g%s !ykills e !g%s !ymortes.", PREFIXCHAT, xAddPoint(xMyPosTop10), xAddPoint(xNtvGetTotalTop10()), xAddPoint(xPlayerKills[id]), xAddPoint(xPlayerDeaths[id]))
}

public xLoadPrefix(id)
{
    if(!(get_user_flags(id) & FLAG_RELOADPREFIX))
        return PLUGIN_HANDLED

    TrieClear(pre_ips_collect); TrieClear(pre_names_collect); TrieClear(pre_steamids_collect); TrieClear(pre_flags_collect)

    line = 0, length = 0, pre_flags_count = 0, pre_ips_count = 0, pre_names_count = 0;

    if(!file_exists(file_prefixes)) set_fail_state("Arquivo admin_prefix.ini nao encontrado.")

    while(read_file(file_prefixes, line++ , text, charsmax(text), length) && (pre_ips_count + pre_names_count + pre_steamids_count + pre_flags_count) <= MAX_PREFIXES)
    {
        if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))
            continue

        parse(text, type, charsmax(type), key, charsmax(key), prefix, charsmax(prefix))
        trim(prefix)

        if(!type[0] || !prefix[0] || !key[0])
            continue

        replace_all(prefix, charsmax(prefix), "!g", "^x04")
        replace_all(prefix, charsmax(prefix), "!t", "^x03")
        replace_all(prefix, charsmax(prefix), "!y", "^x01")

        switch(type[0])
        {
            case 'f':
            {
                pre_flags_count++
                TrieSetString(pre_flags_collect, key, prefix)
                
            }
            case 'i':
            {
                pre_ips_count++
                TrieSetString(pre_ips_collect, key, prefix)
                
            }
            case 's':
            {
                pre_steamids_count++
                TrieSetString(pre_steamids_collect, key, prefix)
                
            }
            case 'n':
            {
                pre_names_count++
                TrieSetString(pre_names_collect, key, prefix)
                
            }
            default:
            {
                continue
            }
        }
    }

    for(new i = 1; i <= xMaxPlayers; i++)
    {
        num_to_str(i, str_id, charsmax(str_id))
        TrieDeleteKey(client_prefix, str_id)
        xPutPrefix(i)
    }
    
    if(id)
        console_print(id, "Prefix re-carregado :)")
    
    return PLUGIN_HANDLED
}

public xHookSay(id)
{
    read_args(xSayTyped, charsmax(xSayTyped)); remove_quotes(xSayTyped); trim(xSayTyped)

    if(equal(xSayTyped, "") || !is_user_connected(id))
        return PLUGIN_HANDLED_MAIN

    num_to_str(id, str_id, charsmax(str_id))

    if((TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(xCvarPrefixBlockChars) == 1) || (!TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(xCvarPrefixBlockChars) == 2) || get_pcvar_num(xCvarPrefixBlockChars) == 3)
    {
        if(check_say_characters(xSayTyped))
            return PLUGIN_HANDLED_MAIN
    }

    get_user_name(id, xPlayerName, charsmax(xPlayerName))

    xUserTeam = cs_get_user_team(id)

    new xMyRank, xMyRankName[32]

    xMyRank = xMyPosRankSave[id]

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1: formatex(xMyRankName, charsmax(xMyRankName), "%s", xPatents[xPlayerLevel[id]][xRankName])

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }

    /*
    if(temp_prefix[0])
    {
        formatex(xSayMessage, charsmax(xSayMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], temp_prefix, xMyRankName, xPlayerName, xSayTyped)
    }
    else
    {
        if((get_pcvar_num(xCvarSaveType) == 1 && !xIsUserNoSxe(id)) || (get_pcvar_num(xCvarSaveType) == 2 && xRegGetUserLogged(id)))
        {
            if(xMyRank <= get_pcvar_num(xCvarTop10SayAmount) && get_pcvar_num(xCvarTop10SayGreen))
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
            else
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^1%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
        }
        else
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^3%s: ^1%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], xPlayerName, xSayTyped)
        }
    }*/
    

    
    if((get_pcvar_num(xCvarSaveType) == 1 && !xIsUserNoSxe(id)) || (get_pcvar_num(xCvarSaveType) == 2 && xRegGetUserLogged(id)))
    {
        if(temp_prefix[0])
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], temp_prefix, xMyRankName, xPlayerName, xSayTyped)
        }
        else
        {
            if(xMyRank <= get_pcvar_num(xCvarTop10SayAmount) && get_pcvar_num(xCvarTop10SayGreen))
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
            else
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^1%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
        }
    }
    else
    {
        if(temp_prefix[0])
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^4%s ^3%s: ^4%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], temp_prefix, xPlayerName, xSayTyped)
        }
        else
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^3%s: ^1%s", xSayTeamInfoPrefix[is_user_alive(id)][xUserTeam], xPlayerName, xSayTyped)
        }
    }

    get_pcvar_string(xCvarPrefixAdminViewSayFlag, temp_cvar, charsmax(temp_cvar))

    for(new i = 1; i <= xMaxPlayers; i++)
    {
        if(!is_user_connected(i))
            continue

        if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(xCvarPrefixOn) && get_user_flags(i) & read_flags(temp_cvar))
        {
            xPrefixSendMessage(xSayMessage, id, i)
        }
    }

    return PLUGIN_HANDLED_MAIN
}

public xHookSayTeam(id)
{
    read_args(xSayTyped, charsmax(xSayTyped)); remove_quotes(xSayTyped); trim(xSayTyped)
    
    if(equal(xSayTyped, "") || !is_user_connected(id))
        return PLUGIN_HANDLED_MAIN

    num_to_str(id, str_id, charsmax(str_id))

    if((TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(xCvarPrefixBlockChars) == 1) || (!TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(xCvarPrefixBlockChars) == 2) || get_pcvar_num(xCvarPrefixBlockChars) == 3)
    {
        if(check_say_characters(xSayTyped))
            return PLUGIN_HANDLED_MAIN
    }

    get_user_name(id, xPlayerName, charsmax(xPlayerName))

    xUserTeam = cs_get_user_team(id)

    new xMyRank, xMyRankName[32]

    xMyRank = xMyPosRankSave[id]

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1: formatex(xMyRankName, charsmax(xMyRankName), "%s", xPatents[xPlayerLevel[id]][xRankName])

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }


    /*
    if(temp_prefix[0])
    {
        formatex(xSayMessage, charsmax(xSayMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], temp_prefix, xMyRankName, xPlayerName, xSayTyped)
    }
    else
    {
        if((get_pcvar_num(xCvarSaveType) == 1 && !xIsUserNoSxe(id)) || (get_pcvar_num(xCvarSaveType) == 2 && xRegGetUserLogged(id)))
        {
            if(xMyRank <= get_pcvar_num(xCvarTop10SayAmount) && get_pcvar_num(xCvarTop10SayGreen))
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
            else
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^1%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
        }
        else
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^3%s: ^1%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], xPlayerName, xSayTyped)
        }
        
    }*/
    

    
    if((get_pcvar_num(xCvarSaveType) == 1 && !xIsUserNoSxe(id)) || (get_pcvar_num(xCvarSaveType) == 2 && xRegGetUserLogged(id)))
    {
        if(temp_prefix[0])
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^4%s ^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], temp_prefix, xMyRankName, xPlayerName, xSayTyped)
        }
        else
        {
            if(xMyRank <= get_pcvar_num(xCvarTop10SayAmount) && get_pcvar_num(xCvarTop10SayGreen))
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^4%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
            else
            {
                formatex(xSayMessage, charsmax(xSayMessage), "^1%s^1» ^4%s ^1« ^3%s: ^1%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], xMyRankName, xPlayerName, xSayTyped)
            }
        }
    }
    else
    {
        if(temp_prefix[0])
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^4%s ^3%s: ^4%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], temp_prefix, xPlayerName, xSayTyped)
        }
        else
        {
            formatex(xSayMessage, charsmax(xSayMessage), "^1%s^3%s: ^1%s", xSayTeamInfoTeamPrefix[is_user_alive(id)][xUserTeam], xPlayerName, xSayTyped)
        }
    }
    

    get_pcvar_string(xCvarPrefixAdminViewSayFlag, temp_cvar, charsmax(temp_cvar))

    for(new i = 1; i <= xMaxPlayers; i++)
    {
        if(!is_user_connected(i))
            continue

        if(get_user_team(id) == get_user_team(i) || get_pcvar_num(xCvarPrefixOn) && get_user_flags(i) & read_flags(temp_cvar))
        {
            if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(xCvarPrefixOn) && get_user_flags(i) & read_flags(temp_cvar))
            {
                xPrefixSendMessage(xSayMessage, id, i)
            }
        }
    }

    return PLUGIN_HANDLED_MAIN
}

public xPutPrefix(id)
{
    num_to_str(id, str_id, charsmax(str_id))
    TrieSetString(client_prefix, str_id, "")

    new sflags[32], temp_flag[2];
    get_flags(get_user_flags(id), sflags, charsmax(sflags))

    for(new i = 0; i <= charsmax(sflags); i++)
    {
        formatex(temp_flag, charsmax(temp_flag), "%c", sflags[i])

        if(TrieGetString(pre_flags_collect, temp_flag, temp_prefix, charsmax(temp_prefix)))
        {
            TrieSetString(client_prefix, str_id, temp_prefix)
        }
    }

    get_user_ip(id, temp_key, charsmax(temp_key), 1)

    if(TrieGetString(pre_ips_collect, temp_key, temp_prefix, charsmax(temp_prefix)))
    {
        TrieSetString(client_prefix, str_id, temp_prefix)
    }

    get_user_authid(id, temp_key, charsmax(temp_key))

    if(TrieGetString(pre_steamids_collect, temp_key, temp_prefix, charsmax(temp_prefix)))
    {
        TrieSetString(client_prefix, str_id, temp_prefix)
    }

    get_user_name(id, temp_key, charsmax(temp_key))

    if(TrieGetString(pre_names_collect, temp_key, temp_prefix, charsmax(temp_prefix)))
    {
        TrieSetString(client_prefix, str_id, temp_prefix)
    }

    return PLUGIN_HANDLED
}

public xPrefixSendMessage(const message[], const id, const i)
{
    message_begin(MSG_ONE, xSayTxt, {0, 0, 0}, i)
    write_byte(id)
    write_string(message)
    message_end()
}

bool:check_say_characters(const check_message[])
{
    for(new i = 0; i < charsmax(xBlockSymbolsSayPrefix); i++)
    {
        if(check_message[0] == xBlockSymbolsSayPrefix[i])
        {
            return true
        }
    }
    return false
}

public xNtvGetUserPosTop10(id)
{
    new Array:aKey = ArrayCreate(35)
    new Array:aData = ArrayCreate(128)
    new Array:aAll = ArrayCreate(xTop15Data)
    
    fvault_load(db_top10_data, aKey, aData)
    
    new iArraySize = ArraySize(aKey)
    
    new Data[xTop15Data]
    
    new i
    for(i = 0; i < iArraySize; i++)
    {
        ArrayGetString(aKey, i, Data[szAuthID ], sizeof Data[szAuthID]-1)
        ArrayGetString(aData, i, Data[szSkillP_Data], sizeof Data[szSkillP_Data]-1)
        
        ArrayPushArray(aAll, Data)
    }
    
    ArraySort(aAll, "xSortData")
    
    new szAuthIdFromArray[64]
    
    new j
    for(j = 0; j < iArraySize; j++ )
    {
        ArrayGetString(aAll, j, szAuthIdFromArray, charsmax(szAuthIdFromArray))
        
        switch(get_pcvar_num(xCvarSaveType))
        {
            case 1: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
            case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
            default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }

        if(equal(szAuthIdFromArray, xGetAuth)) break
        
    }
    
    ArrayDestroy(aKey)
    ArrayDestroy(aData)
    ArrayDestroy(aAll)

    return j + 1
}

public xNtvGetTotalTop10()
{
    new Array:aKey = ArrayCreate(64)
    new Array:aData = ArrayCreate(512)
        
    new xTotalVaults = fvault_load(db_top10_data, aKey, aData)

    ArrayDestroy(aKey)
    ArrayDestroy(aData)

    return xTotalVaults
}

public xNtvGetUserXP(id)
{
    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(!is_user_connected(id))
                return false
        }

        case 2:
        {
            if(!xRegGetUserLogged(id))
                return false
        }

        default:
        {
            if(!is_user_connected(id))
                return false
        }
    }
    
    return xPlayerXP[id]
}

public xNtvCheckUserLvl(id)
{
    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(!is_user_connected(id))
                return false
        }

        case 2:
        {
            if(!xRegGetUserLogged(id))
                return false
        }

        default:
        {
            if(!is_user_connected(id))
                return false
        }
    }
    
    return xCheckLevel(id)
}

public xNtvGetUserRankName(xPluginId, xNumParams)
{
    new id = get_param(1)

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(!is_user_connected(id))
                return false
        }

        case 2:
        {
            if(!xRegGetUserLogged(id))
                return false
        }

        default:
        {
            if(!is_user_connected(id))
                return false
        }
    }
    
    new xUserName[64]

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1: formatex(xUserName, charsmax(xUserName), "%s", xPatents[xPlayerLevel[id]][xRankName])

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
    
    new len = get_param(3)
    set_string(2, xUserName, len)

    return true
}

public xDeathMsg()
{
    new xAddXp
    new xKiller = read_data(1)
    new xVictim = read_data(2)
    new xHeadShot = read_data(3)

    new xWeapon[24]
    read_data(4, xWeapon, charsmax(xWeapon))

    if(xKiller != xVictim && is_user_connected(xKiller) && is_user_connected(xVictim))
    {
        new xDiedXp = random_num(get_pcvar_num(xCvarXpDiedMin), get_pcvar_num(xCvarXpDiedMax))

        if(xHeadShot == 1 && !(xWeapon[0] == 'k') && xKiller != xVictim) // Hs
            xAddXp = get_pcvar_num(xCvarXpKillHs)
        else xAddXp = get_pcvar_num(xCvarXpKillNormal) // Normal

        if(xWeapon[1] == 'r' && xKiller != xVictim) // He Grenade
            xAddXp = get_pcvar_num(xCvarXpKillHeGrenade)

        if(xWeapon[0] == 'k') // Knife
            xAddXp = get_pcvar_num(xCvarXpKillKnife)

        if(get_user_flags(xKiller) & VIP_FLAG)
        {
            xPlayerXP[xKiller] += xAddXp + get_pcvar_num(xCvarXpKillVipMore)
            if(get_pcvar_num(xCvarXpNegative)) xPlayerXP[xVictim] -= xDiedXp - get_pcvar_num(xCvarXpKillVipMore)
        }
        else
        {
            xPlayerXP[xKiller] += xAddXp
            if(get_pcvar_num(xCvarXpNegative)) xPlayerXP[xVictim] -= xDiedXp
        }

        switch(get_pcvar_num(xCvarPttRankStyle))
        {
            case 1:
            {
                if(xPlayerLevel[xKiller] < MAXLEVEL_CSGO-1)
                {
                    if(xPlayerXP[xKiller] >= xPatents[xPlayerLevel[xKiller]+1][xRankXp])
                    {
                        xCheckLevel(xKiller)

                        get_user_name(xKiller, xPlayerName, charsmax(xPlayerName))
                            
                        client_cmd(0, "speak ambience/3dmeagle")
                        xClientPrintColor(0, "%s !yJogador !g%s !ySubiu de level. Level: !g%d, !yPatente: !g%s!y.", PREFIXCHAT, xPlayerName, xPlayerLevel[xKiller], xPatents[xPlayerLevel[xKiller]][xRankName])
                    }
                }
            }

            default: set_pcvar_num(xCvarPttRankStyle, 1)
        }

        xPlayerKills[xKiller] ++
        xPlayerDeaths[xVictim] ++

        xSaveRanks(xKiller)
        xSaveRanks(xVictim)
        xSaveTop10Data(xKiller)
        xSaveTop10Data(xVictim)
    }
}

public xMotdTop10(id)
{
    xCreateMotdTop10()
    show_motd(id, xMotd, "TOP 10")
}

public xCreateMotdTop10()
{
    new iLen, xRandomCss

    xRandomCss = random_num(0, 1)

    switch(xRandomCss)
    {
        case 0:
        {
            iLen = formatex(xMotd, charsmax(xMotd), "<meta charset=UTF-8>\
            <style>*{margin:0px;}body{color:#fff;background:url(^"https://cdn.oboi7.com/b3aa341633c35906c7dd4c33c1465232f9078e5b/sinij-minimalistichnyj-fony.jpg^")}table{border-collapse:collapse;border: 1px solid #000;text-align:center;}</style>\
            <body><table width=100%% height=10%% border=1><tr bgcolor=#4c4c4c style=^"color:#fff;^"><th width=5%%>POS.<th width=50%%>NOME<th width=15%%>KILLS\
            <th width=15%%>MORTES<th width=10%%>XP<th width=20%%>PATENTE")
        }

        case 1:
        {
            iLen = formatex(xMotd, charsmax(xMotd), "<meta charset=UTF-8>\
            <style>*{margin:0px;}body{color:#fff;background:url(^"https://cdn.oboi7.com/b3aa341633c35906c7dd4c33c1465232f9078e5b/sinij-minimalistichnyj-fony.jpg^")}table{border-collapse:collapse;border: 1px solid #000;text-align:center;}</style>\
            <body><table width=100%% height=10%% border=1><tr bgcolor=#4c4c4c style=^"color:#fff;^"><th width=5%%>POS.<th width=50%%>NOME<th width=15%%>KILLS\
            <th width=15%%>MORTES<th width=10%%>XP<th width=20%%>PATENTE")
        }
    }
    
    new Array:aKey = ArrayCreate(35)
    new Array:aData = ArrayCreate(128)
    new Array:aAll = ArrayCreate(xTop15Data)
    
    fvault_load(db_top10_data, aKey, aData)
    
    new iArraySize = ArraySize(aKey)
    
    new Data[xTop15Data]
    
    new i
    for( i = 0; i < iArraySize; i++ )
    {
        ArrayGetString(aKey, i, Data[szAuthID], sizeof Data[szAuthID]-1)
        ArrayGetString(aData, i, Data[szSkillP_Data], sizeof Data[szSkillP_Data]-1)
        
        ArrayPushArray(aAll, Data)
    }
    
    ArraySort(aAll, "xSortData")
    
    new szPlayerKills[10]
    new szPlayerDeahts[10]
    
    new szName[25], xGetDataXps[50]
    new iSize = clamp( iArraySize, 0, 10)

    new j
    for(j = 0; j < iSize; j++)
    {
        ArrayGetArray( aAll, j, Data )
        
        fvault_get_data( db_top10_names, Data[ szAuthID ], szName, charsmax( szName ) )
        
        replace_all(szName, charsmax(szName), "<", "")
        replace_all(szName, charsmax(szName), ">", "")
        replace_all(szName, charsmax(szName), "%", "")
        
        parse(Data[szSkillP_Data],szPlayerKills, charsmax(szPlayerKills), szPlayerDeahts, charsmax(szPlayerDeahts))
        
        fvault_get_data(db_patents, Data[ szAuthID ], xGetDataXps, charsmax(xGetDataXps))

        new xPlayerXpRank = str_to_num(xGetDataXps)
        new xPlayerLvlRank

        switch(get_pcvar_num(xCvarPttRankStyle))
        {
            case 1:
            {
                if(xPlayerLvlRank <= MAXLEVEL_CSGO-1)
                {
                    xPlayerLvlRank = 0
                    
                    while(xPlayerXpRank >= xPatents[xPlayerLvlRank+1][xRankXp])
                    {
                        xPlayerLvlRank ++
                            
                        if(xPlayerLvlRank == MAXLEVEL_CSGO-1)
                            break
                    }
                }

                iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr><td>%i<td>%s<td>%s<td>%s<td>%s<td><img src=^"%s^" width=80 hight=30/>", j + 1, szName, xAddPoint(str_to_num(szPlayerKills)),
                xAddPoint(str_to_num(szPlayerDeahts)), xAddPoint(xPlayerXpRank), xGetUserImgRank(xPlayerLvlRank))
            }

            default: set_pcvar_num(xCvarPttRankStyle, 1)
        }
    }
    
    ArrayDestroy(aKey)
    ArrayDestroy(aData)
    ArrayDestroy(aAll)
}

/*
public xSortData(Array:aArray, iItem1, iItem2, iData[], iDataSize)
{   
    new Data1[ xTop15Data ]
    new Data2[ xTop15Data ]
    
    ArrayGetArray( aArray, iItem1, Data1 )
    ArrayGetArray( aArray, iItem2, Data2 )
    
    new szPlayerKills[7], szPlayerDeahts[7]
    parse(Data1[ szSkillP_Data ], szPlayerKills, charsmax( szPlayerKills ), szPlayerDeahts, charsmax( szPlayerDeahts ))
    new Count1_1 = str_to_num(szPlayerKills)
    new Count1_2 = str_to_num(szPlayerDeahts)

    new Count1_f
    if(Count1_2 >= Count1_1) Count1_f = Count1_1
    else Count1_f = ((Count1_1+Count1_2)/2)

    new szPlayerKills2[7], szPlayerDeahts2[7]
    parse(Data2[ szSkillP_Data ], szPlayerKills2, charsmax( szPlayerKills2 ), szPlayerDeahts2, charsmax( szPlayerDeahts2 ))
    new Count2_1 = str_to_num(szPlayerKills2)
    new Count2_2 = str_to_num(szPlayerDeahts2)

    new Count2_f
    if(Count2_2 >= Count2_1) Count1_f = Count2_1
    else Count2_f = ((Count2_1+Count2_2)/2)
    
    new iCount1 = Count1_f
    new iCount2 = Count2_f
    
    return (iCount1 > iCount2) ? -1 : ((iCount1 < iCount2) ? 1 : 0)
}*/

public xSortData(Array:aArray, iItem1, iItem2, iData[], iDataSize)
{   
    new Data1[ xTop15Data ]
    new Data2[ xTop15Data ]
    
    ArrayGetArray( aArray, iItem1, Data1 )
    ArrayGetArray( aArray, iItem2, Data2 )
    
    new szPlayerKills[7], szPlayerDeahts[7]
    parse(Data1[ szSkillP_Data ], szPlayerKills, charsmax( szPlayerKills ), szPlayerDeahts, charsmax( szPlayerDeahts ))
    new Count1_1 = str_to_num(szPlayerKills)
    new Count1_2 = str_to_num(szPlayerDeahts)

    new Count1_f
    if(Count1_2 >= Count1_1) Count1_f = Count1_1
    else Count1_f = ((Count1_1-Count1_2))

    new szPlayerKills2[7], szPlayerDeahts2[7]
    parse(Data2[ szSkillP_Data ], szPlayerKills2, charsmax( szPlayerKills2 ), szPlayerDeahts2, charsmax( szPlayerDeahts2 ))
    new Count2_1 = str_to_num(szPlayerKills2)
    new Count2_2 = str_to_num(szPlayerDeahts2)

    new Count2_f
    if(Count2_2 >= Count2_1) Count1_f = Count2_1
    else Count2_f = ((Count2_1-Count2_2))
    
    new iCount1 = Count1_f
    new iCount2 = Count2_f
    
    return (iCount1 > iCount2) ? -1 : ((iCount1 < iCount2) ? 1 : 0)
}

public xCheckLevel(id)
{
    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            if(xPlayerLevel[id] <= MAXLEVEL_CSGO-1)
            {
                xPlayerLevel[id] = 0
                        
                while(xPlayerXP[id] >= xPatents[xPlayerLevel[id]+1][xRankXp])
                {
                    xPlayerLevel[id]++
                            
                    if(xPlayerLevel[id] == MAXLEVEL_CSGO-1)
                        return false
                }
            }
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }

    return true
}

public xSaveRanks(id)
{
    new xData[30]

    if(is_user_bot(id) || is_user_hltv(id))
        return PLUGIN_HANDLED

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(xIsUserNoSxe(id))
                return PLUGIN_HANDLED

            get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }

        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    num_to_str(xPlayerXP[id], xData, charsmax(xData))
    fvault_set_data(db_patents, xGetAuth, xData)

    return PLUGIN_HANDLED
}

public xSaveTop10Data(id)
{
    new xData[128]

    if(is_user_bot(id) || is_user_hltv(id))
        return PLUGIN_HANDLED

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(xIsUserNoSxe(id))
                return PLUGIN_HANDLED
                
            get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }
        
        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    formatex(xData, charsmax(xData), "%i %i", xPlayerKills[id], xPlayerDeaths[id])
    fvault_set_data(db_top10_data, xGetAuth, xData)

    return PLUGIN_HANDLED
}

public xSaveTop10Names(id)
{
    if(is_user_bot(id) || is_user_hltv(id))
        return PLUGIN_HANDLED
        
    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(xIsUserNoSxe(id))
                return PLUGIN_HANDLED
                
            get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }

        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    get_user_name(id, xPlayerName, charsmax(xPlayerName))
    fvault_set_data(db_top10_names, xGetAuth, xPlayerName)

    return PLUGIN_HANDLED
}

public xLoadKillsDeaths(id)
{
    new xData[128], xMyKills[50], xMyDeaths[50]

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    if(fvault_get_data(db_top10_data, xGetAuth, xData, charsmax(xData)))
    {
        parse(xData, xMyKills, charsmax(xMyKills), xMyDeaths, charsmax(xMyDeaths))
                
        xPlayerKills[id] = str_to_num(xMyKills)
        xPlayerDeaths[id] = str_to_num(xMyDeaths)
    }
}

public xLoadRanks(id)
{
    xPlayerViewMsg[id] = false
    xPlayerHudInfo[id] = true
    xPlayerHudGeoIp[id] = true

    new xData[30]

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    if(fvault_get_data(db_patents, xGetAuth, xData, charsmax(xData)))
        xPlayerXP[id] = str_to_num(xData)

    xCheckLevel(id)

    set_task(1.0, "xHudInfo", id+TASK_HUDRANK, _, _, "b")

    xMyPosRankSave[id] = xNtvGetUserPosTop10(id)
}

public xMsgNoSave(id)
{
    if(!is_user_connected(id))
    {
        remove_task(id); return
    }

    xClientPrintColor(id, "%s !t------------------------------------------------------------------------------------------------------------------------", PREFIXCHAT)
    xClientPrintColor(id, "%s !tA.T.E.N.C.A.O !ySeus dados como !gRank, Patente !yetc, nao estao sendo salvos. Entre com !gsXe !ypara salva-los.", PREFIXCHAT)
    xClientPrintColor(id, "%s !t------------------------------------------------------------------------------------------------------------------------", PREFIXCHAT)
    client_cmd(id, "speak buttons/blip2")
}

public xMsgLoginInAccount(id)
{
    if(!is_user_connected(id))
    {
        remove_task(id); return
    }

    if(!xRegGetUserLogged(id))
    {
        xClientPrintColor(id, "%s !t------------------------------------------------------------------------------------------------------------------------", PREFIXCHAT)
        xClientPrintColor(id, "%s !tA.T.E.N.C.A.O !ySeus dados como !gRank, Patente !yetc, nao estao sendo salvos. Digite !g.login !ypara salva-los.", PREFIXCHAT)
        xClientPrintColor(id, "%s !t------------------------------------------------------------------------------------------------------------------------", PREFIXCHAT)
        client_cmd(id, "speak buttons/blip2")
    }
}

public xClientUserInfoChanged(id)
{
    if(!is_user_connected(id))
        return FMRES_IGNORED

    new xOldName[32]//, xData[128]

    get_user_info(id, "name", xPlayerName, charsmax(xPlayerName))
    get_user_name(id, xOldName, charsmax(xOldName))

    if(!equal(xPlayerName, xOldName))
    {
        num_to_str(id, str_id, charsmax(str_id))
        TrieSetString(client_prefix, str_id, "")
        set_task(0.5, "xPutPrefix", id)

        return FMRES_HANDLED
    }

    xSaveTop10Names(id)

    return FMRES_IGNORED
}

public xHudInfo(id)
{
    id -= TASK_HUDRANK

    if(!is_user_connected(id))
    {
        remove_task(id+TASK_HUDRANK); return
    }

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            if(is_user_alive(id) && xPlayerHudInfo[id])
            {
                set_hudmessage(0, 191, 255, 0.02, 0.20, 0, 0.01, 1.0, 1.0, 1.0)

                if(xPlayerLevel[id] < MAXLEVEL_CSGO-1)
                {
                    if(equali(xPatents[xPlayerLevel[id]][xRankName], xPatents[xPlayerLevel[id]+1][xRankName]))
                        ShowSyncHudMsg(id, xMsgSync[0], "• Patente: %s^n• Prox. Patente: Suba mais seu level.^n• Level: %d^n• Exp: %s / %s", xPatents[xPlayerLevel[id]][xRankName], xPlayerLevel[id], xAddPoint(xPlayerXP[id]), xAddPoint(xPatents[xPlayerLevel[id]+1][xRankXp]))
                    else
                        ShowSyncHudMsg(id, xMsgSync[0], "• Patente: %s^n• Prox. Patente: %s^n• Level: %d^n• Exp: %s / %s", xPatents[xPlayerLevel[id]][xRankName], xPatents[xPlayerLevel[id]+1][xRankName], xPlayerLevel[id], xAddPoint(xPlayerXP[id]), xAddPoint(xPatents[xPlayerLevel[id]+1][xRankXp]))
                }
                else
                {
                    ShowSyncHudMsg(id, xMsgSync[0], "• Patente: %s^n• Level: %d^n• Exp: %s", xPatents[xPlayerLevel[id]][xRankName], xPlayerLevel[id], xAddPoint(xPlayerXP[id]))
                }
            }
            else if(xPlayerHudInfo[id])
            {
                static id2
                id2 = pev(id, pev_iuser2)

                if(!is_user_alive(id2)) return

                static xPlayerIp[20]
                get_user_ip(id2, xPlayerIp, charsmax(xPlayerIp), 1)

                geoip_city(xPlayerIp, xUserCity, charsmax(xUserCity))
                geoip_region_name(xPlayerIp, xUserRegion, charsmax(xUserRegion))
                get_user_name(id2, xPlayerName, charsmax(xPlayerName))

                set_hudmessage(0, 255, 0, 0.02, 0.20, 0, 0.01, 1.0, 1.0, 1.0)

                if(!xPlayerHudGeoIp[id2] || equal(xUserCity, "") || equal(xUserRegion, ""))
                    ShowSyncHudMsg(id, xMsgSync[0], "Observando: %s^n^n• Patente: %s^n• Level: %d^n• Exp: %s", xPlayerName, xPatents[xPlayerLevel[id2]][xRankName], xPlayerLevel[id2], xAddPoint(xPlayerXP[id2]))
                else ShowSyncHudMsg(id, xMsgSync[0], "Observando: %s^n^n• Patente: %s^n• Level: %d^n• Exp: %s^n• Cidade: %s^n• Estado: %s", xPlayerName, xPatents[xPlayerLevel[id2]][xRankName], xPlayerLevel[id2], xAddPoint(xPlayerXP[id2]), xUserCity, xUserRegion)
            }
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
}

public xHudInfoGeoIpCmd(id)
{
    if(!xPlayerHudGeoIp[id])
    {
        xPlayerHudGeoIp[id] = true
        
        xClientPrintColor(id, "%s !yVoce !gAtivou !ya hudinfo de localizacao.", PREFIXCHAT)
    }
    else
    {
        xPlayerHudGeoIp[id] = false
        
        xClientPrintColor(id, "%s !yVoce !gDesativou !ya hudinfo de localizacao.", PREFIXCHAT)
    }
}

public xHudInfoCmd(id)
{
    if(!xPlayerHudInfo[id])
    {
        xPlayerHudInfo[id] = true
        
        xClientPrintColor(id, "%s !yVoce !gAtivou !ya hudinfo.", PREFIXCHAT)
    
        set_task(1.0, "xHudInfo", id+TASK_HUDRANK, _, _, "b")
    }
    else
    {
        xPlayerHudInfo[id] = false
        
        xClientPrintColor(id, "%s !yVoce !gDesativou !ya hudinfo.", PREFIXCHAT)
        
        remove_task(id+TASK_HUDRANK)
    }
}

stock xGetListRankExp(num)
{
    switch(num)
    {
        case 0: return xPatents[0][xRankXp]
        case 1: return xPatents[1][xRankXp]
        case 2: return xPatents[2][xRankXp]
        case 3: return xPatents[3][xRankXp]
        case 4: return xPatents[4][xRankXp]
        case 5: return xPatents[5][xRankXp]
        case 6: return xPatents[6][xRankXp]
        case 7: return xPatents[7][xRankXp]
        case 8: return xPatents[8][xRankXp]
        case 9: return xPatents[9][xRankXp]
        case 10: return xPatents[10][xRankXp]
        case 11: return xPatents[11][xRankXp]
        case 12: return xPatents[12][xRankXp]
        case 13: return xPatents[13][xRankXp]
        case 14: return xPatents[14][xRankXp]
        case 15: return xPatents[15][xRankXp]
        case 16: return xPatents[16][xRankXp]
        case 17: return xPatents[17][xRankXp]
    
        default: return xPatents[0][xRankXp]
    }

    return xPatents[0][xRankXp]
}

stock xGetListRankName(num)
{
    switch(num)
    {
        case 0: return xPatents[0]
        case 1: return xPatents[1]
        case 2: return xPatents[2]
        case 3: return xPatents[3]
        case 4: return xPatents[4]
        case 5: return xPatents[5]
        case 6: return xPatents[6]
        case 7: return xPatents[7]
        case 8: return xPatents[8]
        case 9: return xPatents[9]
        case 10: return xPatents[10]
        case 11: return xPatents[11]
        case 12: return xPatents[12]
        case 13: return xPatents[13]
        case 14: return xPatents[14]
        case 15: return xPatents[15]
        case 16: return xPatents[16]
        case 17: return xPatents[17]
    
        default: return xPatents[0]
    }

    return xPatents[0]
}

stock xGetUserImgRank(num)
{
    switch(num)
    {
        case 0: return xPatentsImages[0]
        case 1: return xPatentsImages[1]
        case 2: return xPatentsImages[2]
        case 3: return xPatentsImages[3]
        case 4: return xPatentsImages[4]
        case 5: return xPatentsImages[5]
        case 6: return xPatentsImages[6]
        case 7: return xPatentsImages[7]
        case 8: return xPatentsImages[8]
        case 9: return xPatentsImages[9]
        case 10: return xPatentsImages[10]
        case 11: return xPatentsImages[11]
        case 12: return xPatentsImages[12]
        case 13: return xPatentsImages[13]
        case 14: return xPatentsImages[14]
        case 15: return xPatentsImages[15]
        case 16: return xPatentsImages[16]
        case 17: return xPatentsImages[17]

        default: return xPatentsImages[0]
    }

    return xPatentsImages[0]
}

stock xIsUserNoSxe(id)
{
    get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    
    if(equal(xGetAuth, "VALVE_4:4", 9))
        return true
    
    return false
}

stock xAddPoint(number)
{
    new count, i, str[29], str2[35], len
    num_to_str(number, str, charsmax(str))
    len = strlen(str)

    for (i = 0; i < len; i++)
    {
        if(i != 0 && ((len - i) %3 == 0))
        {
            add(str2, charsmax(str2), ".", 1)
            count++
            add(str2[i+count], 1, str[i], 1)
        }
        else add(str2[i+count], 1, str[i], 1)
    }
    
    return str2
}

stock xClientPrintColor(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)
    
    replace_all(msg, 190, "!g", "^4")
    replace_all(msg, 190, "!y", "^1")
    replace_all(msg, 190, "!t", "^3")
    replace_all(msg, 190, "!t2", "^0")
    
    if (id) players[0] = id; else get_players(players, count, "ch")

    for (new i = 0; i < count; i++)
    {
        if (is_user_connected(players[i]))
        {
            message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
            write_byte(players[i])
            write_string(msg)
            message_end()
        }
    }
}

stock xRegisterSay(szsay[], szfunction[])
{
    new sztemp[64]
    formatex(sztemp, 63 , "say /%s", szsay)
    register_clcmd(sztemp, szfunction)
    
    formatex(sztemp, 63 , "say .%s", szsay)
    register_clcmd(sztemp, szfunction)
    
    formatex(sztemp, 63 , "say_team /%s", szsay)
    register_clcmd(sztemp, szfunction )
    
    formatex(sztemp, 63 , "say_team .%s", szsay)
    register_clcmd(sztemp, szfunction)
}
 

Вложения

Сообщения
1,701
Реакции
1,512
Помог
26 раз(а)
Сделать размер массива соотвественно иницилизируемым данным.
 
Сообщения
2,491
Реакции
2,794
Помог
61 раз(а)
ifx, тут человек пишет, мол сам переделывает.

Amyr, покажите что меняли
 
  • Super
Реакции: ifx
Сообщения
36
Реакции
1
Все настроил работает норм, решил добавить строку убийства в голову, тоже работает норм, но только есть беда, убийство в голову засчитывает не одному игроку а всем, не подскажите че сделал не так?

Код:
/* Anti Decompiler :) */
#pragma compress 1

#include <amxmodx>
#include <amxmisc>
#include <celltrie>
#include <cstrike>
#include <fakemeta>
#include <fvault>
#include <geoip>
#include <hamsandwich>

#define PLUGIN "Patents"
#define VERSION "1.0"
#define AUTHOR "M."

#define VIP_FLAG ADMIN_RESERVATION

#define MAXLEVEL_CSGO 18
#define TASK_HUDRANK 1234569
#define ENEMYRANK 4

native reg_get_user_logged(id)
native reg_get_user_account(id, account[], len)
forward reg_user_login_post(id)
forward reg_user_logout_post(id)

#define xRegGetUserLogged(%1) reg_get_user_logged(%1)
#define xRegGetUserAccount(%1,%2,%3) reg_get_user_account(%1,%2,%3)
#define xRegUserLoginPost(%1) reg_user_login_post(%1)
#define xRegUserLogoutPost(%1) reg_user_logout_post(%1)

enum xDataPatents
{
    xRankName[33],
    xRankXp
};

enum _:xTop15Data
{
    szAuthID[35],
    szSkillP_Data[128]
}

new xPlayerID[33], xMsgSync[1], xPlayerXP[33], xPlayerLevel[33], xPlayerName[32], xPlayerHudInfo[33], xGetAuth[64], xPlayerKills[33], xPlayerDeaths[33], g_iHeadShots[33], xMotd[5000], xPlayerViewMsg[33], xUserCity[50], xUserRegion[50], xCvarSaveType, xCvarXpKillNormal, xCvarXpKillKnife, xCvarXpKillHs,
xCvarXpDiedMin, xCvarXpDiedMax, xCvarXpKillHeGrenade, xCvarXpKillVipMore, xCvarXpNegative, xCvarPttRankStyle,
xMyPosRankSave[33], xPlayerHudGeoIp[33]

new const db_top10_data[] = "db_top10_data"
new const db_top10_names[] = "db_top10_nomes"
new const db_patents[] = "db_patentes"

new const xPatents[][xDataPatents] =
{
    
        //Rank           XP/Lvl
    {    "Серебро I",        0        }, // Lvl 0
    {    "Серебро II",        30        }, // Lvl 2
    {    "Серебро III",        80        }, // Lvl 3
    {    "Серебро IV",         100        }, // Lvl 4
    {    "Серебро-Элита",        150        }, // Lvl 5
    {    "Серебро-Магистр",        250        }, // Lvl 10
    {    "Золотая Звезда I",        350        }, // Lvl 11
    {    "Золотая Звезда II",        450        }, // Lvl 18
    {    "Золотая Звезда III",        500        }, // Lvl 19
    {    "Звезда-Магистр",        550        }, // Lvl 20
    {    "Калаш",        650        }, // Lvl 21
    {    "Калаш с венками",        750        }, // Lvl 22
    {    "Два калаша",        850        }, // Lvl 23
    {    "Биг Стар",        1000        }, // Lvl 24
    {    "Беркут",        1250    }, // Lvl 25
    {    "Беркут с венками",        1500    }, // Lvl 26
    {    "Суприм",        1800    }, // Lvl 27
    {    "Всемирная Элита",        2100    }
}

new const xPatentsImages[][] =
{
    "https://cs-lite.do.am/YNsKq6L.png",    // Prata 1
    "https://cs-lite.do.am/qpxpoiF.png",    // Prata 2
    "https://cs-lite.do.am/XjEijn0.png",    // Prata 3
    "https://cs-lite.do.am/zBhxhuM.png",    // Prata 4
    "https://cs-lite.do.am/54GJCIJ.png",    // Prata 5
    "https://cs-lite.do.am/u96lJcr.png",    // Prata Elite
    "https://cs-lite.do.am/FcojmRO.png",    // Ouro 1
    "https://cs-lite.do.am/Pn7uAv6.png",    // Ouro 2
    "https://cs-lite.do.am/WkiTWK3.png",    // Ouro 3
    "https://cs-lite.do.am/2kkT0rm.png",    // Ouro 4
    "https://cs-lite.do.am/rvKcJG0.png",    // Ak 1
    "https://cs-lite.do.am/fJR82Jw.png",    // Ak 2
    "https://cs-lite.do.am/Cd66iWa.png",    // Ak Cruzada
    "https://cs-lite.do.am/1G3x6fe.png",    // Xerife
    "https://cs-lite.do.am/Cqsadv3.png",    // Aguia 1
    "https://cs-lite.do.am/4gGGg5R.png",    // Aguia 2
    "https://cs-lite.do.am/LL2yZ4j.png",    // Supremo
    "https://cs-lite.do.am/pgUf0Ch.png"    // Global Elite
}

new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0 
new gHudSyncAimInfo;
new gPlayerName;
new g_friend[33];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    xCvarSaveType = register_cvar("csr_ptt_savetype_data", "1");// 1= Steam + NoSteam com Sxe || 2= Por conta/registro
    xCvarPttRankStyle = register_cvar("csr_ptt_rank_style", "1");// 1= Rank CSGO (ingame) || 2= Rank CSGO Perfil
    xCvarXpKillNormal = register_cvar("csr_ptt_xp_kill_normal", "2");
    xCvarXpKillKnife = register_cvar("csr_ptt_xp_kill_knife", "4");
    xCvarXpKillHs = register_cvar("csr_ptt_xp_kill_hs", "3");
    xCvarXpKillHeGrenade = register_cvar("csr_ptt_xp_kill_hegrenade", "5");
    xCvarXpDiedMin = register_cvar("csr_ptt_xp_died_min", "1");
    xCvarXpDiedMax = register_cvar("csr_ptt_xp_died_max", "2");
    xCvarXpKillVipMore = register_cvar("csr_ptt_xp_kill_vip_more", "1");
    xCvarXpNegative = register_cvar("csr_ptt_xp_negative", "1");

    register_clcmd("say /huds", "xMenuOptHuds");
    register_clcmd("say /top10", "xMotdTop10");
    register_clcmd("say /top15", "xMotdTop10");
    register_clcmd("say /rank", "xSkillTop10");
    register_clcmd("say /stats", "Server_Menu");
    register_menu("Menu 1", keys, "func_menu");
    register_clcmd("say /top", "Stats_Menu");
    register_menu("Menu 2", keys, "stats_menu");   

    register_event("StatusValue", "setTeam", "be", "1=1");
    register_event("StatusValue", "EventStatusValue", "be", "1=2", "2!0");
    register_event("StatusValue", "on_HideStatus", "be", "1=1", "2=0");
    gHudSyncAimInfo = CreateHudSyncObj();
    gPlayerName = get_xvar_id("PlayerName");
    
    register_event("DeathMsg", "xDeathMsg", "a");
    register_event("HLTV", "xNewRound", "a", "1=0", "2=0");

    register_forward(FM_ClientPutInServer, "xClientPutInServer");
    register_forward(FM_ClientDisconnect, "xClientDisconnect");
    register_forward(FM_ClientUserInfoChanged, "xClientUserInfoChanged", 1);

    xMsgSync[0] = CreateHudSyncObj();

    xCreateMotdTop10();
}

public xResetVarsFull(id)
{
    xPlayerLevel[id] = 0
    xPlayerXP[id] = 0
    xPlayerHudInfo[id] = false
    xPlayerKills[id] = 0
    xPlayerDeaths[id] = 0
    g_iHeadShots[id] = 0
    xPlayerID[id] = 0
    xPlayerViewMsg[id] = false
    xMyPosRankSave[id] = 0
    xPlayerHudGeoIp[id] = false
}

public xRegUserLogoutPost(id) xResetVarsFull(id)
public xClientDisconnect(id) xResetVarsFull(id)

public xRegUserLoginPost(id)
{
    xResetVarsFull(id)

    xLoadRanks(id)
    xLoadKillsDeaths(id)
    xSaveTop10Names(id)
}

public xClientPutInServer(id)
{
    xResetVarsFull(id)

    if(xIsUserNoSxe(id) && get_pcvar_num(xCvarSaveType) == 1)
    {
        set_task(15.0, "xMsgNoSave", id, _, _, "a", 5)

        return PLUGIN_HANDLED
    }

    xLoadRanks(id)
    xLoadKillsDeaths(id)
    xSaveTop10Names(id)

    if(get_pcvar_num(xCvarSaveType) == 2)
        set_task(2.0, "xMsgLoginInAccount", id, _, _, "a", 5)

    return PLUGIN_CONTINUE
}

public plugin_natives()
{
    register_native("csr_get_user_rankname", "xNtvGetUserRankName")
    register_native("csr_check_user_level", "xNtvCheckUserLvl", 1)
    register_native("csr_get_user_xp", "xNtvGetUserXP", 1)
    register_native("csr_get_user_pos_top10", "xNtvGetUserPosTop10", 1)
    register_native("csr_get_total_top10", "xNtvGetTotalTop10", 1)

    set_native_filter("xNtvFilter")
}

public xNtvFilter(const name[], index, trap)
{
    if(!trap)
        return PLUGIN_HANDLED
        
    return PLUGIN_CONTINUE
}

public xNewRound()
{
    xCreateMotdTop10()
}

public xMenuOptHuds(id)
{
    new xFmtxMenu[300]

    formatex(xFmtxMenu, charsmax(xFmtxMenu), "\wOpcoes de hud.")

    new xNewMenu = menu_create(xFmtxMenu, "_xMenuOptHuds")
    
    if(xPlayerHudInfo[id]) menu_additem(xNewMenu, "Скрыть свое звание и очки, чтобы другие не видели")
    else menu_additem(xNewMenu, "Показать свое звание и очки, чтобы другие не видели")

    if(xPlayerHudGeoIp[id]) menu_additem(xNewMenu, "Скрыть свое местоположение, чтобы другие не видели")
    else menu_additem(xNewMenu, "Показать свое местоположение для других, чтобы увидеть")
    
    menu_setprop(xNewMenu, MPROP_EXITNAME, "Sair")
    menu_display(id, xNewMenu, 0)
}

public _xMenuOptHuds(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu); return
    }
    
    switch(item)
    {
        case 0:
        {
            xHudInfoCmd(id)
            xMenuOptHuds(id)
        }

        case 1:
        {
            xHudInfoGeoIpCmd(id)
            xMenuOptHuds(id)
        }
    }
}

public Server_Menu(id)
{
     static menu[650], iLen

     iLen = 0
     iLen = formatex(menu[iLen], charsmax(menu) - iLen, "\r[\yBIO\r] \wМеню Званий^n^n")

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r1\y] \wСтатистика^n")
     keys |= MENU_KEY_1

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r2\y] \wПосмотреть звание игроков^n")
     keys |= MENU_KEY_2

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r3\y] \wТаблица званий^n")
     keys |= MENU_KEY_3
    
     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r4\y] \wПомощь^n^n")
     keys |= MENU_KEY_4

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r0\y] \d(\yВыход\d)^n")
     keys |= MENU_KEY_0

     show_menu(id, keys, menu, -1, "Menu 1")
     return PLUGIN_HANDLED
}

public func_menu(id, key)
{   
    switch(key)
    {
        case 0:
        {
            Stats_Menu(id)
        }
        case 1:
        {
            xViewPatentPlayer(id)
        }
        case 2:
        {
            xListPatents(id)
            show_motd(id, xMotd, "LISTA DE PATENTES")
            Server_Menu(id)
        }
        case 3:
        {
            xMotdHelp(id)
            show_motd(id, xMotd, "AJUDA")
            Server_Menu(id)
        }
    }
    return PLUGIN_HANDLED
}

public Stats_Menu(id)
{
     static menu[650], iLen

     iLen = 0
     iLen = formatex(menu[iLen], charsmax(menu) - iLen, "\r[\yBIO\r] \wТоп Меню^n^n")

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r1\y] \wТоп 10^n")
     keys |= MENU_KEY_1
    
     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r2\y] \wМой ранк^n^n")
     keys |= MENU_KEY_2

     iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\y[\r0\y] \d(\yВыход\d)^n")
     keys |= MENU_KEY_0

     show_menu(id, keys, menu, -1, "Menu 2")
     return PLUGIN_HANDLED
}

public stats_menu(id, key)
{   
    switch(key)
    {
        case 0:
        {
            xMotdTop10(id)
            Stats_Menu(id)
        }

        case 1:
        {
            xSkillTop10(id)
        }
    }
    return PLUGIN_HANDLED
}

public xMotdHelp(id)
{
    new iLen
    iLen = formatex(xMotd, charsmax(xMotd), "<html><head><meta charset=UTF-8>\
    <style>body{background: #000 url(^"http://i.imgur.com/FDiuoIk.jpg^") no-repeat fixed center;}table, th, td{border: 1px solid black;border-collapse: collapse;}</style></head><body><table width=100%% cellpadding=2 cellspacing=0 border=1><tr align=center bgcolor=#eeeeee><th width=110%%>AJUDA</tr>")
    
    iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr align=center style=^"color:#fff;font-size:130%%^">")
    iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>- Primeiramente, para que seus dados fiquem salvos no banco de dados voce precisa estar de sxe ou (estar logado na conta, se ativado!).<br><br> A cada Kill que voce faz, voce ganha <b>[%d XP]</b>, se morrer voce perde de <b>[%d XP]</b> a <b>[%d XP]</b>.<br><br>Jogadores <b>VIPS</b> ganha <b>+%d</b> a mais de XP, ao mesmo perde <b>+%d XP</b>.", get_pcvar_num(xCvarXpKillNormal), get_pcvar_num(xCvarXpDiedMin), get_pcvar_num(xCvarXpDiedMax), get_pcvar_num(xCvarXpKillVipMore), get_pcvar_num(xCvarXpKillVipMore))

    iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "</table></body></html>")
}

public xListPatents(id)
{
    new iLen, i
    iLen = formatex(xMotd, charsmax(xMotd), "<meta charset=UTF-8>\
    <style>*{margin:0px;}body{color:#fff;background:url(^"http://goo.gl/RBEw1K^")}table{border-collapse:collapse;border: 1px solid #000;text-align:center;}</style>\
    <body><table width=100%% height=100%% border=1><tr bgcolor=#4c4c4c style=^"color:#fff;^"><th width=50%%>Звания<th width=50%%>Очки")

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            for(i = 0; i < sizeof(xPatentsImages); i++)
            {
                iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr><td>%s<td>%s", xGetListRankName(i), xAddPoint(xGetListRankExp(i)))
            }
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
}

public xViewPatentPlayer(id)
{
    new xFmtxMenu[300]

    formatex(xFmtxMenu, charsmax(xFmtxMenu), " \wEscolha um jogador para ver a patente.")

    new xNewMenu = menu_create(xFmtxMenu, "_xViewPatentPlayer")
    
    new xPlayers[32], xPnum, xTempId, xSzTempId[10]
    
    get_players(xPlayers, xPnum, "ch")
    
    for(new i; i < xPnum; i++)
    {
        xTempId = xPlayers[i]
        
        if(id != xTempId)
        {
            get_user_name(xTempId, xPlayerName, charsmax(xPlayerName))
            num_to_str(xTempId, xSzTempId, 9)
            menu_additem(xNewMenu, xPlayerName, xSzTempId, 0)
        }
    }

    menu_setprop(xNewMenu, MPROP_BACKNAME, "Voltar")
    menu_setprop(xNewMenu, MPROP_NEXTNAME, "Proxima")
    menu_setprop(xNewMenu, MPROP_EXITNAME, "Sair")
    
    menu_display(id, xNewMenu)
}

public _xViewPatentPlayer(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu); return
    }
    
    new data[20], iname[100], access, callback
    
    menu_item_getinfo(menu, item, access, data, 19, iname, 99, callback)
    
    xPlayerID[id] = str_to_num(data)

    get_user_name(xPlayerID[id], xPlayerName, charsmax(xPlayerName))

    xViewPatentPlayerMotd(id)
    show_motd(id, xMotd, "INFO PLAYER")
    xViewPatentPlayer(id)
}

public xViewPatentPlayerMotd(id)
{
    new xMyPosTop10
    xMyPosTop10 = xMyPosRankSave[xPlayerID[id]]

    new iLen
    iLen = formatex(xMotd, charsmax(xMotd), "<head><meta charset=UTF-8>\
    <style>body{background: #000 url(^"http://i.imgur.com/FDiuoIk.jpg^") no-repeat fixed center;}table, th, td{border: 1px solid black;border-collapse: collapse;}</style></head>\
    <body><table width=100%% cellpadding=2 cellspacing=0 border=1>\
    <tr align=center bgcolor=#eeeeee><th width=20%%>Позиция<th width=35%%>Ник<th width=10%%>Убийства<th width=10%%>Смерти<th width=15%%>HS<th width=15%%>Очки<th width=20%%>Звание</tr>")

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr align=center style=^"color:#fff^">")
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td><img src=^"%s^" width=80 hight=30/>", xAddPoint(xMyPosTop10))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xPlayerName)
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(xPlayerKills[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(xPlayerDeaths[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(g_iHeadShots[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td>%s", xAddPoint(xPlayerXP[xPlayerID[id]]))
            iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<td><img src=^"%s^" width=80 hight=30/>", xGetUserImgRank(xPlayerLevel[xPlayerID[id]]))
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
}

public xSkillTop10(id)
{
    new xMyPosTop10
    xMyPosTop10 = xMyPosRankSave[id]

    client_print_color(id, print_team_red, "^1[^4STATS] ^1Ваш ранг: ^4%s ^1из ^4%s ^1Убийств: ^4%s^1 Смертей: ^4%s", xAddPoint(xMyPosTop10), xAddPoint(xNtvGetTotalTop10()), xAddPoint(xPlayerKills[id]), xAddPoint(xPlayerDeaths[id]))
}

public xNtvGetUserPosTop10(id)
{
    new Array:aKey = ArrayCreate(35)
    new Array:aData = ArrayCreate(128)
    new Array:aAll = ArrayCreate(xTop15Data)
    
    fvault_load(db_top10_data, aKey, aData)
    
    new iArraySize = ArraySize(aKey)
    
    new Data[xTop15Data]
    
    new i
    for(i = 0; i < iArraySize; i++)
    {
        ArrayGetString(aKey, i, Data[szAuthID ], sizeof Data[szAuthID]-1)
        ArrayGetString(aData, i, Data[szSkillP_Data], sizeof Data[szSkillP_Data]-1)
        
        ArrayPushArray(aAll, Data)
    }
    
    ArraySort(aAll, "xSortData")
    
    new szAuthIdFromArray[64]
    
    new j
    for(j = 0; j < iArraySize; j++ )
    {
        ArrayGetString(aAll, j, szAuthIdFromArray, charsmax(szAuthIdFromArray))
        
        switch(get_pcvar_num(xCvarSaveType))
        {
            case 1: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
            case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
            default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }

        if(equal(szAuthIdFromArray, xGetAuth)) break
        
    }
    
    ArrayDestroy(aKey)
    ArrayDestroy(aData)
    ArrayDestroy(aAll)

    return j + 1
}

public xNtvGetTotalTop10()
{
    new Array:aKey = ArrayCreate(64)
    new Array:aData = ArrayCreate(512)
        
    new xTotalVaults = fvault_load(db_top10_data, aKey, aData)

    ArrayDestroy(aKey)
    ArrayDestroy(aData)

    return xTotalVaults
}

public xNtvGetUserXP(id)
{
    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(!is_user_connected(id))
                return false
        }

        case 2:
        {
            if(!xRegGetUserLogged(id))
                return false
        }

        default:
        {
            if(!is_user_connected(id))
                return false
        }
    }
    
    return xPlayerXP[id]
}

public xNtvCheckUserLvl(id)
{
    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(!is_user_connected(id))
                return false
        }

        case 2:
        {
            if(!xRegGetUserLogged(id))
                return false
        }

        default:
        {
            if(!is_user_connected(id))
                return false
        }
    }
    
    return xCheckLevel(id)
}

public xNtvGetUserRankName(xPluginId, xNumParams)
{
    new id = get_param(1)

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(!is_user_connected(id))
                return false
        }

        case 2:
        {
            if(!xRegGetUserLogged(id))
                return false
        }

        default:
        {
            if(!is_user_connected(id))
                return false
        }
    }
    
    new xUserName[64]

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1: formatex(xUserName, charsmax(xUserName), "%s", xPatents[xPlayerLevel[id]][xRankName])

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
    
    new len = get_param(3)
    set_string(2, xUserName, len)

    return true
}

public xDeathMsg()
{
    new xAddXp
    new xKiller = read_data(1)
    new xVictim = read_data(2)
    new xHeadShot = read_data(3)
    
    new xWeapon[24]
    read_data(4, xWeapon, charsmax(xWeapon))

    if(xKiller != xVictim && is_user_connected(xKiller) && is_user_connected(xVictim))
    {
        new xDiedXp = random_num(get_pcvar_num(xCvarXpDiedMin), get_pcvar_num(xCvarXpDiedMax))

        if(xHeadShot == 1 && !(xWeapon[0] == 'k') && xKiller) // Hs
        {
            xAddXp = get_pcvar_num(xCvarXpKillHs)
        }
        else
        {
            xAddXp = get_pcvar_num(xCvarXpKillNormal) // Normal
        }
        

        if(xWeapon[1] == 'r' && xKiller != xVictim) // He Grenade
            xAddXp = get_pcvar_num(xCvarXpKillHeGrenade)

        if(xWeapon[0] == 'k') // Knife
            xAddXp = get_pcvar_num(xCvarXpKillKnife)
            

        if(get_user_flags(xKiller) & VIP_FLAG)
        {
            xPlayerXP[xKiller] += xAddXp + get_pcvar_num(xCvarXpKillVipMore)
            if(get_pcvar_num(xCvarXpNegative)) xPlayerXP[xVictim] -= xDiedXp - get_pcvar_num(xCvarXpKillVipMore)
        }
        else
        {
            xPlayerXP[xKiller] += xAddXp
            if(get_pcvar_num(xCvarXpNegative)) xPlayerXP[xVictim] -= xDiedXp
        }

        switch(get_pcvar_num(xCvarPttRankStyle))
        {
            case 1:
            {
                if(xPlayerLevel[xKiller] < MAXLEVEL_CSGO-1)
                {
                    if(xPlayerXP[xKiller] >= xPatents[xPlayerLevel[xKiller]+1][xRankXp])
                    {
                        xCheckLevel(xKiller)

                        get_user_name(xKiller, xPlayerName, charsmax(xPlayerName))
                            
                        client_cmd(0, "speak ambience/3dmeagle")
                        client_print_color(0, print_team_red, "^1[^4STATS]^1 Вас убил ^3%s его звание: ^4%s", xPlayerName, xPlayerLevel[xKiller], xPatents[xPlayerLevel[xKiller]][xRankName])
                    }
                }
            }

            default: set_pcvar_num(xCvarPttRankStyle, 1)
        }

        xPlayerKills[xKiller] ++
        xPlayerDeaths[xVictim] ++
        g_iHeadShots[xKiller]++

        xSaveRanks(xKiller)
        xSaveRanks(xVictim)
        xSaveTop10Data(xKiller)
        xSaveTop10Data(xVictim)
    }
    return PLUGIN_CONTINUE   
}

public EventStatusValue(const id)
{
    new sName[32], iData = read_data(2);
    get_user_name(iData, sName, 31);
    new color1 = 0, color2 = 0;
    if ( get_user_team(iData) == 1 )
        color1 = 255;
    else
        color2 = 255;
    set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01);
    if (g_friend[id] == 1)
    {
        ShowSyncHudMsg(id,  gHudSyncAimInfo, "Ник: %s^nHP/: %d | AP: %d^nЗвание: %s", sName, get_user_health(iData), get_user_armor(iData), xPatents[xPlayerLevel[iData]][xRankName]);
    }
    else
        ShowSyncHudMsg(id, gHudSyncAimInfo, "%s", sName);
}

public setTeam(id)
{
    g_friend[id] = read_data(2);
}

public on_HideStatus(id)
{
    // If miscstats PlayerName option is on do not show this info
    if ( get_xvar_num(gPlayerName) ) return;

    ClearSyncHud(id, gHudSyncAimInfo);
}

public xMotdTop10(id)
{
    xCreateMotdTop10()
    show_motd(id, xMotd, "TOP 10")
}

public xCreateMotdTop10()
{
    new iLen, xRandomCss

    xRandomCss = random_num(0, 1)

    switch(xRandomCss)
    {
        case 0:
        {
            iLen = formatex(xMotd, charsmax(xMotd), "<meta charset=UTF-8>\
            <style>*{margin:0px;}body{color:#fff;background:url(^"https://cdn.oboi7.com/b3aa341633c35906c7dd4c33c1465232f9078e5b/sinij-minimalistichnyj-fony.jpg^")}table{border-collapse:collapse;border: 1px solid #000;text-align:center;}</style>\
            <body><table width=100%% height=10%% border=1><tr bgcolor=#4c4c4c style=^"color:#fff;^"><th width=7%%>Позиция<th width=35%%>Ник<th width=15%%>Убийства\
            <th width=15%%>Смерти<th width=10%%>HS<th width=10%%>Очки<th width=10%%>Звания")
        }

        case 1:
        {
            iLen = formatex(xMotd, charsmax(xMotd), "<meta charset=UTF-8>\
            <style>*{margin:0px;}body{color:#fff;background:url(^"https://cdn.oboi7.com/b3aa341633c35906c7dd4c33c1465232f9078e5b/sinij-minimalistichnyj-fony.jpg^")}table{border-collapse:collapse;border: 1px solid #000;text-align:center;}</style>\
            <body><table width=100%% height=10%% border=1><tr bgcolor=#4c4c4c style=^"color:#fff;^"><th width=7%%>Позиция<th width=35%%>Ник<th width=15%%>Убийства\
            <th width=15%%>Смерти<th width=10%%>HS<th width=10%%>Очки<th width=10%%>Звания")
        }
    }
    
    new Array:aKey = ArrayCreate(35)
    new Array:aData = ArrayCreate(128)
    new Array:aAll = ArrayCreate(xTop15Data)
    
    fvault_load(db_top10_data, aKey, aData)
    
    new iArraySize = ArraySize(aKey)
    
    new Data[xTop15Data]
    
    new i
    for( i = 0; i < iArraySize; i++ )
    {
        ArrayGetString(aKey, i, Data[szAuthID], sizeof Data[szAuthID]-1)
        ArrayGetString(aData, i, Data[szSkillP_Data], sizeof Data[szSkillP_Data]-1)
        
        ArrayPushArray(aAll, Data)
    }
    
    ArraySort(aAll, "xSortData")
    
    new szPlayerKills[10]
    new szPlayerDeahts[10]
    new szPlayerHeadShots[10]
    
    new szName[25], xGetDataXps[50]
    new iSize = clamp( iArraySize, 0, 10)

    new j
    for(j = 0; j < iSize; j++)
    {
        ArrayGetArray( aAll, j, Data )
        
        fvault_get_data( db_top10_names, Data[ szAuthID ], szName, charsmax( szName ) )
        
        replace_all(szName, charsmax(szName), "<", "")
        replace_all(szName, charsmax(szName), ">", "")
        replace_all(szName, charsmax(szName), "%", "")
        
        parse(Data[szSkillP_Data],szPlayerKills, charsmax(szPlayerKills), szPlayerDeahts, charsmax(szPlayerDeahts), szPlayerHeadShots, charsmax(szPlayerHeadShots))
        
        fvault_get_data(db_patents, Data[ szAuthID ], xGetDataXps, charsmax(xGetDataXps))

        g_iHeadShots[ j ] = str_to_num( szPlayerHeadShots )
        new xPlayerXpRank = str_to_num(xGetDataXps)
        new xPlayerLvlRank

        switch(get_pcvar_num(xCvarPttRankStyle))
        {
            case 1:
            {
                if(xPlayerLvlRank <= MAXLEVEL_CSGO-1)
                {
                    xPlayerLvlRank = 0
                    
                    while(xPlayerXpRank >= xPatents[xPlayerLvlRank+1][xRankXp])
                    {
                        xPlayerLvlRank ++
                            
                        if(xPlayerLvlRank == MAXLEVEL_CSGO-1)
                            break
                    }
                }

                iLen += formatex(xMotd[iLen], charsmax(xMotd) - iLen, "<tr><td>%i<td>%s<td>%s<td>%s<td>%s<td>%s<td><img src=^"%s^" width=80 hight=30/>", j + 1, szName, xAddPoint(str_to_num(szPlayerKills)),
                xAddPoint(str_to_num(szPlayerDeahts)), szPlayerHeadShots, xAddPoint(xPlayerXpRank), xGetUserImgRank(xPlayerLvlRank))
            }

            default: set_pcvar_num(xCvarPttRankStyle, 1)
        }
    }
    
    ArrayDestroy(aKey)
    ArrayDestroy(aData)
    ArrayDestroy(aAll)
}

/*
public xSortData(Array:aArray, iItem1, iItem2, iData[], iDataSize)
{   
    new Data1[ xTop15Data ]
    new Data2[ xTop15Data ]
    
    ArrayGetArray( aArray, iItem1, Data1 )
    ArrayGetArray( aArray, iItem2, Data2 )
    
    new szPlayerKills[7], szPlayerDeahts[7]
    parse(Data1[ szSkillP_Data ], szPlayerKills, charsmax( szPlayerKills ), szPlayerDeahts, charsmax( szPlayerDeahts ))
    new Count1_1 = str_to_num(szPlayerKills)
    new Count1_2 = str_to_num(szPlayerDeahts)

    new Count1_f
    if(Count1_2 >= Count1_1) Count1_f = Count1_1
    else Count1_f = ((Count1_1+Count1_2)/2)

    new szPlayerKills2[7], szPlayerDeahts2[7]
    parse(Data2[ szSkillP_Data ], szPlayerKills2, charsmax( szPlayerKills2 ), szPlayerDeahts2, charsmax( szPlayerDeahts2 ))
    new Count2_1 = str_to_num(szPlayerKills2)
    new Count2_2 = str_to_num(szPlayerDeahts2)

    new Count2_f
    if(Count2_2 >= Count2_1) Count1_f = Count2_1
    else Count2_f = ((Count2_1+Count2_2)/2)
    
    new iCount1 = Count1_f
    new iCount2 = Count2_f
    
    return (iCount1 > iCount2) ? -1 : ((iCount1 < iCount2) ? 1 : 0)
}*/

public xSortData(Array:aArray, iItem1, iItem2, iData[], iDataSize)
{   
    new Data1[ xTop15Data ]
    new Data2[ xTop15Data ]
    
    ArrayGetArray( aArray, iItem1, Data1 )
    ArrayGetArray( aArray, iItem2, Data2 )
    
    new szPlayerKills[7], szPlayerDeahts[7]
    parse(Data1[ szSkillP_Data ], szPlayerKills, charsmax( szPlayerKills ), szPlayerDeahts, charsmax( szPlayerDeahts ) )
    new Count1_1 = str_to_num(szPlayerKills)
    new Count1_2 = str_to_num(szPlayerDeahts)

    new Count1_f
    if(Count1_2 >= Count1_1) Count1_f = Count1_1
    else Count1_f = ((Count1_1-Count1_2))

    new szPlayerKills2[7], szPlayerDeahts2[7]
    parse(Data2[ szSkillP_Data ], szPlayerKills2, charsmax( szPlayerKills2 ), szPlayerDeahts2, charsmax( szPlayerDeahts2 ))
    new Count2_1 = str_to_num(szPlayerKills2)
    new Count2_2 = str_to_num(szPlayerDeahts2)

    new Count2_f
    if(Count2_2 >= Count2_1) Count1_f = Count2_1
    else Count2_f = ((Count2_1-Count2_2))
    
    new iCount1 = Count1_f
    new iCount2 = Count2_f
    
    return (iCount1 > iCount2) ? -1 : ((iCount1 < iCount2) ? 1 : 0)
}

public xCheckLevel(id)
{
    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            if(xPlayerLevel[id] <= MAXLEVEL_CSGO-1)
            {
                xPlayerLevel[id] = 0
                        
                while(xPlayerXP[id] >= xPatents[xPlayerLevel[id]+1][xRankXp])
                {
                    xPlayerLevel[id]++
                            
                    if(xPlayerLevel[id] == MAXLEVEL_CSGO-1)
                        return false
                }
            }
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }

    return true
}

public xSaveRanks(id)
{
    new xData[30]

    if(is_user_bot(id) || is_user_hltv(id))
        return PLUGIN_HANDLED

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(xIsUserNoSxe(id))
                return PLUGIN_HANDLED

            get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }

        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    num_to_str(xPlayerXP[id], xData, charsmax(xData))
    fvault_set_data(db_patents, xGetAuth, xData)

    return PLUGIN_HANDLED
}

public xSaveTop10Data(id)
{
    new xData[128]

    if(is_user_bot(id) || is_user_hltv(id))
        return PLUGIN_HANDLED

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(xIsUserNoSxe(id))
                return PLUGIN_HANDLED
                
            get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }
        
        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    formatex(xData, charsmax(xData), "%i %i %i", xPlayerKills[id], xPlayerDeaths[id], g_iHeadShots[id])
    fvault_set_data(db_top10_data, xGetAuth, xData)

    return PLUGIN_HANDLED
}

public xSaveTop10Names(id)
{
    if(is_user_bot(id) || is_user_hltv(id))
        return PLUGIN_HANDLED
        
    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1:
        {
            if(xIsUserNoSxe(id))
                return PLUGIN_HANDLED
                
            get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        }

        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    get_user_name(id, xPlayerName, charsmax(xPlayerName))
    fvault_set_data(db_top10_names, xGetAuth, xPlayerName)

    return PLUGIN_HANDLED
}

public xLoadKillsDeaths(id)
{
    new xData[128], xMyKills[50], xMyDeaths[50], xMyHeadShots[50]

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    if(fvault_get_data(db_top10_data, xGetAuth, xData, charsmax(xData)))
    {
        parse(xData, xMyKills, charsmax(xMyKills), xMyDeaths, charsmax(xMyDeaths), xMyHeadShots, charsmax(xMyHeadShots))
                
        xPlayerKills[id] = str_to_num(xMyKills)
        xPlayerDeaths[id] = str_to_num(xMyDeaths)
        g_iHeadShots[id] = str_to_num(xMyHeadShots)
    }
}

public xLoadRanks(id)
{
    xPlayerViewMsg[id] = false
    xPlayerHudInfo[id] = true
    xPlayerHudGeoIp[id] = true

    new xData[30]

    switch(get_pcvar_num(xCvarSaveType))
    {
        case 1: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
        case 2: xRegGetUserAccount(id, xGetAuth, charsmax(xGetAuth))
        default: get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    }

    if(fvault_get_data(db_patents, xGetAuth, xData, charsmax(xData)))
        xPlayerXP[id] = str_to_num(xData)

    xCheckLevel(id)

    set_task(0.5, "xHudInfo", id+TASK_HUDRANK, _, _, "b")

    xMyPosRankSave[id] = xNtvGetUserPosTop10(id)
}

public xMsgNoSave(id)
{
    if(!is_user_connected(id))
    {
        remove_task(id); return
    }

    client_print_color(id, print_team_red, "^1[^4STATS]^1 Не сохранять ваши данные в статистики введите ^4/eXe^1 в чате")

    client_cmd(id, "speak buttons/blip2")
}

public xMsgLoginInAccount(id)
{
    if(!is_user_connected(id))
    {
        remove_task(id); return
    }

    if(!xRegGetUserLogged(id))
    {
        client_print_color(id, print_team_red, "^1[^4STATS]^1 Ваш ранг не сохраняется, для сохранения данных введите ^4/save^1 в чате")
        client_cmd(id, "speak buttons/blip2")
    }
}

public xClientUserInfoChanged(id)
{
    if(!is_user_connected(id))
        return FMRES_IGNORED

    xSaveTop10Names(id)

    return FMRES_IGNORED
}

public xHudInfo(id)
{
    id -= TASK_HUDRANK

    if(!is_user_connected(id))
    {
        remove_task(id+TASK_HUDRANK); return
    }

    switch(get_pcvar_num(xCvarPttRankStyle))
    {
        case 1:
        {
            if(is_user_alive(id) && xPlayerHudInfo[id])
            {
                set_dhudmessage(0, 191, 255, 0.02, 0.15, 0, 1.0, 0.03, 0.03, 1.0)

                if(xPlayerLevel[id] < MAXLEVEL_CSGO-1)
                {
                    if(equali(xPatents[xPlayerLevel[id]][xRankName], xPatents[xPlayerLevel[id]+1][xRankName]))
                        show_dhudmessage(id, "• Звание: %s^n• Очки: %s / %s", xPatents[xPlayerLevel[id]][xRankName], xAddPoint(xPlayerXP[id]), xAddPoint(xPatents[xPlayerLevel[id]+1][xRankXp]))
                    else
                        show_dhudmessage(id, "• Звание: %s^n• Очки: %s / %s", xPatents[xPlayerLevel[id]][xRankName], xAddPoint(xPlayerXP[id]), xAddPoint(xPatents[xPlayerLevel[id]+1][xRankXp]))
                }
                else
                {
                    show_dhudmessage(id, "• Звание:: %s^n• Очки: %s", xPatents[xPlayerLevel[id]][xRankName], xAddPoint(xPlayerXP[id]))
                }
            }
            else if(xPlayerHudInfo[id])
            {
                static id2
                id2 = pev(id, pev_iuser2)

                if(!is_user_alive(id2)) return

                static xPlayerIp[20]
                get_user_ip(id2, xPlayerIp, charsmax(xPlayerIp), 1)

                geoip_city(xPlayerIp, xUserCity, charsmax(xUserCity))
                geoip_region_name(xPlayerIp, xUserRegion, charsmax(xUserRegion))
                get_user_name(id2, xPlayerName, charsmax(xPlayerName))

                set_dhudmessage(0, 255, 0, 0.02, 0.15, 0, 1.0, 0.03, 0.03, 1.0)

                if(!xPlayerHudGeoIp[id2] || equal(xUserCity, "") || equal(xUserRegion, ""))
                    show_dhudmessage(id, "Наблюдение за: %s^n^n• Звание: %s^n• Очки: %s", xPlayerName, xPatents[xPlayerLevel[id2]][xRankName], xAddPoint(xPlayerXP[id2]))
                else show_dhudmessage(id, "Наблюдение за: %s^n^n• Звание: %s^n• Очки: %s^n• Город: %s^n• Страна: %s", xPlayerName, xPatents[xPlayerLevel[id2]][xRankName], xAddPoint(xPlayerXP[id2]), xUserCity, xUserRegion)
            }
        }

        default: set_pcvar_num(xCvarPttRankStyle, 1)
    }
}

public xHudInfoGeoIpCmd(id)
{
    if(!xPlayerHudGeoIp[id])
    {
        xPlayerHudGeoIp[id] = true
        
        client_print_color(id, print_team_red, "^1[^4STATS]^1 Вы ^4включили местоположение.")
    }
    else
    {
        xPlayerHudGeoIp[id] = false
        
        client_print_color(id, print_team_red, "^1[^4STATS]^1 Вы ^4выключили местоположение.")
    }
}

public xHudInfoCmd(id)
{
    if(!xPlayerHudInfo[id])
    {
        xPlayerHudInfo[id] = true
        
        client_print_color(id, print_team_red, "^1[^4STATS]^1 Вы ^4включили худ информацию.")
    
        set_task(1.0, "xHudInfo", id+TASK_HUDRANK, _, _, "b")
    }
    else
    {
        xPlayerHudInfo[id] = false
        
        client_print_color(id, print_team_red, "^1[^4STATS]^1 Вы ^4выключили худ информацию.")
        
        remove_task(id+TASK_HUDRANK)
    }
}

stock xGetListRankExp(num)
{
    switch(num)
    {
        case 0: return xPatents[0][xRankXp]
        case 1: return xPatents[1][xRankXp]
        case 2: return xPatents[2][xRankXp]
        case 3: return xPatents[3][xRankXp]
        case 4: return xPatents[4][xRankXp]
        case 5: return xPatents[5][xRankXp]
        case 6: return xPatents[6][xRankXp]
        case 7: return xPatents[7][xRankXp]
        case 8: return xPatents[8][xRankXp]
        case 9: return xPatents[9][xRankXp]
        case 10: return xPatents[10][xRankXp]
        case 11: return xPatents[11][xRankXp]
        case 12: return xPatents[12][xRankXp]
        case 13: return xPatents[13][xRankXp]
        case 14: return xPatents[14][xRankXp]
        case 15: return xPatents[15][xRankXp]
        case 16: return xPatents[16][xRankXp]
        case 17: return xPatents[17][xRankXp]
    
        default: return xPatents[0][xRankXp]
    }

    return xPatents[0][xRankXp]
}

stock xGetListRankName(num)
{
    switch(num)
    {
        case 0: return xPatents[0]
        case 1: return xPatents[1]
        case 2: return xPatents[2]
        case 3: return xPatents[3]
        case 4: return xPatents[4]
        case 5: return xPatents[5]
        case 6: return xPatents[6]
        case 7: return xPatents[7]
        case 8: return xPatents[8]
        case 9: return xPatents[9]
        case 10: return xPatents[10]
        case 11: return xPatents[11]
        case 12: return xPatents[12]
        case 13: return xPatents[13]
        case 14: return xPatents[14]
        case 15: return xPatents[15]
        case 16: return xPatents[16]
        case 17: return xPatents[17]
    
        default: return xPatents[0]
    }

    return xPatents[0]
}

stock xGetUserImgRank(num)
{
    switch(num)
    {
        case 0: return xPatentsImages[0]
        case 1: return xPatentsImages[1]
        case 2: return xPatentsImages[2]
        case 3: return xPatentsImages[3]
        case 4: return xPatentsImages[4]
        case 5: return xPatentsImages[5]
        case 6: return xPatentsImages[6]
        case 7: return xPatentsImages[7]
        case 8: return xPatentsImages[8]
        case 9: return xPatentsImages[9]
        case 10: return xPatentsImages[10]
        case 11: return xPatentsImages[11]
        case 12: return xPatentsImages[12]
        case 13: return xPatentsImages[13]
        case 14: return xPatentsImages[14]
        case 15: return xPatentsImages[15]
        case 16: return xPatentsImages[16]
        case 17: return xPatentsImages[17]

        default: return xPatentsImages[0]
    }

    return xPatentsImages[0]
}

stock xIsUserNoSxe(id)
{
    get_user_authid(id, xGetAuth, charsmax(xGetAuth))
    
    if(equal(xGetAuth, "VALVE_4:4", 9))
        return true
    
    return false
}

stock xAddPoint(number)
{
    new count, i, str[29], str2[35], len
    num_to_str(number, str, charsmax(str))
    len = strlen(str)

    for (i = 0; i < len; i++)
    {
        if(i != 0 && ((len - i) %3 == 0))
        {
            add(str2, charsmax(str2), ".", 1)
            count++
            add(str2[i+count], 1, str[i], 1)
        }
        else add(str2[i+count], 1, str[i], 1)
    }
    
    return str2
}
 
Сообщения
2
Реакции
0
Чтобы помогли бесплатно, отправь фрагмент кода с моментом описания попадания в голову из данного кода. Подсказка: используй reapi для этого
 
Сообщения
198
Реакции
16
Помог
1 раз(а)
Samwise, реапи для того, чтобы "отправь фрагмент кода с моментом описания попадания в голову из данного кода"?
 

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

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