This small function makes it possible to store the exchange logs in a table with player name, vnum item, date, map_index and yang
Open exchange.cpp
Search fonction :
And in this fonction search:
In this part search :
Add these lines, that will send INSERT into the player_exchange table:
C
- std::string NomObjet = item->GetName(); // store the name of the item
- char tempNomObjet[64+1]; // Create a table of a size equal to the name of the stored item
- DBManager::instance().EscapeString(tempNomObjet, sizeof(tempNomObjet), NomObjet.c_str(), NomObjet.size()); // Convers special characters such as "é'"etc into a value that can be inserted into MYSQL
- std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("INSERT INTO player_echange%s (pseudo, pseudo2, item, yang, map_index, date) VALUES('%s', '%s', '%s', '%lld', '%d', now())", get_table_postfix(), GetOwner()->GetName(), victim->GetName(), tempNomObjet, m_lGold, GetOwner()->GetMapIndex())); // Retrieve the exchange log
Search line :
Add that query for the yang
C
- std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("INSERT INTO player_echange%s (pseudo, pseudo2, item, yang, map_index, date) VALUES('%s', '%s', '%s', '%lld', '%d', now())", get_table_postfix(), GetOwner()->GetName(), victim->GetName(), "YANG", m_lGold, GetOwner()->GetMapIndex())); // Retrieve the log exchange
It done !
Now you need to create a tabele in Navicat (database player)
SQL
- DROP TABLE IF EXISTS `player_echange`;
- CREATE TABLE `player_echange` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `pseudo` varchar(255) NOT NULL,
- `pseudo2` varchar(255) NOT NULL,
- `item` varchar(255) NOT NULL,
- `yang` bigint(19) NOT NULL DEFAULT '0',
- `map_index` int(11) NOT NULL DEFAULT '0',
- `date` varchar(255) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Warning : uniqueptr exist only under gcc48 to gcc6, if you are still under gcc42 replace all unique_ptr with auto_ptr
Best regards, Winchester
Jin