Sanasol 27 Posted August 25, 2013 (edited) Source inserting shop info into database.Few source lines and a little bit of magic php + jsDecorated with new Twitter Bootstrap Remake of this http://www.eathena.ws/board/index.php?showtopic=255406 /oops Installation diff --git a/src/map/unit.c b/src/map/unit.cindex 22c7165..9b0aa6a 100644--- a/src/map/unit.c+++ b/src/map/unit.c@@ -2135,6 +2135,9 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, chat->leavechat(sd,0); if(sd->trade_partner) trade->cancel(sd);+ //vending to db [Sanasol]+ vending->close(sd);+ //vending to db [Sanasol] buyingstore->close(sd); searchstore->close(sd); if(sd->state.storage_flag == 1)diff --git a/src/map/vending.c b/src/map/vending.cindex 2784d46..0f213a2 100644--- a/src/map/vending.c+++ b/src/map/vending.c@@ -37,6 +37,10 @@ void vending_closevending(struct map_session_data* sd) { if( sd->state.vending ) { sd->state.vending = false; clif->closevendingboard(&sd->bl, 0);+ //vending to db [Sanasol]+ if( SQL_ERROR == SQL->Query(mmysql_handle,"delete from `vending` where `char_id`='%d'", sd->status.char_id) )+ Sql_ShowDebug(mmysql_handle);+ //vending to db [Sanasol] idb_remove(vending->db, sd->status.char_id); } }@@ -174,7 +178,18 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, vsd->vending[vend_list[i]].amount -= amount; pc->cart_delitem(vsd, idx, amount, 0, LOG_TYPE_VENDING); clif->vendingreport(vsd, idx, amount);-+ //vending to db [Sanasol]+ if(vsd->vending[vend_list[i]].amount >= 1)+ {+ if( SQL_ERROR == SQL->Query(mmysql_handle,"update `vending` set `amount`='%d' where `char_id`='%d' and `index`='%d'", vsd->vending[vend_list[i]].amount, vsd->status.char_id, vend_list[i]) )+ Sql_ShowDebug(mmysql_handle);+ }+ else+ {+ if( SQL_ERROR == SQL->Query(mmysql_handle,"delete from `vending` where `char_id`='%d' and `index`='%d'", vsd->status.char_id, vend_list[i]) )+ Sql_ShowDebug(mmysql_handle);+ }+ //vending to db [Sanasol] //print buyer's name if( battle_config.buyer_name ) { char temp[256];@@ -281,6 +296,19 @@ void vending_openvending(struct map_session_data* sd, const char* message, const safestrncpy(sd->message, message, MESSAGE_SIZE); clif->openvending(sd,sd->bl.id,sd->vending);+ //vending to db [Sanasol]+ for( j = 0; j < count; j++ )+ {+ int index = sd->vending[j].index;+ struct item_data* data = itemdb->search(sd->status.cart[index].nameid);+ int nameid = ( data->view_id > 0 ) ? data->view_id : sd->status.cart[index].nameid;+ int amount = sd->vending[j].amount;+ int price = cap_value(sd->vending[j].value, 0, (unsigned int)battle_config.vending_max_value);+ + if( SQL_ERROR == SQL->Query(mmysql_handle,"INSERT INTO `vending` (`char_id`,`name`,`index`,`nameid`,`amount`,`price`,`refine`,`card0`,`card1`,`card2`,`card3`) VALUES (%d, '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", sd->status.char_id, message, j, nameid, amount, price, sd->status.cart[index].refine, sd->status.cart[index].card[0], sd->status.cart[index].card[1], sd->status.cart[index].card[2], sd->status.cart[index].card[3]) )+ Sql_ShowDebug(mmysql_handle);+ }+ //vending to db [Sanasol] clif->showvendingboard(&sd->bl,message,0); idb_put(vending->db, sd->vender_id, sd); Create table CREATE TABLE IF NOT EXISTS `vending` ( `char_id` int(11) unsigned NOT NULL DEFAULT '0', `name` varchar(50) DEFAULT NULL, `index` tinyint(3) unsigned NOT NULL DEFAULT '0', `nameid` int(11) unsigned NOT NULL DEFAULT '0', `amount` int(11) unsigned NOT NULL DEFAULT '0', `price` bigint(20) unsigned NOT NULL DEFAULT '0', `refine` tinyint(3) unsigned NOT NULL DEFAULT '0', `card0` smallint(11) NOT NULL DEFAULT '0', `card1` smallint(11) NOT NULL DEFAULT '0', `card2` smallint(11) NOT NULL DEFAULT '0', `card3` smallint(11) NOT NULL DEFAULT '0', PRIMARY KEY (`char_id`,`index`), KEY `char_id` (`char_id`), KEY `nameid` (`nameid`)) ENGINE=MyISAM; Screenshots Main page Map position tooltip For map showing need *.gat files Approximate position, accurate display at map could not to achieve And Search Item images very old, you need to add the new items FluxCP Screens DemoFluxCP Demo Sources My src versions: Hercules SRC Patch + web Standalone or FluxCP Yommy src versions: Standalone or FluxCP [NEW 04.20.14] Hercules src version: FluxCP Sources is absolutely free, but if you want you can do donation Edited March 4, 2016 by Sanasol 6 Dies Irae, evilpuncker, mleo1 and 3 others reacted to this Quote Share this post Link to post Share on other sites
evilpuncker 503 Posted August 25, 2013 please make it compatible with hercules (for newbies) Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 25, 2013 did you try with hercules? i think it must work Quote Share this post Link to post Share on other sites
Dramosith 4 Posted August 25, 2013 (edited) Sanasol, i think you need read this topic hercules too http://herc.ws/board/topic/2107-web-vending-database/?hl=vending And idk if those code is create by all you? i just saw [add-on] Vending Zone by KarLaeda Edited August 3, 2016 by Mysterious Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 25, 2013 Patch for Hercules ready https://github.com/S-anasol/sanasol/blob/ea8588531d955be28f722c1d73902ac08db224b3/merchant_db_hercules_source.patch Quote Share this post Link to post Share on other sites
Mystery 594 Posted August 25, 2013 Wow…. very awesome and kind of you to release such a nice feature! Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 25, 2013 Sanasol, i think you need read this topic hercules too http://herc.ws/board/topic/2107-web-vending-database/?hl=vending And idk if those code is create by all you? i just saw [add-on] Vending Zone by KarLaeda it absolutely other addon this is all my code, except .gat read class Quote Share this post Link to post Share on other sites
quesoph 105 Posted August 26, 2013 (edited) Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 21Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 21Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 22Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 22Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 21Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 21Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 22Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 22Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 21Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 21Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 22Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 22 this appears when trying to vend named item. @edit typo: line 13 of config.php $refine = array(0 =>"-", "+1", "+2", "+3", "+4", "+5", "+5", "+6", "+7","+8","+9","+10"); I think it should be: $refine = array(0 =>"-", "+1", "+2", "+3", "+4", "+5", "+6", "+7","+8","+9","+10"); @TS Good job Edited August 26, 2013 by quesoph 1 Sanasol reacted to this Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 26, 2013 (edited) Oops typo Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 21Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 21Notice: Undefined offset: 0 in C:Xampphtdocshervendorconfig.php on line 22Notice: Trying to get property of non-object in C:Xampphtdocshervendorconfig.php on line 22 That means "item"(card id from slot) not found, need add some check Edited August 26, 2013 by Sanasol Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 26, 2013 Fix for named item Fix require paths Fix refine array Commit: https://github.com/S-anasol/sanasol/commit/d14166acda05f31e9b8460f824882523b64a91cf Quote Share this post Link to post Share on other sites
Dramosith 4 Posted August 26, 2013 (edited) Sanasol, i think you need read this topic hercules too http://herc.ws/board/topic/2107-web-vending-database/?hl=vending And idk if those code is create by all you? i just saw [add-on] Vending Zone by KarLaeda it absolutely other addon this is all my code, except .gat read class Ah i understand okay what could different between with https://github.com/HerculesWS/StaffPlugins/tree/master/Yommy/Vend_SQL? Edited August 26, 2013 by Dramosith Quote Share this post Link to post Share on other sites
Helena 0 Posted August 26, 2013 https://github.com/H.../Yommy/Vend_SQL This doesnt seem web based or is it? Quote Share this post Link to post Share on other sites
jaBote 438 Posted August 26, 2013 Yommy's is a plugin and doesn't require any source edit and once compiled can activated/deactivated with just a conf change and a server restart, but has no web counterpart. This one's just a source edit that needs compilation both for adding and removing it, but has a web counterpart. In case of Yommy's you just would need to make the web part yourself. Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 26, 2013 Flux fix named item Flux fix refine array https://github.com/S-anasol/sanasol/commit/ed5d5ef1ce0f6481be1da7dda082ece16a44766d Added Yommy's src version for flux and sa scripts Yommy Flux https://github.com/S-anasol/sanasol/tree/master/merchant_db_flux_yommy Yommy Standalone https://github.com/S-anasol/sanasol/tree/master/merchant_db_yommy 2 mleo1 and Dramosith reacted to this Quote Share this post Link to post Share on other sites
Dramosith 4 Posted August 27, 2013 Wow Thanks so much you saved my time Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 29, 2013 (edited) Added Demo and FluxCP demo Edited August 29, 2013 by Sanasol Quote Share this post Link to post Share on other sites
thanna 11 Posted August 31, 2013 Sir sanasol, I'll just ask if your web vending database is compatible with extended vending system or is there a way to make it compatible Quote Share this post Link to post Share on other sites
Sanasol 27 Posted August 31, 2013 looked extended vending code, i think it should work. Just on the site will show that the price zeny, but in the name of the store kind of like to show the correct currency Quote Share this post Link to post Share on other sites
thanna 11 Posted September 1, 2013 thanks sir, great work btw Quote Share this post Link to post Share on other sites
Sanasol 27 Posted September 1, 2013 Some fixes for both versions. FluxCP my and Yommy src Standalone my and Yommy src Thank RagnaOk for providing the veeery big data to detect bugs: http://ragnaok.net/vending_database/ Quote Share this post Link to post Share on other sites
quesoph 105 Posted October 4, 2013 This has an error on hercules latest patch.. to make it work change: mmysql_handle to map->mysql_handle Quote Share this post Link to post Share on other sites
EriNa_KillerSoul 9 Posted November 1, 2013 This has an error on hercules latest patch.. to make it work change: mmysql_handle to map->mysql_handle I got this error vending.c: In function âvending_closevendingâ:vending.c:41: warning: implicit declaration of function âSql_Queryâvending.c: In function âvending_openvendingâ:vending.c:405: warning: implicit declaration of function âitemdb_searchâvending.c:405: warning: initialization makes pointer from integer without a castvending.c: In function âvending_purchasereqâ:vending.c:260: warning: âitem_nameâ may be used uninitialized in this function Quote Share this post Link to post Share on other sites
ossi0110 200 Posted November 1, 2013 (edited) This has an error on hercules latest patch.. to make it work change: mmysql_handle to map->mysql_handle I got this error vending.c: In function âvending_closevendingâ:vending.c:41: warning: implicit declaration of function âSql_Queryâvending.c: In function âvending_openvendingâ:vending.c:405: warning: implicit declaration of function âitemdb_searchâvending.c:405: warning: initialization makes pointer from integer without a castvending.c: In function âvending_purchasereqâ:vending.c:260: warning: âitem_nameâ may be used uninitialized in this function Vending.c Line 41 change Sql_Query to SQL->Query Vending.c Line 405 change itemdb_search to itemdb->search Edited November 1, 2013 by ossi0110 Quote Share this post Link to post Share on other sites
SSky 2 Posted November 7, 2013 (edited) Hello, anyone knows how to fix this? Item name is Unkown, Refine is not shown, Card goes Unkown Item too. Btw, im using Hercules FluxCp Edited November 7, 2013 by SSky Quote Share this post Link to post Share on other sites