Introducing Cash Shop Support

default_ani_meow.gif
+1 i've been waiting for this.

 
Hi hercules devs, here is the code for working kafra & free cash points.

void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) { WFIFOHEAD(fd, 10); WFIFOW(fd, 0) = 0x845; WFIFOL(fd, 2) = sd->cashPoints; //[Ryuuzaki] - switched positions to reflect proper values WFIFOL(fd, 6) = sd->kafraPoints; WFIFOSET(fd, 10); }


Code:
void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {	unsigned short limit = RFIFOW(fd, 4), i, j;	int kafra_pay = RFIFOL(fd, 6); // [Ryuuzaki] - These are free cash points (strangely #CASH = main cash curreny for us, confusing)		/* no idea what data is on 6-10 */	for(i = 0; i < limit; i++) {		int qty = RFIFOL(fd, 14 + ( i * 10 ));		int id = RFIFOL(fd, 10 + ( i * 10 ));		short tab = RFIFOW(fd, 18 + ( i * 10 ));		enum CASH_SHOP_BUY_RESULT result = CSBR_UNKNOWN;						if( tab < 0 || tab > CASHSHOP_TAB_MAX )			continue;				for( j = 0; j < clif->cs.item_count[tab]; j++ ) {			if( clif->cs.data[tab][j]->id == id )				break;		}		if( j < clif->cs.item_count[tab] ) {			struct item_data *data;			if( (sd->cashPoints+kafra_pay) < (clif->cs.data[tab][j]->price * qty) ) { // [Ryuuzaki] - Add freecash to your cash points (might need a check? client checks if you have enough free cash, better safe than sorry right?)				result = CSBR_SHORTTAGE_CASH;			} else if ( !( data = itemdb_exists(clif->cs.data[tab][j]->id) ) ) {				result = CSBR_UNKONWN_ITEM;			} else {				struct item item_tmp;				int k, get_count;								get_count = qty;								if (!itemdb_isstackable2(data))					get_count = 1;								pc_paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki] - Pay cash & kafrapoints				for (k = 0; k < qty; k += get_count) {					if (!pet_create_egg(sd, data->nameid)) {						memset(&item_tmp, 0, sizeof(item_tmp));						item_tmp.nameid = data->nameid;						item_tmp.identify = 1;												switch (pc_additem(sd, &item_tmp, get_count, LOG_TYPE_NPC)) {							case 0:								result = CSBR_SUCCESS;								break;							case 1:								result = CSBR_EACHITEM_OVERCOUNT;								break;							case 2:								result = CSBR_INVENTORY_WEIGHT;								break;							case 4:								result = CSBR_INVENTORY_ITEMCNT;								break;							case 5:								result = CSBR_EACHITEM_OVERCOUNT;								break;							case 7:								result = CSBR_RUNE_OVERCOUNT;								break;						}												if( result != CSBR_SUCCESS )							pc_getcash(sd, clif->cs.data[tab][j]->price * get_count, kafra_pay); //[Ryuuzaki] - Return also free cash if it failed.					}				}			}		} else {			result = CSBR_UNKONWN_ITEM;		}				WFIFOHEAD(fd, 16);		WFIFOW(fd, 0) = 0x849;		WFIFOL(fd, 2) = id;		WFIFOW(fd, 6) = result;/* result */		WFIFOL(fd, 8) = sd->cashPoints;/* current cash point */		WFIFOL(fd, 12) = sd->kafraPoints;/* current kafra points */		WFIFOSET(fd, 16);	}}
Hope this will help you out, thanks for the release again.

I added //[Ryuuzaki] with a comment next to it so you can see what exactly i changed.

 
Last edited by a moderator:
anyone who is testing this.

i remember in my server was some bugs, like purchasing items to make the cashpoints go over int limit caused the items for free.

or using a negative value in free cash.

just some wisdom <3

 
My client refuses to allow negative cash, will also state that you don't have enough kafra points.

Thanks for the warning though ^^

Edit: But yeah, you can also spoof packets to skip the client checks..

 
Last edited by a moderator:
Hi hercules devs, here is the code for working kafra & free cash points.

Hope this will help you out, thanks for the release again.

I added //[Ryuuzaki] with a comment next to it so you can see what exactly i changed.
I thank you for pointing out what the unknown field was (6-10), but now that I know it I don't think we'll be using it (i wouldn't trust the packet/client to tell us the kafra value -- would rather measure it ourselves on the server end)
 
Last edited by a moderator:
The packet only tells the server what number you've put into the box, we still need the check if the amount is valid, that's what i pointed out^^

 
The packet only tells the server what number you've put into the box, we still need the check if the amount is valid, that's what i pointed out^^
ooh my bad I didn't think that was what the value was XD
 
I would love to have some sort of log of:

Who bought what, how many, when, previous amount of cash points, new amount.

Guess it would be good to keep track of donators, or maybe see which item is most popular. Maybe i'll code one later.

 
Last edited by a moderator:
I would love to have some sort of log of:

Who bought what, how many, when, previous amount of cash points, new amount.

Guess it would be good to keep track of donators, or maybe see which item is most popular. Maybe i'll code one later.
yup its in our todo (a new log type for cash shops), if you could provide us with one it'd be even better
 
When I buy some items my cash value is changed to 0, I have to close and open the cash button again.

 
When I buy some items my cash value is changed to 0, I have to close and open the cash button again.
please fill us a bug report
default_biggrin.png
thank you for testing the feature
 
Forgot to fix ind ?
I did indeed forget about your reply, sorry for that. as for it not being yet fixed we share blame on that XD <3 I, because I forgot and you, for you didn't make the bug report which would have made other developers aware of the issue.
 
Wow wow wow this is great! It's a big jump in RO history!
default_biggrin.png
Good job all of you!!

 
hmm, got Hack Shield error on all 2012 ragexe's, anyone have correct hex strings for disable HShield?

 
Keep in mind this isn't a Support Topic. Support that you're looking for should be created in a different topic please.

 
Back
Top