Jump to content

Recommended Posts

Posted

Autotrade Persistence & Live Vendor Data

27cbc7f brings two major vending features to rAthena.

Live Vendor Data

All vending data is now stored in SQL tables `vendings` and `vending_items`, making the data easily accessible to third party applications. This makes it possible to display and search through player shops on web pages or control panels without any server modifications. The vending data can also be accessed through scripts, which opens similar possibilities for players to search for shop items.

[spoiler=Table Structures:]

CREATE TABLE IF NOT EXISTS `vending_items` (
  `vending_id` int(10) unsigned NOT NULL,
  `index` smallint(5) unsigned NOT NULL,
  `cartinventory_id` int(10) unsigned NOT NULL,
  `amount` smallint(5) unsigned NOT NULL,
  `price` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `vendings` (
  `id` int(10) unsigned NOT NULL,
  `account_id` int(11) unsigned NOT NULL,
  `char_id` int(10) unsigned NOT NULL,
  `sex` enum('F','M') NOT NULL DEFAULT 'M',
  `map` varchar(20) NOT NULL,
  `x` smallint(5) unsigned NOT NULL,
  `y` smallint(5) unsigned NOT NULL,
  `title` varchar(80) NOT NULL,
  `autotrade` tinyint(4) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Autotrade Persistence

Vendors in auto-trade mode (@autotrade/@at) will now automatically be logged in after a server restart. In other words, it is no longer necessary for players to re-open their shops following each reboot or maintenance, made possible due to saving of vending data. This feature can be disabled in conf/battle/feature.conf.

[spoiler=Options:]

// Autotrade persistency (Note 1)
// Should vendors that used @autotrade be restored after a restart?
feature.autotrade: on

// In which direction should respawned autotraders look?
// Possible values are from 0-7
// Default: 4(South)
feature.autotrade_direction: 4

// Do you want your autotraders to sit? (Note 1)
feature.autotrade_sit: yes

Credits

Thanks to @Lemongrass for coding this update, and @Ind for the original idea.

Don't forget to run sql-files/upgrades/upgrade_20140114.sql!

  • Upvote 9
Posted

May I suggest a text file on the sql-files/upgrades folder, that gives a hint of what that particular *.sql do.

Or a sql table only for server information, that contains which .sql upgrades they have merged (imported) on their database, so the server owner knows there are some .sql files that must be imported.

  • Upvote 1
Posted

So that means it would be possible to make a control panel application which would allow the searching and purchase remotely from a webpage or am i miss understanding the topic o.O?

Posted

So that means it would be possible to make a control panel application which would allow the searching and purchase remotely from a webpage or am i miss understanding the topic o.O?

yes. but it was possible long ago very very long ago 

 

:)))

Posted

Purchasing from  the control panel is not a good idea, because the shop ingame would not be refreshed on purchase.

 

I think that is a good idea. The vending would be stored in a table, when the sell is done, the item will be deleted from that table.
 
The player shop in the game will fetch the items from that table and will refresh the purchase list in an interval of N seconds. If someone buy an item that is not in the vending table, the sell is cancelled.
 
By this way will be possible to shop an item from the control panel.
Posted

MySQL user privilege

You need the MySQL user that access your database has permission to does Truncate (Drop and Create) table.

or this is will happens, and other errors are incoming. /hmm

ffz3.png

 

What? why must truncate? I never gives those permission for my MySQL user for 'safety' reason. /heh

Posted

@^ I also notice it. xD

and seems if the autotrader > 1 it will stuck or maybe crashed.

Same issue happened to me , after crashed then restarted server only 1st vendor persist

 

here is the map console  warring:

[Error]: _mmalloc: -269488152

Posted

MySQL user privilege

You need the MySQL user that access your database has permission to does Truncate (Drop and Create) table.

or this is will happens, and other errors are incoming. /hmm

ffz3.png

 

What? why must truncate? I never gives those permission for my MySQL user for 'safety' reason. /heh

 

: DB error - Duplicate entry '1' for key 'PRIMARY'
[Debug]: at ..\src\map\vending.c:457 - INSERT INTO `vendings`(`id`,`account_id`,
`char_id`,`sex`,`map`,`x`,`y`,`title`,`autotrade`) VALUES( 1, 2072856, 157247, '
M', 'prontera', 153, 90, '[Zeny] ComeBuy', 0 );
 
is it my problem?
Posted (edited)

 

Purchasing from  the control panel is not a good idea, because the shop ingame would not be refreshed on purchase.

Hi~lemo,

 

@autotrade command should check and update Character's sex

 

becoz sex field default value is 'M'

 

 

 

MySQL user privilege

You need the MySQL user that access your database has permission to does Truncate (Drop and Create) table.

or this is will happens, and other errors are incoming. /hmm

ffz3.png

 

What? why must truncate? I never gives those permission for my MySQL user for 'safety' reason. /heh

 

: DB error - Duplicate entry '1' for key 'PRIMARY'
[Debug]: at ..\src\map\vending.c:457 - INSERT INTO `vendings`(`id`,`account_id`,
`char_id`,`sex`,`map`,`x`,`y`,`title`,`autotrade`) VALUES( 1, 2072856, 157247, '
M', 'prontera', 153, 90, '[Zeny] ComeBuy', 0 );
 
is it my problem?

 

 

Fixed those two issues in 5988c7a.

 

[Edit:]

 

Also fixed allocation and other minor issues in 139bc1c.

Edited by Lemongrass
  • Upvote 1
  • 2 months later...
  • 2 months later...
Posted

so, anyone got issue about this for Pre-Renewal/client ver < 20120201 / no #define NEW_CARTS?

autotrade persistency never been loaded?

Posted (edited)

@Cydh

 

I Suggest for gm command when very need remove player with autotrade

 

or click right gm menu
 

void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd)
{
	int fd = tsd->fd;

	if( fd > 0 )
		clif_authfail_fd(fd, 15);
	else {
		if( tsd->state.vending && tsd->state.autotrade ){
			if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 0 WHERE `id` = %d;", vendings_db, tsd->vender_id ) != SQL_SUCCESS ){
				Sql_ShowDebug( mmysql_handle );
			}
		}else if( tsd->state.buyingstore && tsd->state.autotrade ){
			if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 0 WHERE `id` = %d;", buyingstore_db, tsd->buyer_id ) != SQL_SUCCESS ){
				Sql_ShowDebug( mmysql_handle );
			}
		}
		map_quit(tsd);
	}

	if( sd )
		clif_GM_kickack(sd,tsd->status.account_id);
}

thank you

Edited by Napster
  • Upvote 1
Posted

@Cydh

 

I have idea for look & feel perfect when create shop

			// Make him look perfect
			unit_setdir(&sd->bl,battle_config.feature_autotrade_direction);

			if( battle_config.feature_autotrade_sit )
				pc_setsit(sd);

i think allter table "action" store value for this (&dir, &head_dir, &sit)

	if (dir || head_dir)
	{
		pc_setdir(sd, dir, head_dir);
		clif_changed_dir(&sd->bl, AREA);
	}

	if( battle_config.feature_autotrade_sit )
		pc_setsit(sd);

use function input value

sprintf(value, "%d,%d,%d", sd->ud.dir, sd->head_dir, pc_issit(sd));
sscanf(sd->autotrade.action, "%d,%d,%d", &dir, &head_dir, &sit); 

I Suggest it  thank you sir

  • Upvote 1
Posted (edited)

HI, i added this feature on my eathena server, now it works fine, but i 've had an issue where the server was sometime not able to load all the shops, that was totally gambling because of this :

//If the last autotrade is loaded, clear autotraders [Cydh]
if( i + 1 >= autotrader_count )
    do_final_vending_autotrade();

i set in ARR_FIND(0,autotrader_count,i,autotraders && autotraders->char_id == sd->status.char_id);

 

so sometimes when the first shop triggered is the last of the autotrader DB  i meaning ( i + 1 >= autotrader_count ) is true and trigger do_final_vending_autotrade() so all shops are gone exept the first loaded.

 

All because they are loaded at the same time by pc_autotrade_timer triggered by timer with do_init_pc. I don't know if there is this problem on rAthena but if any user trying to put this feature on eathena server, experience this problem

I fixed it by making a second 

static uint16 autotrader_count_final = 0; and


}
autotrader_count_final++;

aFree(data);
//If the last autotrade is loaded, clear autotraders [Cydh]
if( autotrader_count_final >= autotrader_count )
    do_final_vending_autotrade();

and reseting it with autotrader_count

maybe just putting order in sql request do the job, i don't tried it at this time <<ORDER BY `char_id` DESC>>

 

Repeating that i'am on eathena so maybe it's just an outdate problem :P

Edited by Stingor

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...