Lilith Posted May 4, 2012 Author Posted May 4, 2012 (edited) item_vending.txt feature.conf In-game Edited May 4, 2012 by Lilith Quote
Napster Posted May 4, 2012 Posted May 4, 2012 (edited) I am so sorry i found problem I forgot remove old config in items.conf Edited May 4, 2012 by Napster Quote
lakasmonk Posted May 6, 2012 Posted May 6, 2012 (edited) i have an error when compiling thats not all this gave me error i use rathena latest rev i use te latest one for rAthena Only diff Edited May 6, 2012 by lakasmonk123 Quote
SlashGeeGee Posted May 7, 2012 Posted May 7, 2012 Hey Lilith i got a problem on applying patch when i target my rAthena folder it says An Unknown Line Type was found in line 409 ! i use this : rAthena only: ExtendedVendingSystem_1.8.1.patch my svn : latest rA rev Quote
zxb329622888 Posted May 9, 2012 Posted May 9, 2012 (edited) I'msorry, I'm fromChina, English is not very good,sorry itemid,type,Variable name 19994,3,Vitality type = 1 zeny type = 2 cash type = 3 Custom variable nam type = 4 item Code Find: pc.h int vend_loot; Join: int vend_type; char *vend_variable; Find: item.h struct s_item_vend{ Join: int type; char variable[20]; Find: item.c static bool itemdb_read_vending(char* fields[], int columns, int current) Replace: static bool itemdb_read_vending(char* fields[], int columns, int current) { struct item_data* id; int nameid,type; nameid = atoi(fields[0]); type = atoi(fields[1]); if( ( id = itemdb_exists(nameid) ) == NULL ) { ShowWarning("itemdb_read_vending: Invalid item id %d.n", nameid); return false; } if( id->type == IT_ARMOR || id->type == IT_WEAPON ) { ShowWarning("itemdb_read_vending: item id %d cannot be equipment or weapon.n", nameid); return false; } if ( type < 0 || type > 4 ) { ShowWarning("itemdb_read_vending: 无效的type属性 %d n",type); return false; } safestrncpy(item_vend[current].variable,fields[2],sizeof(item_vend[current].variable)); item_vend[current].itemid = nameid; item_vend[current].type = type; return true; } Find: sv_readdb(db_path, "item_vending.txt", ',', 1, 1, MAX_INVENTORY, &itemdb_read_vending); Replace: sv_readdb(db_path, "item_vending.txt", ',', 3, 3, MAX_INVENTORY, &itemdb_read_vending); Find: skill.c int skill_vending( struct map_session_data *sd, int nameid) { Replace: int skill_vending( struct map_session_data *sd, int nameid) { struct item_data *item = itemdb_exists(nameid); char output[1024]; int i; nullpo_ret(sd); if( nameid <= 0) { clif_skill_fail(sd,MC_VENDING,0,0,0); return 0; } if( nameid > MAX_ITEMDB ) return 0; for (i=0;i<MAX_INVENTORY;i++) { if (item_vend[i].itemid == nameid) { sd->vend_loot = item_vend[i].itemid; sd->vend_type = item_vend[i].type; sd->vend_variable = item_vend[i].variable; } } sprintf(output,"您已选择: %s",itemdb_jname(sd->vend_loot)); clif_displaymessage(sd->fd,output); if ( !pc_can_give_items(pc_isGM(sd))) clif_skill_fail(sd,MC_VENDING,0,0,0); else { clif_openvendingreq(sd,2+sd->vend_lvl); } return 1; } Find: vending.c void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count) { Replace: void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count) { int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING]; double z; int currid,vcurrid; struct item item_buffer; int paysd,getvsd,p_z,p_g; struct s_vending vending[MAX_VENDING]; // against duplicate packets struct map_session_data* vsd = map_id2sd(aid); nullpo_retv(sd); if( sd->state.npc_vending && sd->state.npc_vending == uid ) {// a script vend has been requests struct npc_data* nd = map_id2nd(uid); if( nd == NULL ) return; vending_purchasereq_script(sd, nd, uid, data, count); return; } if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id ) return; // invalid shop if( vsd->vender_id != uid ) {// shop has changed clif_buyvending(sd, 0, 0, 6); // store information was incorrect return; } if( !searchstore_queryremote(sd, aid) && ( sd->bl.m != vsd->bl.m || !check_distance_bl(&sd->bl, &vsd->bl, AREA_SIZE) ) ) return; // shop too far away searchstore_clearremote(sd); if( count < 1 || count > MAX_VENDING || count > vsd->vend_num ) return; // invalid amount of purchased items blank = pc_inventoryblank(sd); //number of free cells in the buyer's inventory // duplicate item in vending to check hacker with multiple packets memcpy(&vending, &vsd->vending, sizeof(vsd->vending)); // copy vending list // some checks z = 0.; // zeny counter w = 0; // weight counter for( i = 0; i < count; i++ ) { short amount = *(uint16*)(data + 4*i + 0); short idx = *(uint16*)(data + 4*i + 2); idx -= 2; if( amount <= 0 ) return; // check of item index in the cart if( idx < 0 || idx >= MAX_CART ) return; ARR_FIND( 0, vsd->vend_num, j, vsd->vending[j].index == idx ); if( j == vsd->vend_num ) return; //picked non-existing item else vend_list[i] = j; if (battle_config.extended_vending) { z += ((double)vsd->vending[j].value * (double)amount); switch (vsd->vend_type) { case 1: if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) { clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny return; } if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) { clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow return; } break; case 2: if(z > sd->cashPoints || z < 0. || z > (double)MAX_ZENY ) { clif_displaymessage(sd->fd, msg_txt(800)); return; } if (z + (double)vsd->cashPoints > (double)MAX_ZENY) { clif_displaymessage(sd->fd, msg_txt(812)); return; } break; case 3: if(z > pc_readregistry(sd,trim(vsd->vend_variable),3) || z < 0. || z > (double)MAX_ZENY ) { clif_displaymessage(sd->fd, msg_txt(810)); return; } if (z + (double)pc_readregistry(sd,trim(vsd->vend_variable),3) > (double)MAX_ZENY) { clif_displaymessage(sd->fd, msg_txt(811)); return; } break; case 4: currid = pc_search_inventory (sd, vsd->vend_loot); if( z > (double)sd->status.inventory[currid].amount || currid < 0. || z > (double)MAX_ZENY ) { clif_displaymessage(sd->fd, msg_txt(801)); // you don't have enough zeny return; } vcurrid = pc_search_inventory (vsd, vsd->vend_loot); if( z + (double) vsd->status.inventory[vcurrid].amount > MAX_AMOUNT && !battle_config.vending_over_max_item ) { clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow return; } break; } } else { if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) { clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny return; } if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) { clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow return; } } w += itemdb_weight(vsd->status.cart[idx].nameid) * amount; if( w + sd->weight > sd->max_weight ) { clif_buyvending(sd, idx, amount, 2); // you can not buy, because overweight return; } //Check to see if cart/vend info is in sync. if( vending[j].amount > vsd->status.cart[idx].amount ) vending[j].amount = vsd->status.cart[idx].amount; // if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples). // here, we check cumulative amounts if( vending[j].amount < amount ) { // send more quantity is not a hack (an other player can have buy items just before) clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity return; } vending[j].amount -= amount; switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) { case ADDITEM_EXIST: break; //We'd add this item to the existing one (in buyers inventory) case ADDITEM_NEW: new_++; if (new_ > blank) return; //Buyer has no space in his inventory break; case ADDITEM_OVERAMOUNT: return; //too many items } } //Logs (V)ending Zeny [Lupus] if( log_config.zeny > 0 ) log_zeny(vsd, "V", sd, (int)z); if(battle_config.extended_vending){ switch (vsd->vend_type) { case 1: //Logs (V)ending Zeny [Lupus] if( log_config.zeny > 0 ) log_zeny(vsd, "V", sd, (int)z); pc_payzeny(sd, (int)z); if( battle_config.vending_tax ) z -= z * (battle_config.vending_tax/10000.); pc_getzeny(vsd, (int)z); break; case 2: pc_paycash(sd,(int)z,0); pc_getcash(vsd,(int)z,0); break; case 3: paysd = pc_readregistry(sd,trim(vsd->vend_variable),3); getvsd = pc_readregistry(vsd,trim(vsd->vend_variable),3); p_z = paysd - (int)z; p_g = getvsd + (int)z; pc_setregistry(sd,trim(vsd->vend_variable), p_z, 3); pc_setregistry(vsd,trim(vsd->vend_variable), p_g, 3); break; case 4: if(z > sd->status.inventory[currid].amount) return; pc_delitem(sd, currid, (int)z, 0, 0); memset(&item_buffer,0,sizeof(item_buffer)); item_buffer.nameid = vsd->vend_loot; item_buffer.identify = 1; pc_additem(vsd,&item_buffer,(int)z); break; } } else { if( log_config.zeny > 0 ) log_zeny(vsd, "V", sd, (int)z); pc_payzeny(sd, (int)z); if( battle_config.vending_tax ) z -= z * (battle_config.vending_tax/10000.); pc_getzeny(vsd, (int)z); } for( i = 0; i < count; i++ ) { short amount = *(uint16*)(data + 4*i + 0); short idx = *(uint16*)(data + 4*i + 2); idx -= 2; //Logs sold (V)ending items [Lupus] if(log_config.enable_logs&0x4) { log_pick_pc(vsd, "V", vsd->status.cart[idx].nameid, -amount, &vsd->status.cart[idx]); log_pick_pc( sd, "V", vsd->status.cart[idx].nameid, amount, &vsd->status.cart[idx]); } // vending item pc_additem(sd, &vsd->status.cart[idx], amount); vsd->vending[vend_list[i]].amount -= amount; pc_cart_delitem(vsd, idx, amount, 0); clif_vendingreport(vsd, idx, amount); //print buyer's name if( battle_config.buyer_name ) { char temp[256]; sprintf(temp, msg_txt(265), sd->status.name); clif_disp_onlyself(vsd,temp,strlen(temp)); } } // compact the vending list for( i = 0, cursor = 0; i < vsd->vend_num; i++ ) { if( vsd->vending[i].amount == 0 ) continue; if( cursor != i ) // speedup { vsd->vending[cursor].index = vsd->vending[i].index; vsd->vending[cursor].amount = vsd->vending[i].amount; vsd->vending[cursor].value = vsd->vending[i].value; } cursor++; } vsd->vend_num = cursor; //Always save BOTH: buyer and customer if( save_settings&2 ) { chrif_save(sd,0); chrif_save(vsd,0); } //check for @AUTOTRADE users [durf] if( vsd->state.autotrade ) { //see if there is anything left in the shop ARR_FIND( 0, vsd->vend_num, i, vsd->vending[i].amount > 0 ); if( i == vsd->vend_num ) { //Close Vending (this was automatically done by the client, we have to do it manually for autovenders) [skotlex] vending_closevending(vsd); map_quit(vsd); //They have no reason to stay around anymore, do they? } } } Thiscode is notusedinthelatest version of theRA,correctionanddeletion of Edited May 9, 2012 by zxb329622888 Quote
moneymuch Posted May 13, 2012 Posted May 13, 2012 (edited) hey Lilith i have a problem while i buy anything in vending with any way, map server displayer error,then server restart i use 1.8.1,but it is not upgrade from 1.6 before i use 1.6,it is ok.but i change rathena version to 16096, i add 1.8.1 to svn again i think maybe i make mistake when i add to it ,so i try to find mistake but i don't find any mistake [Error] Server received crash signal ! Attempting to save all online characters ! oh ,it don't let me Send pictures T Ti i have sloved the problem . it is the megs 707 ,amount and item_name , i invert their order Edited May 25, 2012 by moneymuch Quote
wazhanudin Posted May 23, 2012 Posted May 23, 2012 (edited) Thanks for this release.. It's working. Test on rAthena 16139 Test on rAthena 16150 Test on rAthena 16316 Edited June 19, 2012 by wazhanudin Quote
Messi Posted June 19, 2012 Posted June 19, 2012 can i have a guide on how to do with the patch?=( newbie here why the 3ceam patrch not working for eathena version svn r676m? it error when i merge Quote
Petey Pablo Posted June 30, 2012 Posted June 30, 2012 im using this ExtendedVendingSystem_1.8.1.patch and latest revision of rA. Please update your diff/patch file. Thanks after patching the diff using tortoise. see the image below 1 Quote
botka4aet Posted July 2, 2012 Posted July 2, 2012 (edited) 16365 - all good Edited July 2, 2012 by botka4aet Quote
leontino Posted July 5, 2012 Posted July 5, 2012 error C2198: 'clif_skill_fail' : too few arguments for call Skill.c :\ Quote
oohmen Posted July 8, 2012 Posted July 8, 2012 i have an error when compiling thats not all this gave me error i use rathena latest rev i use te latest one for rAthena Only diff same problem with him Quote
Jezu Posted July 11, 2012 Posted July 11, 2012 @Lilith The 1.8.1 patch for the extended vending system is having an error when compiling like the post above of this. Please re-update this Lilith as this is really important on my server too =) by the way, great system and script ! Quote
onizame Posted July 21, 2012 Posted July 21, 2012 hi Lilith.. im trying to patch this on CentOS 5.8 VPS.. and it fails.. using this command [onizame2823@localhost ~]$ patch -Np1 -d trunk/ < ExtendedVendingSystem_1.8.1.patch (Stripping trailing CRs from patch.) can't find file to patch at input line 5 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |Index: conf/battle/feature.conf |=================================================================== |--- conf/battle/feature.conf (revision 16070) |+++ conf/battle/feature.conf (working copy) -------------------------- File to patch: then i try to put it manually become like this.. rAthena SVN 16462 In file included from pc.h:12, from clif.c:17: itemdb.h:233:24: warning: no newline at end of file clif.c: In function âclif_parse_OpenVendingâ: clif.c:11850: error: âstruct Battle_Configâ has no member named âmin_npc_vending_distanceâ make[1]: *** [obj_sql/clif.o] Error 1 make[1]: Leaving directory `/home/onizame2823/trunk/src/map' make: *** [map_sql] Error 2 hope u can help me.. bcuz this script so great and i want to use it on my server Quote
KingTristan Posted July 26, 2012 Posted July 26, 2012 rAthena Version SVN r16380 Working! thank you ! @above post with compile error try to remove the + in patch Quote
onizame Posted July 26, 2012 Posted July 26, 2012 maybe my SVN not match.. i'm wondering how to use SVN r16380? bcuz when install on linux only can install the latest one... Quote
KingTristan Posted July 26, 2012 Posted July 26, 2012 Ver. 1.8.1 i have problem tho. i used 2 chars Lets assume : Char A Char B Char A vend an item ygg for 26000 Bronze Coins(while Char A inventory has 5000 Bronze Coins) Char B bought ygg from Char A Char B receives ygg and reduce his Bronze Coins by 26000 but the problem is Char A remains with 5000 Bronze Coins. is there a way that if the vendor exceeded the x number of items in his inventory and someone bought it will say that the vendor has exceeded the max inventory? thanks! Quote
PewN Posted July 28, 2012 Posted July 28, 2012 can u make a raw file for it? cuz i can't dl tortoise svn T_T! Quote
Jezu Posted July 29, 2012 Posted July 29, 2012 This 1.8.1 is not working on latest revision of rAthena. Lilith should update this to a working copy. Quote
SlashGeeGee Posted July 31, 2012 Posted July 31, 2012 The 1.8.1 patch work with me but there are 3 diffs that I included manually and others patched 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.