Euphy Posted January 23, 2014 Posted January 23, 2014 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! 9 Quote
nanakiwurtz Posted January 23, 2014 Posted January 23, 2014 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. 1 Quote
TrueNoir Posted January 24, 2014 Posted January 24, 2014 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? Quote
Sanasol Posted January 24, 2014 Posted January 24, 2014 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 )) Quote
QQfoolsorellina Posted January 24, 2014 Posted January 24, 2014 I had requested this feature for nearly two years, glad to see it being implemented thanks to Ind 、 Lemongrass and all contributors Quote
Lemongrass Posted January 24, 2014 Posted January 24, 2014 Purchasing from the control panel is not a good idea, because the shop ingame would not be refreshed on purchase. Quote
Digos Posted January 24, 2014 Posted January 24, 2014 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. Quote
Cydh Posted January 25, 2014 Posted January 25, 2014 ^not good idea because table records are updated based on game datas, not from table to player. Quote
Darkpurple Posted January 25, 2014 Posted January 25, 2014 Does this system supported this scr mod?? http://rathena.org/board/topic/60817-extended-vending-system-18/ Thanks. Quote
Cydh Posted January 25, 2014 Posted January 25, 2014 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. What? why must truncate? I never gives those permission for my MySQL user for 'safety' reason. Quote
QQfoolsorellina Posted January 25, 2014 Posted January 25, 2014 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' Quote
Cydh Posted January 25, 2014 Posted January 25, 2014 @^ I also notice it. xD and seems if the autotrader > 1 it will stuck or maybe crashed. Quote
QQfoolsorellina Posted January 26, 2014 Posted January 26, 2014 @^ 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 Quote
Darkpurple Posted January 26, 2014 Posted January 26, 2014 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. What? why must truncate? I never gives those permission for my MySQL user for 'safety' reason. : 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? Quote
Lemongrass Posted January 27, 2014 Posted January 27, 2014 (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. What? why must truncate? I never gives those permission for my MySQL user for 'safety' reason. : 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 January 27, 2014 by Lemongrass 1 Quote
nanakiwurtz Posted April 27, 2014 Posted April 27, 2014 Hi, is there an eathena version for this? I never heard about that, but I might be wrong, you could search on Google Quote
Sanasol Posted April 28, 2014 Posted April 28, 2014 Hi, is there an eathena version for this? http://rathena.org/board/topic/91855-autotrade-persistence-live-vendor-data/?p=241528 Quote
Cydh Posted July 16, 2014 Posted July 16, 2014 so, anyone got issue about this for Pre-Renewal/client ver < 20120201 / no #define NEW_CARTS? autotrade persistency never been loaded? Quote
Napster Posted July 16, 2014 Posted July 16, 2014 (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 July 17, 2014 by Napster 1 Quote
Napster Posted July 17, 2014 Posted July 17, 2014 @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 1 Quote
Stingor Posted July 21, 2014 Posted July 21, 2014 (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 Edited July 21, 2014 by Stingor Quote
Cydh Posted July 21, 2014 Posted July 21, 2014 since I change it to use timer, I didn't check that Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.