Hiện bộ gõ=phím F8
PRESS F9 to turn on/off the unicode typing method. Bộ gõ Tiếng Việt kiểu VNI đã mặc định bật, bấm F8 để hiện trạng thái bộ gõ và hiệu chỉnh khi cần.
Latest topics
» Specified Game requires a saved game file problem
Tue Nov 24, 2015 6:08 am by kingsamurie

» Strange Invalid version error after changing to bnet version 26
Wed Oct 07, 2015 9:26 am by Gen

» Perfect-G 412KANAKO Gallery
Wed Sep 23, 2015 11:32 pm by Guest

» Fully Naked Pics Of Jessica Gomes
Tue Jul 07, 2015 5:57 pm by Guest

» The One Tree Hill Season 3
Sun Jun 07, 2015 11:27 am by Guest

» The One Tree Hill Season 3
Sun Jun 07, 2015 11:20 am by Guest

» When i host i get this error using Gen MOdded Ghostone(Latest ver)
Mon Apr 21, 2014 12:00 am by kingsamurie

» When i type !map on any kind of map i get this error
Sun Apr 20, 2014 11:59 pm by kingsamurie

» Players get kicked
Thu Oct 17, 2013 1:51 am by keisersoze

» Where to find Games!
Tue Oct 15, 2013 11:22 am by kokkis

Thống Kê/Statistic
Free counters!

Update Welcome patch

View previous topic View next topic Go down

Update Welcome patch

Post by russoka on Fri Nov 16, 2012 4:32 am

After hard work with compiler, I am create my first patch. I know it is not best, may be i have errors. On my bot is working pretty good.

For patch i'm used WinMerge. Version Ghost One - Ghost One Gen Modded 1.51 (from svn). If you know better soft - I can remake patch. Working only with MySQL database!

This patch will update Welcome strings with "Top Players"

for example:

▲►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►▼
Welcome on TTW Host. This is Russian/English server.
Связь с Adminом Skype: Euro.TTW.Host
Hosting Bot from: thegenmaps.tk
▲◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄▼
Top Players:
1 - Krieg_Schnee - 194 games.
2 - Fanty01 - 112 games.
3 - zed1405 - 88 games.
4 - 94makc26RUS - 85 games.
5 - Fenestra - 80 games.
6 - piczasso - 79 games.
7 - russoka - 74 games.
8 - Shvecov.v - 74 games.
9 - Dobik2008 - 71 games.
10 - sonikcx - 71 games.


Ghost.H
Code:
440a441
>    void UpdateWelcome();
513a515,521
>
>    // mysql values for update welcome
>    string m_Server;
>    string m_Database;
>    string m_User;
>    string m_Password;
>    int m_Port;

Ghost.CPP
Code:
48a49,50
> #include <mysql/mysql.h>
>
945a948,955
>
>    // MySQL values for Update Welcome.
>    m_Server = CFG->GetString( "db_mysql_server", string( ) );
>    m_Database = CFG->GetString( "db_mysql_database", "ghost" );
>    m_User = CFG->GetString( "db_mysql_user", string( ) );
>    m_Password = CFG->GetString( "db_mysql_password", string( ) );
>    m_Port = CFG->GetInt( "db_mysql_port", 3306 );
>
4268a4279,4311
>    UpdateWelcome();
>    return;
>
>    string file = "welcome.txt";
>    ifstream in;
>    in.open( file.c_str( ) );
>    m_Welcome.clear();
>    if( in.fail( ) )
>        CONSOLE_Print( "[GHOST] warning - unable to read file [" + file + "]" );
>    else
>    {
>        CONSOLE_Print( "[GHOST] loading file [" + file + "]" );
>        string Line;
>
>        while( !in.eof( ) )
>        {
>            getline( in, Line );
>
>            // ignore blank lines and comments
>
>            if( Line.empty( ) || Line[0] == '#' )
>                continue;
>            m_Welcome.push_back(Line);
>        }
>    }
>    in.close( );
> }
>
> void CGHost :: UpdateWelcome ()
> {
>    // TODOWELCOME
>    // Перенести переменную bShowRatingMySQL в глобалки и конфиг.
>    // Добавить автовыполнение этой команды раз в 5 минут.
4269a4313
>    bool bShowRatingMySQL = true;
4288a4333,4407
>        }
>
>        if (bShowRatingMySQL)
>        {
>            m_Welcome.push_back("Top Players:");
>            // Дескриптор соединения
>            MYSQL conn;
>            // Дескриптор результирующей таблицы
>            MYSQL_RES *res;
>            // Дескриптор строки
>            MYSQL_ROW row;
>           
>            if(!mysql_init(&conn))
>            {
>                // Если дескриптор не получен - выводим сообщение об ошибке
>                CONSOLE_Print( "Error: can't create MySQL-descriptor" );
>                return;
>            }
>
>            string FileConfig = "ghost.cfg";
>            CConfig CFG;
>            CFG.Read( FileConfig );
>            //int m_Server = CFG->GetString( "db_mysql_server", string( ) );
>            //int m_Database = CFG->GetString( "db_mysql_database", "ghost" );
>            //int m_User = CFG->GetString( "db_mysql_user", string( ) );
>            //int m_Password = CFG->GetString( "db_mysql_password", string( ) );
>            //int m_Port = CFG->GetInt( "db_mysql_port", 3306 );
>            //m_BotID = CFG->GetInt( "db_mysql_botid", 0 );
>
>            if(!mysql_real_connect(&conn, m_Server.c_str( ), m_User.c_str( ), m_Password.c_str( ), m_Database.c_str( ), m_Port, NULL, 0))
>            {
>                // Если соединение не установлено выводим сообщение об ошибке
>                CONSOLE_Print( "Error: ");
>                CONSOLE_Print( mysql_error(&conn) );
>                return;
>            }
>            // Выполняем SQL-запрос
>            if(mysql_query(&conn, "use test;") != 0)
>                CONSOLE_Print("Error: can't execute SQL-query 1");
>            if(mysql_query(&conn, "CREATE TEMPORARY TABLE tmp SELECT name, COUNT(*) as count, ip FROM db_ttw.gameplayers GROUP BY name ORDER BY COUNT(*) DESC;") != 0)
>                CONSOLE_Print("Error: can't execute SQL-query 2");
>            if(mysql_query(&conn, "select name, count from tmp LIMIT 0,10;") != 0)
>                CONSOLE_Print("Error: can't execute SQL-query 3");
>
>            // Получаем дескриптор результирующей таблицы
>            res = mysql_store_result(&conn);
>            if(res == NULL) CONSOLE_Print("Error: can't get the result description");
>
>            // Если имеется хотя бы одна запись - выводим список каталогов
>            if(mysql_num_rows(res) > 0)
>            {
>                // В цикле перебираем все записи
>                // результирующей таблицы
>                int i = 1;
>                while((row = mysql_fetch_row(res)) != NULL)
>                {
>                    // Выводим результат
>                    std::stringstream ss;
>                    std::string sNumber, str;
>                    ss << i;
>                    ss >> sNumber;
>                    str = sNumber + " - " + row[0] + " - " + row[1] + " games;";
>                    m_Welcome.push_back(str);
>                    i++;
>                }
>            }
>
>            if(mysql_query(&conn, "DROP TABLE tmp;") != 0)
>                CONSOLE_Print("Error: can't execute SQL-query 4");
>
>            // Освобождаем память, занятую результирующей таблицей
>            mysql_free_result(res);
>
>            // Закрываем соединение с сервером базы данных
>            mysql_close(&conn);

Sorry for comments on russian. I think this isn't final version.

To use - restart ghost or wishper !uw or wishper !updatewelcome. Also working with !rcfg. Oh i forget, need replace db_ttw on real db name. That is m_Database.c_str( ).

Problem: Idk how to run this command every 5 min or every last game. Please help me.

And exe file if you do not want install compiler: [You must be registered and logged in to see this link.] (Ghost One Gen Modded 1.51 + Update Welcome patch).

russoka
Active Member
Active Member

Posts : 53
Join date : 2012-10-25
Age : 26
Location : Russia / Far East

Testing
Your Garena ID:

View user profile

Back to top Go down

Re: Update Welcome patch

Post by Gen on Fri Nov 16, 2012 3:39 pm

Impressive. But it's hard to realize your new lines of code. Please follow the trick below to create the patch file. The new lines and removed lines will be colored. Tool require: Tortoise SVN.

Questions:
1. Is everything working fine and stably (no crash)?
2. Will the bot work to print the stats for any map/any game or just TTW? What will be printed out if the bots are hosting multi-games?, considering multigames autohosting Gen bots
3. What function do you call for an update? e.g. CreateIntialFakePlayers(); is used & called to auto-insert some fakeplayers initially every time a new game is created.

To make a patch file:
You can just select the modded files (.cpp & .h files if there're more than 1 file - ghost.cpp - in your case), right click on 1 of the selected files, in the right-click menu you can see Tortoise SVN, then find the Create Patch... in SVN menu. Name it lobby stats.patch or .diff, both are applicable. That must be it.
In the patch file, you will see the green field with + prefix meaning for adding, red field with - prefix meaning for removing. If you see those, then congrats!

I'm busy this time but I'll look into your problem later (December is the soonest of my possibility). You can't update what showed to the players who are staying in the lobby. Update might just work for new players joining your host.

Gen
Admin
Admin

Posts : 148
Join date : 2012-02-26

View user profile http://GarenaID G.M.Bot

Back to top Go down

Re: Update Welcome patch

Post by russoka on Fri Nov 16, 2012 8:24 pm

Yes, I can't update for old players in lobby. But no need make update too often. I will check your fake players code. My script working on all maps. MySQL actuality just make count all games for nickname and bot will show 10 lines from top. As I says this can be modified for more compatibility (for example db name from var, not const, add to config parametr and do it automatically. Idk how to do it with SQLite, but i know about this database as slowly database. May be with SQLite CPU will loaded on 100%.

russoka
Active Member
Active Member

Posts : 53
Join date : 2012-10-25
Age : 26
Location : Russia / Far East

Testing
Your Garena ID:

View user profile

Back to top Go down

Re: Update Welcome patch

Post by Admin on Sun Nov 18, 2012 1:56 am

The only problem with SQLite is Bans on Garena don't fully work.

Even though in v1.51, Garena ppls are denied from joining for 5 mins (= same time for the database refresh as adjusted to 5 mins not an hour). After 5 mins, the temporary string m_BlacklistName is cleared to reduce the memory consumption of each bot and to spare rooms for newly banned names. This theory fully works for bans on Garena with SQL database. Never test on SQLite db though. Problem is after 5 mins, that string is cleared, whether a Garena player with the banned name on SQLite db can rejoin? this hasn't been tested.

Tell me:
Can you make the new .patch file based on what I told you?
and
What function do you call for an update?(ask again from above)

- - - - - - - - - - - - Your signature - - - - - - - - - - - - -
BUNNY (\__/)
FUNNY (='.'=) TheGenMap. Official Support Forum
GENIE ('')_('') for all games Gen created and much more.
PLS upload your files on DropBox public folder and link them here.

[You must be registered and logged in to see this link.]

Admin
Admin
Admin

Posts : 131
Join date : 2009-08-03

View user profile http://thegenmaps.forumotion.net

Back to top Go down

Re: Update Welcome patch

Post by russoka on Thu Nov 22, 2012 1:48 am

Need time to learn source of ghost. I will create later.

About PHP. My First script will done (but user can't choose to view the records)

[You must be registered and logged in to see this image.]

CountGames.php
Code:
<html>
<meta http-equiv="refresh" content="9">
<body>
<?php

# BEGIN CONFIGURATION

$db_host = "HOST";
$db_username = "USER";
$db_password = "PASSWORD";
$db_name = "DATABASE";

# END CONFIGURATION

mysql_connect($db_host, $db_username, $db_password) or die("can't create mysql connection");
mysql_select_db($db_name) or die(mysql_error());
   
$query = "CREATE TEMPORARY TABLE tmp SELECT name, COUNT(*) as count, ip FROM gameplayers GROUP BY name ORDER BY COUNT(*) DESC";
mysql_query($query);

$query = "CREATE TEMPORARY TABLE tmp2 (
                id Mediumint not null Auto_Increment,
                name VARCHAR(15) NOT NULL,
                ip VARCHAR(15) NOT NULL,
                count bigint(21),
                Primary Key (id)
            )";
mysql_query($query);

$query = "INSERT INTO tmp2 (name, ip, count) SELECT name, ip, count FROM tmp";
mysql_query($query);

$query = "select * FROM tmp2 limit 0,10";
$result = mysql_query($query);

echo '<table cellspacing="0" cellpadding="2" border="1">';
echo '<tr><td>Number</td><td>Name</td><td>Games</td>';

while($row = mysql_fetch_array($result))
{
    echo '<tr><td>' , $row['id'] , '</td><td>' , $row['name'] , '</td><td>' , $row['count'] , '</td></tr>';
}

echo '</table>';

mysql_free_result($result);

?>
</body>
</html>

russoka
Active Member
Active Member

Posts : 53
Join date : 2012-10-25
Age : 26
Location : Russia / Far East

Testing
Your Garena ID:

View user profile

Back to top Go down

Re: Update Welcome patch

Post by Gen on Sun Nov 25, 2012 11:36 pm

awesome, but you may want to integrate players' ping display.

- - - - - - - - - - - - Your signature - - - - - - - - - - - - -
Garena nickname G.M.Bot
Please post on forum first, because I may not be around in Garena.

Gen
Admin
Admin

Posts : 148
Join date : 2012-02-26

View user profile http://GarenaID G.M.Bot

Back to top Go down

Re: Update Welcome patch

Post by russoka on Tue Nov 27, 2012 12:19 am

About PHP. I am working on Site. [You must be registered and logged in to see this link.] I think this is real useful.

russoka
Active Member
Active Member

Posts : 53
Join date : 2012-10-25
Age : 26
Location : Russia / Far East

Testing
Your Garena ID:

View user profile

Back to top Go down

Re: Update Welcome patch

Post by russoka on Thu Dec 27, 2012 7:26 pm

[You must be registered and logged in to see this link.]

russoka
Active Member
Active Member

Posts : 53
Join date : 2012-10-25
Age : 26
Location : Russia / Far East

Testing
Your Garena ID:

View user profile

Back to top Go down

Re: Update Welcome patch

Post by Sponsored content Today at 12:35 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum