Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/conf/battle/items.conf b/conf/battle/items.conf
index be5e6448d..ce1e6c1de 100644
--- a/conf/battle/items.conf
+++ b/conf/battle/items.conf
@@ -141,3 +141,11 @@ min_shop_buy: 1
// Minimum sell price of items at a normal shop
// Officially items can be sold for 0 Zeny
min_shop_sell: 0
+
+// Instead of Cashpoints in Cashshop UI (interface)
+// Use ITEMID with ID below. The item must exists in the game
+// The item must have tradable flags, etc like a normal item
+// Instead of cashpoints will be consumed the item from players inventory
+// Set it to 0 if you wish completely disable the system.
+// Max ID = 65k
+cashshop_currency_itemid: 505
diff --git a/src/custom/battle_config_init.inc b/src/custom/battle_config_init.inc
index e47aca9be..8e6557eb8 100644
--- a/src/custom/battle_config_init.inc
+++ b/src/custom/battle_config_init.inc
@@ -11,3 +11,5 @@
* { "name", &battle_config.<variable name>, <default value>, <minimum value>, <maximum value> },
**/
+// Cashshop UI item currency shop:
+{ "cashshop_currency_itemid", &battle_config.cashshop_currency_itemid, 0, 0, MAX_ITEMID, },
diff --git a/src/custom/battle_config_struct.inc b/src/custom/battle_config_struct.inc
index 017d99d07..3b708765a 100644
--- a/src/custom/battle_config_struct.inc
+++ b/src/custom/battle_config_struct.inc
@@ -12,3 +12,6 @@
* <datatype> name;
**/
+
+// Cashshop currency ItemID shop
+int cashshop_currency_itemid;
diff --git a/src/map/cashshop.cpp b/src/map/cashshop.cpp
index df26abde7..65058a7cf 100644
--- a/src/map/cashshop.cpp
+++ b/src/map/cashshop.cpp
@@ -564,10 +564,32 @@ bool cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, u
return false;
}
- if(pc_paycash( sd, totalcash, kafrapoints, LOG_TYPE_CASH ) <= 0){
- clif_cashshop_result( sd, 0, CASHSHOP_RESULT_ERROR_SHORTTAGE_CASH );
- return false;
+ // Custom code for using instead of cashpoints itemID as a currency in cashshop UI shop.
+ if(battle_config.cashshop_currency_itemid)
+ {
+ struct item_data *id_cash_currency = itemdb_search(battle_config.cashshop_currency_itemid);
+ if (!id_cash_currency)
+ {
+ clif_cashshop_result(sd, 0, CASHSHOP_RESULT_ERROR_SHORTTAGE_CASH);
+ ShowError("cashshop_currency_itemid: %d itemID not exists in the game, try another one.\n", battle_config.cashshop_currency_itemid);
+ return false;
+ }
+ int item_idx = pc_search_inventory(sd, battle_config.cashshop_currency_itemid);
+ if (item_idx < 0 || pc_delitem(sd, item_idx, totalcash, 0, 0, LOG_TYPE_CONSUME))
+ {
+ clif_cashshop_result(sd, 0, CASHSHOP_RESULT_ERROR_SHORTTAGE_CASH);
+ return false;
+ }
+ }
+ else // Original Function
+ {
+ if (pc_paycash(sd, totalcash, kafrapoints, LOG_TYPE_CASH) <= 0)
+ {
+ clif_cashshop_result(sd, 0, CASHSHOP_RESULT_ERROR_SHORTTAGE_CASH);
+ return false;
+ }
}
+ // Custom code for using instead of cashpoints itemID as a currency in cashshop UI shop.
for( i = 0; i < n; ++i ){
unsigned short nameid = *( item_list + i * 5 );
@anacondaq

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2019

How apply?

git apply --reject cashshop_ui_itemid_as_currency.diff

Or with SourceTree -> Apply Patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.