Jump to content

Extended Vending System [1.8]


Lilith

Recommended Posts


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  407
  • Reputation:   159
  • Joined:  11/18/11
  • Last Seen:  

item_vending.txt

post-386-0-02234800-1336143976_thumb.png

feature.conf

post-386-0-18312400-1336144006_thumb.png

In-game

post-386-0-64760100-1336144019_thumb.png

Edited by Lilith
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:  

I am so sorry

i found problem :)

I forgot remove old config in items.conf

Edited by Napster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  231
  • Reputation:   24
  • Joined:  12/18/11
  • Last Seen:  

i have an error when compiling errorwd.jpg

thats not all this gave me error i use rathena latest rev

i use te latest one for rAthena Only diff

Edited by lakasmonk123
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  111
  • Topics Per Day:  0.02
  • Content Count:  573
  • Reputation:   20
  • Joined:  11/19/11
  • Last Seen:  

Hey Lilith /no1

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: txt.gif ExtendedVendingSystem_1.8.1.patch

my svn : latest rA rev

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  2
  • Reputation:   0
  • Joined:  01/07/12
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  20
  • Reputation:   0
  • Joined:  03/11/12
  • Last Seen:  

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

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  05/15/12
  • Last Seen:  

Thanks for this release..

It's working.

Test on rAthena 16139

Test on rAthena 16150

Test on rAthena 16316

Edited by wazhanudin
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  331
  • Reputation:   63
  • Joined:  11/29/11
  • Last Seen:  

Working, Tested on 16141

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   2
  • Joined:  05/15/12
  • Last Seen:  

thanks it work for me /no1

tested on 16155 /lv

Link to comment
Share on other sites

  • 4 weeks later...

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

@Request

Extended Buying Store System /oops

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   0
  • Joined:  05/29/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  152
  • Topics Per Day:  0.03
  • Content Count:  569
  • Reputation:   11
  • Joined:  11/24/11
  • Last Seen:  

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

1043uad.jpg

143f05c.jpg

17s4r8.jpg

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  211
  • Reputation:   17
  • Joined:  12/23/11
  • Last Seen:  

16365 - all good

oz72nq-0.png

Edited by botka4aet
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  01/19/12
  • Last Seen:  

error C2198: 'clif_skill_fail' : too few arguments for call

Skill.c :\

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  211
  • Reputation:   17
  • Joined:  12/23/11
  • Last Seen:  

rev?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  15
  • Reputation:   0
  • Joined:  03/08/12
  • Last Seen:  

i have an error when compiling errorwd.jpg

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  566
  • Reputation:   34
  • Joined:  11/17/11
  • Last Seen:  

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

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   2
  • Joined:  07/05/12
  • Last Seen:  

hi Lilith.. im trying to patch this on CentOS 5.8 VPS.. and it fails.. using this command /oops

[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 /panic 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 /no1 and i want to use it on my server /pat

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  66
  • Reputation:   3
  • Joined:  04/02/12
  • Last Seen:  

rAthena Version SVN r16380 Working!

thank you !

@above post with compile error

try to remove the + in patch

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  139
  • Reputation:   2
  • Joined:  07/05/12
  • Last Seen:  

maybe my SVN not match.. i'm wondering how to use SVN r16380? bcuz when install on linux only can install the latest one... /abs

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  66
  • Reputation:   3
  • Joined:  04/02/12
  • Last Seen:  

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!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  209
  • Topics Per Day:  0.05
  • Content Count:  892
  • Reputation:   27
  • Joined:  12/09/11
  • Last Seen:  

can u make a raw file for it? :D cuz i can't dl tortoise svn T_T!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  566
  • Reputation:   34
  • Joined:  11/17/11
  • Last Seen:  

This 1.8.1 is not working on latest revision of rAthena. Lilith should update this to a working copy.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  209
  • Topics Per Day:  0.05
  • Content Count:  892
  • Reputation:   27
  • Joined:  12/09/11
  • Last Seen:  

@lilith please update this :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  111
  • Topics Per Day:  0.02
  • Content Count:  573
  • Reputation:   20
  • Joined:  11/19/11
  • Last Seen:  

The 1.8.1 patch work with me but there are 3 diffs that I included manually and others patched :)

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...