Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [RU] The Source Code → ghost rating

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 21

1

Topic: ghost rating

Привет хэрпивару! Вопрос: как правильно настроить это?

{    
    t_account * acc;
    char query[2048];
    t_sql_engine *sql = NULL;
    t_sql_res * result = NULL;
    t_sql_row * Row = NULL;

    text = skip_command(text); // Extract command. (Parameters, etc.)
    acc = accountlist_find_account(text); // Get account according to the name parameter.

    sql = &sql_mysql; // The SQL connection.
    if (!sql) // Check if the SQL connection exists.
    {
        eventlog(eventlog_level_error, __FUNCTION__, "sql layer not initilized"); // The SQL connection does not exist.
        return -1;
    }
    if ( acc != NULL ) // Check if the account is NULL or not.
    {
        // Run some bad-ass SQL query.
        snprintf(query,sizeof(query),"select totgames,wins,losses,killstotal,deathstotal,creepkillstotal,creepdeniestotal,assiststotal,neutralkillstotal,towerkillstotal,raxkillstotal,courierkillstotal,kills,deaths,creepkills,creepdenies,assists,neutralkills,towerkills,raxkills,courierkills, server from(select *, (kills/deaths) as killdeathratio, (totgames-wins) as losses from (select gp.name as name,ga.server as server,gp.gameid as gameid, gp.colour as colour, avg(dp.courierkills) as courierkills, sum(dp.raxkills) as raxkillstotal, sum(dp.towerkills) as towerkillstotal, sum(dp.assists) as assiststotal,sum(dp.courierkills) as courierkillstotal, sum(dp.creepdenies) as creepdeniestotal, sum(dp.creepkills) as creepkillstotal,sum(dp.neutralkills) as neutralkillstotal, sum(dp.deaths) as deathstotal, sum(dp.kills) as killstotal,avg(dp.raxkills) as raxkills,avg(dp.towerkills) as towerkills, avg(dp.assists) as assists, avg(dp.creepdenies) as creepdenies, avg(dp.creepkills) as creepkills,avg(dp.neutralkills) as neutralkills, avg(dp.deaths) as deaths, avg(dp.kills) as kills,count(*) as totgames, SUM(case when((dg.winner = 1 and dp.newcolour < 6) or (dg.winner = 2 and dp.newcolour > 6)) then 1 else 0 end) as wins from gameplayers as gp, dotagames as dg, games as ga,dotaplayers as dp where dg.winner <> 0 and dp.gameid = gp.gameid and dg.gameid = dp.gameid and dp.gameid = ga.id and gp.gameid = dg.gameid and gp.colour = dp.colour and gp.name='%s' group by gp.name) as h) as i",    account_get_name(acc));
        result = sql->query_res(query); // Copy the result of the query.
        eventlog(eventlog_level_error,__FUNCTION__,query); // Log the query, as an error(?)
        if (result != NULL) // Check if the query didn't return NULL or is NULL.
        {
            if (sql->num_rows(result) < 1) // Check if the user has played any games on linked bots.
            {
                message_send_text(c,message_type_error,c,"Rating Doesnt exist"); // No entries found.
                sql->free_result(result);
                return 0;
            }
            while ((Row = sql->fetch_row(result)) != NULL) // Now we run through all rows found in the result of the query.
            {
                uint32_t TotalGames = std::atoi( Row[0] );
    
                if( TotalGames > 0 ) // Make sure the row has at least a total amount of games played higher than zero.
                {
                    // Parsing is done here. No comments needed.
                    uint32_t TotalWins = std::atoi( Row[1] );
                    uint32_t TotalLosses = std::atoi( Row[2] );
                    uint32_t TotalKills = std::atoi( Row[3] );
                    uint32_t TotalDeaths = std::atoi( Row[4] );
                    uint32_t TotalCreepKills = std::atoi( Row[5] );
                    uint32_t TotalCreepDenies = std::atoi( Row[6] );
                    uint32_t TotalAssists = std::atoi( Row[7] );
                    uint32_t TotalNeutralKills = std::atoi( Row[8] );
                    uint32_t TotalTowerKills = std::atoi( Row[9] );
                    uint32_t TotalRaxKills = std::atoi( Row[10] );
                    uint32_t TotalCourierKills = std::atoi( Row[11] );
    
                    double wpg = 0;
                    double lpg = 0;
                    double kpg = (double)TotalKills/TotalGames;
                    double dpg = (double)TotalDeaths/TotalGames;
                    double ckpg = (double)TotalCreepKills/TotalGames;
                    double cdpg = (double)TotalCreepDenies/TotalGames;
                    double apg = (double)TotalAssists/TotalGames;
                    double nkpg = (double)TotalNeutralKills/TotalGames;
                    double tkpg = (double)TotalTowerKills/TotalGames;
                    double rkpg = (double)TotalRaxKills/TotalGames;
                    double coukpg = (double)TotalCourierKills/TotalGames;
                    
                    double Score = std::atoi( Row[21] );
                    uint32_t Rank = 0;
                    wpg = (double)TotalWins/TotalGames;
                    lpg = (double)TotalLosses/TotalGames;
                    wpg = wpg * 100;
                    lpg = lpg * 100;
                    uint32_t leavecount = 0;
                    
                    // Make the sendable text and send it.
                    snprintf(msgtemp, sizeof(msgtemp), "Rating >> S/W/L/K/D/CK/CD/A/NK/TK/RK/CK %d/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u",Score,TotalWins,TotalLosses,TotalKills,TotalDeaths,TotalCreepKills,TotalCreepDenies,TotalAssists,TotalNeutralKills,TotalTowerKills,TotalRaxKills,TotalCourierKills);
                    message_send_text(c,message_type_info,c,msgtemp);
                    return 0;
                }
                else
                {
                    // Return this when there are no games found for this user.
                    message_send_text(c,message_type_error,c,"No Game");
                    return 0;
                }
            }
        }
    }
    else
    {
        snprintf(msgtemp, sizeof(msgtemp), "User was not found : %s",text);
        message_send_text(c,message_type_error,c,msgtemp);
        return 0;
    }

    message_send_text(c,message_type_error,c,"User was not found : %s",text);
    return 0;
} 

При компиляции следующие ошибки:

1>..\..\..\src\bnetd\command.cpp(2244) : error C2065: t_sql_engine: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2244) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2245) : error C2065: t_sql_res: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2245) : error C2065: result: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2246) : error C2065: t_sql_row: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2246) : error C2065: Row: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2251) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2251) : error C2065: sql_mysql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2252) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2261) : error C2065: result: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2261) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2261) : error C2227: выражение слева от "->query_res" должно указывать на тип класса, структуры или объединения либо на универсальный тип
1>        тип: 'unknown-type'
1>..\..\..\src\bnetd\command.cpp(2263) : error C2065: result: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2265) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2265) : error C2227: выражение слева от "->num_rows" должно указывать на тип класса, структуры или объединения либо на универсальный тип
1>        тип: 'unknown-type'
1>..\..\..\src\bnetd\command.cpp(2265) : error C2065: result: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2268) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2268) : error C2227: выражение слева от "->free_result" должно указывать на тип класса, структуры или объединения либо на универсальный тип
1>        тип: 'unknown-type'
1>..\..\..\src\bnetd\command.cpp(2268) : error C2065: result: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2271) : error C2065: Row: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2271) : error C2065: sql: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2271) : error C2227: выражение слева от "->fetch_row" должно указывать на тип класса, структуры или объединения либо на универсальный тип
1>        тип: 'unknown-type'
1>..\..\..\src\bnetd\command.cpp(2271) : error C2065: result: необъявленный идентификатор
1>..\..\..\src\bnetd\command.cpp(2271) : fatal error C1903: не удается восстановить после предыдущих ошибок; остановка компиляции
1>Журнал построения был сохранен в "file://c:\Games\pvpgn\pvpgn\builder\src\bnetd\bnetd.dir\Release\BuildLog.htm"
1>bnetd - ошибок 24, предупреждений 1
========== Построение: успешно: 0, с ошибками: 1, без изменений: 23, пропущено: 0 ==========

2

Re: ghost rating

Ты что тупо скопипастил с бота и сразу в pvpgn? не так уж проста)

3

Re: ghost rating

Источник нужно указывать, чтобы было понятно forums.pvpgn.org/index.php?topic=167686

Команда отображает статистику игрока из mysql таблицы "gameplayers", принадлежащей боту ghost.
Работает только с mysql, и pvpgn должен использовать ту же бд, что и ghost.

Чтобы это компилировалось, нужно добавить два заголовочных файла:
#include "sql_common.h"
#include "sql_mysql.h"

Do not ask for support in PM.

4

Re: ghost rating

дажле после включения тех заголовочных файлов компилятор выдает ошибку... ( хочу напомнить я юзаю не ту дохлую часть кода которую нам дал автор а с официального форума пвпгн )
Код нуждается в модификации

5

Re: ghost rating

напомнить хочу что мой код взят из официального сайта пвпгн'а. а то что у тебя ошибки это не удивительно

6

Re: ghost rating

Напоминать надо было раньше а не когда за тебя напомнили. А почему неудивительно что есть ошибки ? О_О ... Я че тупой штоле :huyase

7

Re: ghost rating

Реализовал всем спасибо

8

Re: ghost rating

и как же?)

9

Re: ghost rating

Блин не понял я((

XOM91K wrote:

Привет хэрпивару! Вопрос: как правильно настроить это?

{    
    t_account * acc;
    char query[2048];
    t_sql_engine *sql = NULL;
    t_sql_res * result = NULL;
    t_sql_row * Row = NULL;

    text = skip_command(text); // Extract command. (Parameters, etc.)
    acc = accountlist_find_account(text); // Get account according to the name parameter.

    sql = &sql_mysql; // The SQL connection.
    if (!sql) // Check if the SQL connection exists.
    {
        eventlog(eventlog_level_error, __FUNCTION__, "sql layer not initilized"); // The SQL connection does not exist.
        return -1;
    }
    if ( acc != NULL ) // Check if the account is NULL or not.
    {
        // Run some bad-ass SQL query.
        snprintf(query,sizeof(query),"select totgames,wins,losses,killstotal,deathstotal,creepkillstotal,creepdeniestotal,assiststotal,neutralkillstotal,towerkillstotal,raxkillstotal,courierkillstotal,kills,deaths,creepkills,creepdenies,assists,neutralkills,towerkills,raxkills,courierkills, server from(select *, (kills/deaths) as killdeathratio, (totgames-wins) as losses from (select gp.name as name,ga.server as server,gp.gameid as gameid, gp.colour as colour, avg(dp.courierkills) as courierkills, sum(dp.raxkills) as raxkillstotal, sum(dp.towerkills) as towerkillstotal, sum(dp.assists) as assiststotal,sum(dp.courierkills) as courierkillstotal, sum(dp.creepdenies) as creepdeniestotal, sum(dp.creepkills) as creepkillstotal,sum(dp.neutralkills) as neutralkillstotal, sum(dp.deaths) as deathstotal, sum(dp.kills) as killstotal,avg(dp.raxkills) as raxkills,avg(dp.towerkills) as towerkills, avg(dp.assists) as assists, avg(dp.creepdenies) as creepdenies, avg(dp.creepkills) as creepkills,avg(dp.neutralkills) as neutralkills, avg(dp.deaths) as deaths, avg(dp.kills) as kills,count(*) as totgames, SUM(case when((dg.winner = 1 and dp.newcolour < 6) or (dg.winner = 2 and dp.newcolour > 6)) then 1 else 0 end) as wins from gameplayers as gp, dotagames as dg, games as ga,dotaplayers as dp where dg.winner <> 0 and dp.gameid = gp.gameid and dg.gameid = dp.gameid and dp.gameid = ga.id and gp.gameid = dg.gameid and gp.colour = dp.colour and gp.name='%s' group by gp.name) as h) as i",    account_get_name(acc));
        result = sql->query_res(query); // Copy the result of the query.
        eventlog(eventlog_level_error,__FUNCTION__,query); // Log the query, as an error(?)
        if (result != NULL) // Check if the query didn't return NULL or is NULL.
        {
            if (sql->num_rows(result) < 1) // Check if the user has played any games on linked bots.
            {
                message_send_text(c,message_type_error,c,"Rating Doesnt exist"); // No entries found.
                sql->free_result(result);
                return 0;
            }
            while ((Row = sql->fetch_row(result)) != NULL) // Now we run through all rows found in the result of the query.
            {
                uint32_t TotalGames = std::atoi( Row[0] );
    
                if( TotalGames > 0 ) // Make sure the row has at least a total amount of games played higher than zero.
                {
                    // Parsing is done here. No comments needed.
                    uint32_t TotalWins = std::atoi( Row[1] );
                    uint32_t TotalLosses = std::atoi( Row[2] );
                    uint32_t TotalKills = std::atoi( Row[3] );
                    uint32_t TotalDeaths = std::atoi( Row[4] );
                    uint32_t TotalCreepKills = std::atoi( Row[5] );
                    uint32_t TotalCreepDenies = std::atoi( Row[6] );
                    uint32_t TotalAssists = std::atoi( Row[7] );
                    uint32_t TotalNeutralKills = std::atoi( Row[8] );
                    uint32_t TotalTowerKills = std::atoi( Row[9] );
                    uint32_t TotalRaxKills = std::atoi( Row[10] );
                    uint32_t TotalCourierKills = std::atoi( Row[11] );
    
                    double wpg = 0;
                    double lpg = 0;
                    double kpg = (double)TotalKills/TotalGames;
                    double dpg = (double)TotalDeaths/TotalGames;
                    double ckpg = (double)TotalCreepKills/TotalGames;
                    double cdpg = (double)TotalCreepDenies/TotalGames;
                    double apg = (double)TotalAssists/TotalGames;
                    double nkpg = (double)TotalNeutralKills/TotalGames;
                    double tkpg = (double)TotalTowerKills/TotalGames;
                    double rkpg = (double)TotalRaxKills/TotalGames;
                    double coukpg = (double)TotalCourierKills/TotalGames;
                    
                    double Score = std::atoi( Row[21] );
                    uint32_t Rank = 0;
                    wpg = (double)TotalWins/TotalGames;
                    lpg = (double)TotalLosses/TotalGames;
                    wpg = wpg * 100;
                    lpg = lpg * 100;
                    uint32_t leavecount = 0;
                    
                    // Make the sendable text and send it.
                    snprintf(msgtemp, sizeof(msgtemp), "Rating >> S/W/L/K/D/CK/CD/A/NK/TK/RK/CK %d/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u",Score,TotalWins,TotalLosses,TotalKills,TotalDeaths,TotalCreepKills,TotalCreepDenies,TotalAssists,TotalNeutralKills,TotalTowerKills,TotalRaxKills,TotalCourierKills);
                    message_send_text(c,message_type_info,c,msgtemp);
                    return 0;
                }
                else
                {
                    // Return this when there are no games found for this user.
                    message_send_text(c,message_type_error,c,"No Game");
                    return 0;
                }
            }
        }
    }
    else
    {
        snprintf(msgtemp, sizeof(msgtemp), "User was not found : %s",text);
        message_send_text(c,message_type_error,c,msgtemp);
        return 0;
    }

    message_send_text(c,message_type_error,c,"User was not found : %s",text);
    return 0;
} 

Куда надо это   поставть?

10

Re: ghost rating

HarpyWar wrote:

Источник нужно указывать, чтобы было понятно forums.pvpgn.org/index.php?topic=167686

Команда отображает статистику игрока из mysql таблицы "gameplayers", принадлежащей боту ghost.
Работает только с mysql, и pvpgn должен использовать ту же бд, что и ghost.

Чтобы это компилировалось, нужно добавить два заголовочных файла:
#include "sql_common.h"
#include "sql_mysql.h"

все uint32_t в int вроде, все О_О

11

Re: ghost rating

esenbek wrote:

Я там регаюсь))
а что  оветить?? на вопрос
What company makes Diablo?:
What company makes WARCRAFT?:

близзард *фейспелм*

лол, ты вообще понял, что я сказал?

Добавлено: 26.08.2013 08:21

лучше удали сырцы пвпгна если не шаришь.

12

Re: ghost rating

XOM91K wrote:

Привет хэрпивару! Вопрос: как правильно настроить это?

{    
    t_account * acc;
    char query[2048];
    t_sql_engine *sql = NULL;
    t_sql_res * result = NULL;
    t_sql_row * Row = NULL;

    text = skip_command(text); // Extract command. (Parameters, etc.)
    acc = accountlist_find_account(text); // Get account according to the name parameter.

    sql = &sql_mysql; // The SQL connection.
    if (!sql) // Check if the SQL connection exists.
    {
        eventlog(eventlog_level_error, __FUNCTION__, "sql layer not initilized"); // The SQL connection does not exist.
        return -1;
    }
    if ( acc != NULL ) // Check if the account is NULL or not.
    {
        // Run some bad-ass SQL query.
        snprintf(query,sizeof(query),"select totgames,wins,losses,killstotal,deathstotal,creepkillstotal,creepdeniestotal,assiststotal,neutralkillstotal,towerkillstotal,raxkillstotal,courierkillstotal,kills,deaths,creepkills,creepdenies,assists,neutralkills,towerkills,raxkills,courierkills, server from(select *, (kills/deaths) as killdeathratio, (totgames-wins) as losses from (select gp.name as name,ga.server as server,gp.gameid as gameid, gp.colour as colour, avg(dp.courierkills) as courierkills, sum(dp.raxkills) as raxkillstotal, sum(dp.towerkills) as towerkillstotal, sum(dp.assists) as assiststotal,sum(dp.courierkills) as courierkillstotal, sum(dp.creepdenies) as creepdeniestotal, sum(dp.creepkills) as creepkillstotal,sum(dp.neutralkills) as neutralkillstotal, sum(dp.deaths) as deathstotal, sum(dp.kills) as killstotal,avg(dp.raxkills) as raxkills,avg(dp.towerkills) as towerkills, avg(dp.assists) as assists, avg(dp.creepdenies) as creepdenies, avg(dp.creepkills) as creepkills,avg(dp.neutralkills) as neutralkills, avg(dp.deaths) as deaths, avg(dp.kills) as kills,count(*) as totgames, SUM(case when((dg.winner = 1 and dp.newcolour < 6) or (dg.winner = 2 and dp.newcolour > 6)) then 1 else 0 end) as wins from gameplayers as gp, dotagames as dg, games as ga,dotaplayers as dp where dg.winner <> 0 and dp.gameid = gp.gameid and dg.gameid = dp.gameid and dp.gameid = ga.id and gp.gameid = dg.gameid and gp.colour = dp.colour and gp.name='%s' group by gp.name) as h) as i",    account_get_name(acc));
        result = sql->query_res(query); // Copy the result of the query.
        eventlog(eventlog_level_error,__FUNCTION__,query); // Log the query, as an error(?)
        if (result != NULL) // Check if the query didn't return NULL or is NULL.
        {
            if (sql->num_rows(result) < 1) // Check if the user has played any games on linked bots.
            {
                message_send_text(c,message_type_error,c,"Rating Doesnt exist"); // No entries found.
                sql->free_result(result);
                return 0;
            }
            while ((Row = sql->fetch_row(result)) != NULL) // Now we run through all rows found in the result of the query.
            {
                uint32_t TotalGames = std::atoi( Row[0] );
    
                if( TotalGames > 0 ) // Make sure the row has at least a total amount of games played higher than zero.
                {
                    // Parsing is done here. No comments needed.
                    uint32_t TotalWins = std::atoi( Row[1] );
                    uint32_t TotalLosses = std::atoi( Row[2] );
                    uint32_t TotalKills = std::atoi( Row[3] );
                    uint32_t TotalDeaths = std::atoi( Row[4] );
                    uint32_t TotalCreepKills = std::atoi( Row[5] );
                    uint32_t TotalCreepDenies = std::atoi( Row[6] );
                    uint32_t TotalAssists = std::atoi( Row[7] );
                    uint32_t TotalNeutralKills = std::atoi( Row[8] );
                    uint32_t TotalTowerKills = std::atoi( Row[9] );
                    uint32_t TotalRaxKills = std::atoi( Row[10] );
                    uint32_t TotalCourierKills = std::atoi( Row[11] );
    
                    double wpg = 0;
                    double lpg = 0;
                    double kpg = (double)TotalKills/TotalGames;
                    double dpg = (double)TotalDeaths/TotalGames;
                    double ckpg = (double)TotalCreepKills/TotalGames;
                    double cdpg = (double)TotalCreepDenies/TotalGames;
                    double apg = (double)TotalAssists/TotalGames;
                    double nkpg = (double)TotalNeutralKills/TotalGames;
                    double tkpg = (double)TotalTowerKills/TotalGames;
                    double rkpg = (double)TotalRaxKills/TotalGames;
                    double coukpg = (double)TotalCourierKills/TotalGames;
                    
                    double Score = std::atoi( Row[21] );
                    uint32_t Rank = 0;
                    wpg = (double)TotalWins/TotalGames;
                    lpg = (double)TotalLosses/TotalGames;
                    wpg = wpg * 100;
                    lpg = lpg * 100;
                    uint32_t leavecount = 0;
                    
                    // Make the sendable text and send it.
                    snprintf(msgtemp, sizeof(msgtemp), "Rating >> S/W/L/K/D/CK/CD/A/NK/TK/RK/CK %d/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u",Score,TotalWins,TotalLosses,TotalKills,TotalDeaths,TotalCreepKills,TotalCreepDenies,TotalAssists,TotalNeutralKills,TotalTowerKills,TotalRaxKills,TotalCourierKills);
                    message_send_text(c,message_type_info,c,msgtemp);
                    return 0;
                }
                else
                {
                    // Return this when there are no games found for this user.
                    message_send_text(c,message_type_error,c,"No Game");
                    return 0;
                }
            }
        }
    }
    else
    {
        snprintf(msgtemp, sizeof(msgtemp), "User was not found : %s",text);
        message_send_text(c,message_type_error,c,msgtemp);
        return 0;
    }

    message_send_text(c,message_type_error,c,"User was not found : %s",text);
    return 0;
} 

Этот код нужно  куда вставлять??

Добавлено: 26.08.2013 20:22

XOM91K wrote:

Привет хэрпивару! Вопрос: как правильно настроить это?

{    
    t_account * acc;
    char query[2048];
    t_sql_engine *sql = NULL;
    t_sql_res * result = NULL;
    t_sql_row * Row = NULL;

    text = skip_command(text); // Extract command. (Parameters, etc.)
    acc = accountlist_find_account(text); // Get account according to the name parameter.

    sql = &sql_mysql; // The SQL connection.
    if (!sql) // Check if the SQL connection exists.
    {
        eventlog(eventlog_level_error, __FUNCTION__, "sql layer not initilized"); // The SQL connection does not exist.
        return -1;
    }
    if ( acc != NULL ) // Check if the account is NULL or not.
    {
        // Run some bad-ass SQL query.
        snprintf(query,sizeof(query),"select totgames,wins,losses,killstotal,deathstotal,creepkillstotal,creepdeniestotal,assiststotal,neutralkillstotal,towerkillstotal,raxkillstotal,courierkillstotal,kills,deaths,creepkills,creepdenies,assists,neutralkills,towerkills,raxkills,courierkills, server from(select *, (kills/deaths) as killdeathratio, (totgames-wins) as losses from (select gp.name as name,ga.server as server,gp.gameid as gameid, gp.colour as colour, avg(dp.courierkills) as courierkills, sum(dp.raxkills) as raxkillstotal, sum(dp.towerkills) as towerkillstotal, sum(dp.assists) as assiststotal,sum(dp.courierkills) as courierkillstotal, sum(dp.creepdenies) as creepdeniestotal, sum(dp.creepkills) as creepkillstotal,sum(dp.neutralkills) as neutralkillstotal, sum(dp.deaths) as deathstotal, sum(dp.kills) as killstotal,avg(dp.raxkills) as raxkills,avg(dp.towerkills) as towerkills, avg(dp.assists) as assists, avg(dp.creepdenies) as creepdenies, avg(dp.creepkills) as creepkills,avg(dp.neutralkills) as neutralkills, avg(dp.deaths) as deaths, avg(dp.kills) as kills,count(*) as totgames, SUM(case when((dg.winner = 1 and dp.newcolour < 6) or (dg.winner = 2 and dp.newcolour > 6)) then 1 else 0 end) as wins from gameplayers as gp, dotagames as dg, games as ga,dotaplayers as dp where dg.winner <> 0 and dp.gameid = gp.gameid and dg.gameid = dp.gameid and dp.gameid = ga.id and gp.gameid = dg.gameid and gp.colour = dp.colour and gp.name='%s' group by gp.name) as h) as i",    account_get_name(acc));
        result = sql->query_res(query); // Copy the result of the query.
        eventlog(eventlog_level_error,__FUNCTION__,query); // Log the query, as an error(?)
        if (result != NULL) // Check if the query didn't return NULL or is NULL.
        {
            if (sql->num_rows(result) < 1) // Check if the user has played any games on linked bots.
            {
                message_send_text(c,message_type_error,c,"Rating Doesnt exist"); // No entries found.
                sql->free_result(result);
                return 0;
            }
            while ((Row = sql->fetch_row(result)) != NULL) // Now we run through all rows found in the result of the query.
            {
                uint32_t TotalGames = std::atoi( Row[0] );
    
                if( TotalGames > 0 ) // Make sure the row has at least a total amount of games played higher than zero.
                {
                    // Parsing is done here. No comments needed.
                    uint32_t TotalWins = std::atoi( Row[1] );
                    uint32_t TotalLosses = std::atoi( Row[2] );
                    uint32_t TotalKills = std::atoi( Row[3] );
                    uint32_t TotalDeaths = std::atoi( Row[4] );
                    uint32_t TotalCreepKills = std::atoi( Row[5] );
                    uint32_t TotalCreepDenies = std::atoi( Row[6] );
                    uint32_t TotalAssists = std::atoi( Row[7] );
                    uint32_t TotalNeutralKills = std::atoi( Row[8] );
                    uint32_t TotalTowerKills = std::atoi( Row[9] );
                    uint32_t TotalRaxKills = std::atoi( Row[10] );
                    uint32_t TotalCourierKills = std::atoi( Row[11] );
    
                    double wpg = 0;
                    double lpg = 0;
                    double kpg = (double)TotalKills/TotalGames;
                    double dpg = (double)TotalDeaths/TotalGames;
                    double ckpg = (double)TotalCreepKills/TotalGames;
                    double cdpg = (double)TotalCreepDenies/TotalGames;
                    double apg = (double)TotalAssists/TotalGames;
                    double nkpg = (double)TotalNeutralKills/TotalGames;
                    double tkpg = (double)TotalTowerKills/TotalGames;
                    double rkpg = (double)TotalRaxKills/TotalGames;
                    double coukpg = (double)TotalCourierKills/TotalGames;
                    
                    double Score = std::atoi( Row[21] );
                    uint32_t Rank = 0;
                    wpg = (double)TotalWins/TotalGames;
                    lpg = (double)TotalLosses/TotalGames;
                    wpg = wpg * 100;
                    lpg = lpg * 100;
                    uint32_t leavecount = 0;
                    
                    // Make the sendable text and send it.
                    snprintf(msgtemp, sizeof(msgtemp), "Rating >> S/W/L/K/D/CK/CD/A/NK/TK/RK/CK %d/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u",Score,TotalWins,TotalLosses,TotalKills,TotalDeaths,TotalCreepKills,TotalCreepDenies,TotalAssists,TotalNeutralKills,TotalTowerKills,TotalRaxKills,TotalCourierKills);
                    message_send_text(c,message_type_info,c,msgtemp);
                    return 0;
                }
                else
                {
                    // Return this when there are no games found for this user.
                    message_send_text(c,message_type_error,c,"No Game");
                    return 0;
                }
            }
        }
    }
    else
    {
        snprintf(msgtemp, sizeof(msgtemp), "User was not found : %s",text);
        message_send_text(c,message_type_error,c,msgtemp);
        return 0;
    }

    message_send_text(c,message_type_error,c,"User was not found : %s",text);
    return 0;
} 

Этот код нужно  куда вставлять??

Добавлено: 26.08.2013 20:23

Надо сюда?7

snprintf(msgtemp, sizeof(msgtemp), "Your Dota-AllStarS record:",account_get_name(account));
        message_send_text(c,message_type_info,c,msgtemp);
        snprintf(msgtemp, sizeof(msgtemp), "Ladder Games (5x5): %u, ",
        account_get_ladder_level(account,clienttag_uint,ladder_id_solo),
        account_get_ladder_xp(account,clienttag_uint,ladder_id_solo));
        message_send_text(c,message_type_info,c,msgtemp);
        snprintf(msgtemp, sizeof(msgtemp), "Next Ladder Games!!!",
        account_get_ladder_wins(account,clienttag_uint,ladder_id_solo),
        account_get_ladder_losses(account,clienttag_uint,ladder_id_solo));
        message_send_text(c,message_type_info,c,msgtemp);

/bnetd/ommand.cpp

13

Re: ghost rating

конечно нет/да

14

Re: ghost rating

suite
Этот код

Suite wrote:

static int _handle_rating_command(t_connection *c,char const * text)
{   
    t_account * acc;
    char query[2048];
    t_sql_engine *sql = NULL;
    t_sql_res * result = NULL;
    t_sql_row * Row = NULL;

   
   
    text = skip_command(text);
    acc = accountlist_find_account(text);
   


    sql = &sql_mysql;
     if (!sql)
    {
        eventlog(eventlog_level_error, __FUNCTION__, "sql layer not initilized");
        return -1;
    }
    if ( acc != NULL )
    {
            snprintf(query,sizeof(query),"select totgames,wins,losses,killstotal,deathstotal,creepkillstotal,creepdeniestotal,assiststotal,neutralkillstotal,towerkillstotal,raxkillstotal,courierkillstotal,kills,deaths,creepkills,creepdenies,assists,neutralkills,towerkills,raxkills,courierkills, server from(select *, (kills/deaths) as killdeathratio, (totgames-wins) as losses from (select gp.name as name,ga.server as server,gp.gameid as gameid, gp.colour as colour, avg(dp.courierkills) as courierkills, sum(dp.raxkills) as raxkillstotal, sum(dp.towerkills) as towerkillstotal, sum(dp.assists) as assiststotal,sum(dp.courierkills) as courierkillstotal, sum(dp.creepdenies) as creepdeniestotal, sum(dp.creepkills) as creepkillstotal,sum(dp.neutralkills) as neutralkillstotal, sum(dp.deaths) as deathstotal, sum(dp.kills) as killstotal,avg(dp.raxkills) as raxkills,avg(dp.towerkills) as towerkills, avg(dp.assists) as assists, avg(dp.creepdenies) as creepdenies, avg(dp.creepkills) as creepkills,avg(dp.neutralkills) as neutralkills, avg(dp.deaths) as deaths, avg(dp.kills) as kills,count(*) as totgames, SUM(case when((dg.winner = 1 and dp.newcolour < 6) or (dg.winner = 2 and dp.newcolour > 6)) then 1 else 0 end) as wins from gameplayers as gp, dotagames as dg, games as ga,dotaplayers as dp where dg.winner <> 0 and dp.gameid = gp.gameid and dg.gameid = dp.gameid and dp.gameid = ga.id and gp.gameid = dg.gameid and gp.colour = dp.colour and gp.name='%s' group by gp.name) as h) as i",    account_get_name(acc));
            result = sql->query_res(query);
            eventlog(eventlog_level_error,__FUNCTION__,query);
            if (result != NULL)
            {
                if (sql->num_rows(result) < 1)
                {
                    message_send_text(c,message_type_error,c,"Rating Doesnt exist");
                    sql->free_result(result);
                    return 0;        /* empty clan list */
                }
                while ((Row = sql->fetch_row(result)) != NULL)
                {
                    uint32_t TotalGames = std::atoi( Row[0] );

                    if( TotalGames > 0 )
                    {
                   

                        uint32_t TotalWins = std::atoi( Row[1] );
                        uint32_t TotalLosses = std::atoi( Row[2] );
                        uint32_t TotalKills = std::atoi( Row[3] );
                        uint32_t TotalDeaths = std::atoi( Row[4] );
                        uint32_t TotalCreepKills = std::atoi( Row[5] );
                        uint32_t TotalCreepDenies = std::atoi( Row[6] );
                        uint32_t TotalAssists = std::atoi( Row[7] );
                        uint32_t TotalNeutralKills = std::atoi( Row[8] );
                        uint32_t TotalTowerKills = std::atoi( Row[9] );
                        uint32_t TotalRaxKills = std::atoi( Row[10] );
                        uint32_t TotalCourierKills = std::atoi( Row[11] );

                        double wpg = 0;
                        double lpg = 0;
                        double kpg = (double)TotalKills/TotalGames;
                        double dpg = (double)TotalDeaths/TotalGames;
                        double ckpg = (double)TotalCreepKills/TotalGames;
                        double cdpg = (double)TotalCreepDenies/TotalGames;
                        double apg = (double)TotalAssists/TotalGames;
                        double nkpg = (double)TotalNeutralKills/TotalGames;
                        double tkpg = (double)TotalTowerKills/TotalGames;
                        double rkpg = (double)TotalRaxKills/TotalGames;
                        double coukpg = (double)TotalCourierKills/TotalGames;
                       
                        double Score = std::atoi( Row[21] );
                        uint32_t Rank = 0;
                        wpg = (double)TotalWins/TotalGames;
                        lpg = (double)TotalLosses/TotalGames;
                        wpg = wpg * 100;
                        lpg = lpg * 100;
                        uint32_t leavecount = 0;

                        snprintf(msgtemp, sizeof(msgtemp), "Rating >> S/W/L/K/D/CK/CD/A/NK/TK/RK/CK %d/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u/%u",Score,TotalWins,TotalLosses,TotalKills,TotalDeaths,TotalCreepKills,TotalCreepDenies,TotalAssists,TotalNeutralKills,TotalTowerKills,TotalRaxKills,TotalCourierKills);
                        message_send_text(c,message_type_info,c,msgtemp);
                        return 0;
                    }
                    else
                    {
                        message_send_text(c,message_type_error,c,"No Game");
                        return 0;
                    }
                }
            }
            else
            {

            }
        }
    else
    {
                   
        snprintf(msgtemp, sizeof(msgtemp), "User was not found : %s",text);
        message_send_text(c,message_type_error,c,msgtemp);
        return 0;
    }
      
       
    message_send_text(c,message_type_error,c,"User was not found : %s",text);
    return 0;
}

Через какую команду работает?

15

Re: ghost rating

откуда я знаю исходники у тебя же. надо добавить еще /rating (как я понял) и функцию

16

Re: ghost rating

{ "/rating"               , _handle_rating_command },
static int _handle_rating_command(t_connection * c, char const * text);

Эти функции??

17

Re: ghost rating

да

18

Re: ghost rating

А это  функция что дает??
/rating

19

Re: ghost rating

это не функция. оно добавляет команду /rating

20

Re: ghost rating

аа
А что показывает  это команда??

Добавлено: 29.08.2013 11:14

СТатистику что ли??
как  на ICCUPE /stats (5x5) [D] и тд. так чтоли?

21

Re: ghost rating

а чет не понял, где происходит коннект к базе?

Posts: 21

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 0 guests, 0 registered users

forums.pvpgn.pro → [RU] The Source Code → ghost rating