Jump to content
  • 0

Custom cash shop


x13th

Question


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

EDIT: at last, i fixed it~

-_- please close this thread. thank you for your help guys ♥

Hello. I diff the Custom Cash Shop by @Ind

topic from eA: Link

The problem is, it doesn't delete the item in players inventory. Please help me :3 Thank you!

Here's the diff.

hehe
}

Edited by x13th
Link to comment
Share on other sites

14 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

please show your final diff so we know what we're working on

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

Here:

if( stristr(nd->name,"ITMCur") ) {//Item Currency
int count=0,ind=0,c = 0, cid = pc_readreg(sd,add_str("@RRITMCur"));
for(c = 0; c < MAX_INVENTORY; c++)
if(sd->status.inventory[c].nameid == cid)
count += sd->status.inventory[c].amount;
if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )
return 6;
ind = pc_search_inventory(sd,cid);
if( ind < 0 )//because checking twice is safer...
return 6;
sd->cashPoints = count;
if( sd->cashPoints < price )
return 6;
if( pc_delitem(sd,ind,price,0,0, LOG_TYPE_NPC) )//somehow it failed to delete...
return 6;
sd->cashPoints -= price;
if( !pet_create_egg(sd, nameid) )
{
	struct item item_tmp;
	memset(&item_tmp, 0, sizeof(struct item));
	item_tmp.nameid = nameid;
	item_tmp.identify = 1;

	pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
}
if(log_config.enable_logs&0x20)
log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
return 0;
}
if( stristr(nd->name,"CharCur") ) {//Char Reg Currency (from set REGNAME,1;)
const char* charReg = pc_readregstr(sd,add_str("@CharCurrrency$"));
int count = pc_readglobalreg(sd,charReg);
if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )//safecheck
return 6;
sd->cashPoints = count;
if( sd->cashPoints < price )
return 6;
sd->cashPoints -= price;
pc_setglobalreg(sd,charReg,sd->cashPoints);//update...
if( !pet_create_egg(sd, nameid) )//give item...
{
	struct item item_tmp;
	memset(&item_tmp, 0, sizeof(struct item));
	item_tmp.nameid = nameid;
	item_tmp.identify = 1;

	pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
}
if(log_config.enable_logs&0x20)
log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
return 0;
}
if( stristr(nd->name,"ACCCur") ) {//Account Reg Currency
const char* charReg = pc_readregstr(sd,add_str("@AccCurrrency$"));
int count = pc_readaccountreg(sd,charReg);
if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )//safecheck
return 6;
sd->cashPoints = count;
if( sd->cashPoints < price )
return 6;
sd->cashPoints -= price;
pc_setaccountreg(sd,charReg,sd->cashPoints);//update...
if( !pet_create_egg(sd, nameid) )//give item...
{
	struct item item_tmp;
	memset(&item_tmp, 0, sizeof(struct item));
	item_tmp.nameid = nameid;
	item_tmp.identify = 1;

	pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
}
if(log_config.enable_logs&0x20)
log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
return 0;
}

bump!

Help please :< bump~

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  243
  • Reputation:   206
  • Joined:  11/28/11
  • Last Seen:  

I ported Orcao's setcashpoints version here. I think it is similar to what you wanted ...?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

Gonna check it out. btw, Is it supported with item? That's what i want :3

EDIT: That's not what i'm looking for. I want cash shop that uses currency like POD >.< the problem with the diff is, it doesn't delete the item needed when purchasing.

Edited by x13th
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

we don't have it all but :

that your issue right ? :

if( pc_delitem(sd,ind,price,0,0, LOG_TYPE_NPC) )//somehow it failed to delete...

Just quick verification does price > 0 ?? couldn't see a check about it

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

Yea, that's my issue.

What do you mean by price > 0 ? items at cash shop? if thats what you mean. Yes, price > 0

If you want to try, diff it.

CustomShop by Ind

or read the topic from eA: Link

bump ~ sorry for bumping too much /pat

Edited by x13th
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  85
  • Reputation:   17
  • Joined:  12/25/11
  • Last Seen:  

can share the fix?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

Actually i did not use this, i made my own code :3

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  85
  • Reputation:   17
  • Joined:  12/25/11
  • Last Seen:  

Actually i did not use this, i made my own code :3

Ok...thanks sir for your answer

___________________________________________________________________________________________________

Hello all ;D

I need help with the code ( Custom Cash Shop ) by IND.

Original patch:

Custom Cash Shop

I try to adapt the code to rAthena and to the compile don't show any error, but at buy in the shop it doesn't delete the item in players inventory ( Item Currency ).

Video explanation:

[media=]

[/media]

Iam using: rAthena 17053

Exe: 20120525a

Packets

Npc Demo

Index: src/map/clif.c
===================================================================
--- src/map/clif.c (revision 17053)
+++ src/map/clif.c (working copy)
@@ -14349,9 +14364,9 @@
 WFIFOHEAD(fd,offset+nd->u.shop.count*11);
 WFIFOW(fd,0) = 0x287;
 WFIFOW(fd,2) = offset+nd->u.shop.count*11;
- WFIFOL(fd,4) = sd->cashPoints; // Cash Points
+ WFIFOL(fd,4) = pc_readaccountreg(sd,"#CASHPOINTS"); // Cash Points
#if PACKETVER >= 20070711
- WFIFOL(fd,8) = sd->kafraPoints; // Kafra Points
+ WFIFOL(fd,8) = pc_readaccountreg(sd,"#KAFRAPOINTS"); // Kafra Points
#endif

 for( i = 0; i < nd->u.shop.count; i++ )

Index: src/map/npc.c
===================================================================
--- src/map/npc.c (revision 17053)
+++ src/map/npc.c (working copy)
@@ -1427,15 +1427,100 @@
 if( (double)nd->u.shop.shop_item[i].value * amount > INT_MAX )
 {
  ShowWarning("npc_cashshop_buy: Item '%s' (%d) price overflow attempt!\n", item->name, nameid);
-  ShowDebug("(NPC:'%s' (%s,%d,%d), player:'%s' (%d/%d), value:%d, amount:%d)\n",
-	 nd->exname, map[nd->bl.m].name, nd->bl.x, nd->bl.y, sd->status.name, sd->status.account_id, sd->status.char_id, nd->u.shop.shop_item[i].value, amount);
+  ShowDebug("(NPC:'%s' (%s,%d,%d), player:'%s' (%d/%d), value:%d, amount:%d)\n", nd->exname, map[nd->bl.m].name, nd->bl.x, nd->bl.y, sd->status.name, sd->status.account_id, sd->status.char_id, nd->u.shop.shop_item[i].value, amount);
  return 5;
 }

 price = nd->u.shop.shop_item[i].value * amount;
 if( points > price )
  points = price;
+
+ /*--------------------------- Ind Mod ---------------------------*/
+
+ if( stristr(nd->name,"ITMCur") ) {//Item Currency
+  int count=0,ind=0,c = 0, cid = pc_readreg(sd,add_str("@RRITMCur"));
+  for(c = 0; c < MAX_INVENTORY; c++)
+   if(sd->status.inventory[c].nameid == cid )
+   count += sd->status.inventory[c].amount;
+  if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )
+   return 6;
+  ind = pc_search_inventory(sd, cid);
+  if( ind < 0 )//because checking twice is safer...
+   return 6;
+  sd->cashPoints = count;
+  if( sd->cashPoints < price )
+   return 6;
+  if( pc_delitem(sd, ind, price, 0, 0, LOG_TYPE_NPC) )//somehow it failed to delete...
+   return 6;
+
+  sd->cashPoints -= price;
+  if( !pet_create_egg(sd, nameid) )
+  {
+   struct item item_tmp;
+   memset(&item_tmp, 0, sizeof(struct item));
+   item_tmp.nameid = nameid;
+   item_tmp.identify = 1;
+  

+   pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+  
+  }
+  if(log_config.enable_logs&0x20)
+   log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
+  pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
+  return 0;
+ }
+ if( stristr(nd->name,"CharCur") ) {//Char Reg Currency (from set REGNAME,1;)
+  const char* charReg = pc_readregstr(sd,add_str("@CharCurrrency$"));
+  int count = pc_readglobalreg(sd,charReg);
+  if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )//safecheck
+   return 6;
+  sd->cashPoints = count;
+  if( sd->cashPoints < price )
+   return 6;
+  sd->cashPoints -= price;
+  pc_setglobalreg(sd,charReg,sd->cashPoints);//update...
+  if( !pet_create_egg(sd, nameid) )//give item...
+  {
+   struct item item_tmp;
+   memset(&item_tmp, 0, sizeof(struct item));
+   item_tmp.nameid = nameid;
+   item_tmp.identify = 1;
+
+   pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+  }
+  if(log_config.enable_logs&0x20)
+   log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
+  pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
+  return 0;
+ }
+ if( stristr(nd->name,"ACCCur") ) {//Account Reg Currency
+  const char* charReg = pc_readregstr(sd,add_str("@AccCurrrency$"));
+  int count = pc_readaccountreg(sd,charReg);
+  if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )//safecheck
+   return 6;
+  sd->cashPoints = count;
+  if( sd->cashPoints < price )
+   return 6;
+  sd->cashPoints -= price;
+  pc_setaccountreg(sd,charReg,sd->cashPoints);//update...
+  if( !pet_create_egg(sd, nameid) )//give item...
+  {
+   struct item item_tmp;
+   memset(&item_tmp, 0, sizeof(struct item));
+   item_tmp.nameid = nameid;
+   item_tmp.identify = 1;
+
+   pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+  }
+  if(log_config.enable_logs&0x20)
+   log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
+  pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
+  return 0;
+ }
+
+
+  /*--------------------------- Ind Mod ---------------------------*/
 if( (sd->kafraPoints < points) || (sd->cashPoints < price - points) )
  return 6

Somebody help please..... /sob

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

Are you using different currency?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  85
  • Reputation:   17
  • Joined:  12/25/11
  • Last Seen:  

I am using several currency, like bronze coins, plata, gold, Battle Badge.

This mod is working fine in another revisions more old, but i will upgrade to rathena and i need this modification.

Edited by Angel
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

I guess some of the code in your diff need to move in other line. like the deleting of item. I think it should be in

// Payment Process ----------------------------------------------------
if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
	return 6;
pc_paycash(sd,vt,points);

Edited by x13th
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  85
  • Reputation:   17
  • Joined:  12/25/11
  • Last Seen:  

I guess some of the code in your diff need to move in other line. like the deleting of item. I think it should be in

// Payment Process ----------------------------------------------------
if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
	return 6;
pc_paycash(sd,vt,points);

yup, i solve the problem yesterday checking the changeset, i forgot post the solution

Fixed almost i think so ...

npc_cashshop_buylis was aggregated in (Changeset 15137) its some type of revalidation i think.

I add the mod by @Ind in this part and now delete the item in players inventory ( Item Currency ).

i hope that at someone help

Thank [member=In

d] for your awesome mod ;D

Index: src/map/npc.c
===================================================================
--- src/map/npc.c (revision 17053)
+++ src/map/npc.c (working copy)
@@ -1322,11 +1322,97 @@
 if( points > vt ) points = vt;

 // Payment Process ----------------------------------------------------
+
+ if( stristr(nd->name,"ITMCur") ) {//Item Currency
+ int count=0,ind=0,c = 0, cid = pc_readreg(sd,add_str("@RRITMCur"));
+ for(c = 0; c < MAX_INVENTORY; c++)
+ if(sd->status.inventory[c].nameid == cid )
+ count += sd->status.inventory[c].amount;
+ if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )
+ return 6;
+ ind = pc_search_inventory(sd, cid);
+ if( ind < 0 )//because checking twice is safer...
+ return 6;
+ sd->cashPoints = count;
+ if( sd->cashPoints < vt )
+ return 6;
+ if( pc_delitem(sd, ind, vt, 0, 0, LOG_TYPE_NPC) )//somehow it failed to delete...
+ return 6;
+
+ sd->cashPoints -= vt;
+ if( !pet_create_egg(sd, nameid) )
+ {
+ struct item item_tmp;
+ memset(&item_tmp, 0, sizeof(struct item));
+ item_tmp.nameid = nameid;
+ item_tmp.identify = 1;
+
+
+ pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+
+ }
+ if(log_config.enable_logs&0x20)
+ log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
+ return 0;
+ }
+
+ if( stristr(nd->name,"CharCur") ) {//Char Reg Currency (from set REGNAME,1;)
+ const char* charReg = pc_readregstr(sd,add_str("@CharCurrrency$"));
+ int count = pc_readglobalreg(sd,charReg);
+ if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )//safecheck
+ return 6;
+ sd->cashPoints = count;
+ if( sd->cashPoints < vt )
+ return 6;
+ sd->cashPoints -= vt;
+ pc_setglobalreg(sd,charReg,sd->cashPoints);//update...
+ if( !pet_create_egg(sd, nameid) )//give item...
+ {
+ struct item item_tmp;
+ memset(&item_tmp, 0, sizeof(struct item));
+ item_tmp.nameid = nameid;
+ item_tmp.identify = 1;
+
+ pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+ }
+ if(log_config.enable_logs&0x20)
+ log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
+ return 0;
+ }
+ if( stristr(nd->name,"ACCCur") ) {//Account Reg Currency
+ const char* charReg = pc_readregstr(sd,add_str("@AccCurrrency$"));
+ int count = pc_readaccountreg(sd,charReg);
+ if( count != pc_readaccountreg( sd, "#CASHPOINTS" ) )//safecheck
+ return 6;
+ sd->cashPoints = count;
+ if( sd->cashPoints < vt )
+ return 6;
+ sd->cashPoints -= vt;
+ pc_setaccountreg(sd,charReg,sd->cashPoints);//update...
+ if( !pet_create_egg(sd, nameid) )//give item...
+ {
+ struct item item_tmp;
+ memset(&item_tmp, 0, sizeof(struct item));
+ item_tmp.nameid = nameid;
+ item_tmp.identify = 1;
+
+ pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+ }
+ if(log_config.enable_logs&0x20)
+ log_pick_pc(sd, LOG_TYPE_SCRIPT, amount, NULL);
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);//update shop~
+ return 0;
+ }
+
+
 if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
	 return 6;
 pc_paycash(sd,vt,points);
-
+
 // Delivery Process ----------------------------------------------------

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  206
  • Reputation:   13
  • Joined:  11/20/11
  • Last Seen:  

Good to hear mate! :)

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
Answer this question...

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