How to add "Best buy items" to XP statistics?
Moderator: Forum Moderator
- YamiKaitou
- Forum Moderator
- Posts: 1925
- Joined: Wed Feb 01, 2006 4:33 pm
- Contact:
Re: How to add "Best buy items" to XP statistics?
This will involve adding a bit to the code. What do you mean by "best buy items"
No support via PM or Email
-
- Spell Breaker
- Posts: 398
- Joined: Sun Apr 27, 2008 10:11 pm
Re: How to add "Best buy items" to XP statistics?
create a new table with values of items and how many times baught. everytime some1 buy's an item add 1 to that value. are you using mysql or sqlite?

-
- Spell Breaker
- Posts: 398
- Joined: Sun Apr 27, 2008 10:11 pm
Re: How to add "Best buy items" to XP statistics?
only cause u said please ill make something up are u using mysql or sqlite?

-
- Spell Breaker
- Posts: 398
- Joined: Sun Apr 27, 2008 10:11 pm
Re: How to add "Best buy items" to XP statistics?
run this in ur mysql query to make the table for ur items
that will create ur table
this will get the top 5 items
this will input top 5 items in a motd
add this into constants.inl
in items.inl do this
in clientcommands.inl add
this will save the new purchased amounts into the mysql server
in war3ft.sma in plugin_end() add
at the bottum of
this should be all u need let me know how it works out
Code: Select all
CREATE TABLE IF NOT EXISTS `wc3_best_item` ( `item_id` int(8) unsigned NOT NULL default '0', `times_bought` int(8) unsigned NOT NULL default '0',PRIMARY KEY (`item_id`) ) TYPE=MyISAM;
this will get the top 5 items
Code: Select all
TOP_5(id)
{
// Make sure our connection is working
if ( !MYSQLX_Connection_Available() )
{
return;
}
new TopItemsName[6]; i = 0
new szQuery[256],Handle:query;
format(szQuery, 255, "SELECT * FROM `wc3_best_item` ORDER BY times_bought DESC LIMIT 5; ");
query = SQL_PrepareQuery( g_DBConn, szQuery );
if ( !SQL_Execute( query ) )
{
client_print( id, print_chat, "Sql error");
MYSQLX_Error( query, szQuery, 6 );
return;
}
// Loop through all of the records to find the items data
while ( SQL_MoreResults( query ) )
{
TopItemsName[i] = SQL_ReadResult( query, 0 );
i++
SQL_NextRow( query );
}
SQL_FreeHandle( query );
MOTD_TOPITEMS(id,TopItemsName)
}
Code: Select all
MOTD_TOPITEMS(id,Topitem[6])
{
static szTmp[256], szTmp2[256], pos, i;
pos = 0;
// Add header
pos += formatex( szTmpMsg[pos], 2047-pos, "%s", MOTD_header );
// Add the item information
for ( i = 0; i < 6; i++ )
{
LANG_GetItemInfo( Topitem[i], id, szTmp, 127 );
LANG_GetItemName( Topitem[i], id, szTmp2, 127 );
pos += formatex( szTmpMsg[pos], 2047-pos, "<li>%s</li><div id='s'>%s</div><br>", szTmp, szTmp2 );
}
formatex( szTmp, 127, "Top 5 Items Bought", id);
show_motd( id, szTmpMsg, szTmp );
}
Code: Select all
new UpdateBoughtItems[MAX_PLAYER_ITEM]
Code: Select all
ITEM_GiveItem( id, iItem )
{
UpdateBoughtItems[iItem]++
Code: Select all
CMD_Handle( id, szCmd[], bool:bThroughSay )
{
// Change the user's race
if ( CMD_Equal( id, szCmd, "changerace" ) )
{
WC3_ChangeRaceStart( id );
}
// Change the user's race
else if ( CMD_Equal( id, szCmd, "top5items" ) )
{
TOP_5(id)
}
Code: Select all
SAVETOPITEMS()
{
// Make sure our connection is working
if ( !MYSQLX_Connection_Available() )
{
return;
}
new TimesBought[MAX_PLAYER_ITEM]; i = 0
new szQuery[256],Handle:query;
format(szQuery, 255, "SELECT * FROM `wc3_best_item`; ");
query = SQL_PrepareQuery( g_DBConn, szQuery );
if ( !SQL_Execute( query ) )
{
client_print( id, print_chat, "Sql error");
MYSQLX_Error( query, szQuery, 6 );
return;
}
// Loop through all of the records to find the items data
while ( SQL_MoreResults( query ) )
{
TimesBought[i] = SQL_ReadResult( query, 1 );
i++
SQL_NextRow( query );
}
SQL_FreeHandle( query );
for( new w= 0; w < MAX_PLAYER_ITEM; w++ )
if( UpdateBoughtItems[w] != 0 )
{
TimesBought[w] += UpdateBoughtItems[w]
format( szQuery, 511, "REPLACE INTO `wc3_best_item` ( `item_id` , `times_bought` ) VALUES ( '%d', '%d', '%d' );", w, TimesBought[w] );
query = SQL_PrepareQuery( g_DBConn, szQuery );
if ( !SQL_Execute( query ) )
{
WC3_Log( false, "Unable to update bought items" );
MYSQLX_Error( query, szQuery, 5 );
return;
}
}
}
Code: Select all
SAVETOPITEMS()
Code: Select all
DB_Close();

- YamiKaitou
- Forum Moderator
- Posts: 1925
- Joined: Wed Feb 01, 2006 4:33 pm
- Contact:
Re: How to add "Best buy items" to XP statistics?
Mon Dec 03, 2007fjollerik wrote:just another question.. im using XP statistics too (MySQL)
And i was thinking.. when did you guys last made an update for that one ?

-
- Spell Breaker
- Posts: 398
- Joined: Sun Apr 27, 2008 10:11 pm
Re: How to add "Best buy items" to XP statistics?
funny thing is that im not sure if this works 100% did any1 test it out yet?
