Jump to content

Autotrade Persistence & Live Vendor Data


Euphy

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  109
  • Reputation:   19
  • Joined:  11/14/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  185
  • Reputation:   53
  • Joined:  01/04/12
  • Last Seen:  

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 

 

:)))

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   104
  • Joined:  11/19/11
  • Last Seen:  

I had requested this feature  for nearly two years, glad to see it being implemented

thanks to Ind 、 Lemongrass and all contributors

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  547
  • Reputation:   270
  • Joined:  11/08/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  88
  • Reputation:   23
  • Joined:  01/30/12
  • Last Seen:  

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.
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

^not good idea because table records are updated based on game datas, not from table to player.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  187
  • Reputation:   7
  • Joined:  09/04/12
  • Last Seen:  

Does this system supported this scr mod??

 

http://rathena.org/board/topic/60817-extended-vending-system-18/

 

Thanks.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   104
  • Joined:  11/19/11
  • Last Seen:  

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'

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

@^ I also notice it. xD

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   104
  • Joined:  11/19/11
  • Last Seen:  

@^ 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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  187
  • Reputation:   7
  • Joined:  09/04/12
  • Last Seen:  

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?
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

@u two, yup

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  547
  • Reputation:   270
  • Joined:  11/08/11
  • Last Seen:  

 

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
Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  16
  • Reputation:   0
  • Joined:  01/18/12
  • Last Seen:  

Hi, is there an eathena version for this?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Hi, is there an eathena version for this?

I never heard about that, but I might be wrong, you could search on Google :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  185
  • Reputation:   53
  • Joined:  01/04/12
  • Last Seen:  

Link to comment
Share on other sites

  • 2 months later...

  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

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

autotrade persistency never been loaded?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  196
  • Reputation:   72
  • Joined:  12/12/11
  • Last Seen:  

@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
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

I'll add config for it

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  196
  • Reputation:   72
  • Joined:  12/12/11
  • Last Seen:  

@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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  5
  • Reputation:   1
  • Joined:  03/02/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

since I change it to use timer, I didn't check that :o

Link to comment
Share on other sites

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.

×
×
  • Create New...