x13th Posted November 21, 2012 Posted November 21, 2012 (edited) 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 November 26, 2012 by x13th Quote
Lighta Posted November 22, 2012 Posted November 22, 2012 please show your final diff so we know what we're working on Quote
x13th Posted November 23, 2012 Author Posted November 23, 2012 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~ Quote
Xantara Posted November 24, 2012 Posted November 24, 2012 I ported Orcao's setcashpoints version here. I think it is similar to what you wanted ...? Quote
x13th Posted November 24, 2012 Author Posted November 24, 2012 (edited) 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 November 24, 2012 by x13th Quote
Lighta Posted November 24, 2012 Posted November 24, 2012 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 Quote
x13th Posted November 25, 2012 Author Posted November 25, 2012 (edited) 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 Edited November 24, 2012 by x13th Quote
x13th Posted December 29, 2012 Author Posted December 29, 2012 Actually i did not use this, i made my own code :3 Quote
Angel Posted December 29, 2012 Posted December 29, 2012 (edited) 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..... Edited January 1, 2013 by Emistry Please use [CODEBOX] or Attachments for long contents. Quote
x13th Posted December 30, 2012 Author Posted December 30, 2012 Are you using different currency? Quote
Angel Posted December 30, 2012 Posted December 30, 2012 (edited) 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 December 30, 2012 by Angel Quote
x13th Posted December 31, 2012 Author Posted December 31, 2012 (edited) 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 December 31, 2012 by x13th Quote
Angel Posted December 31, 2012 Posted December 31, 2012 (edited) 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 January 1, 2013 by Emistry Please use [CODEBOX] or Attachments for long contents. Quote
Question
x13th
EDIT: at last, i fixed it~
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.
Edited by x13th14 answers to this question
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.