Thread: [Kronos] Blood Money <-> Platinum Tokens Exchange

Results 1 to 2 of 2
  1. #1 [Kronos] Blood Money <-> Platinum Tokens Exchange 
    Registered Member
    Join Date
    Nov 2020
    Posts
    6
    Thanks given
    0
    Thanks received
    2
    Rep Power
    0
    Wrote this really quick for someone as a favor, figured I'd put it here for anyone who wants it

    The ratio was 1:10000 for Platinum:Blood Money. You can configure this by changing the "exchangeRate" variable in both sections.


    Be sure to do your own testing as this was written very quickly and every edge-case/validation may not be present. Worked as intended when I tested it, though!


    This is done through dialogue, by the way. Make sure it's within the "new OptionsDialogue(" of an NPC's talk() method.

    Code:
    new Option("I'd like to exchange my Blood Money for Platinum Tokens", () -> {
        if (!player.getInventory().hasId(BLOOD_MONEY)) { // If they don't have any blood money, return
            player.dialogue(new NPCDialogue(npc, "You don't have any Blood Money to exchange."));
            return;
        }
        int exchangeRate = 10000;
        int bloodMoney = player.getInventory().findItem(BLOOD_MONEY).getAmount();
        long platTokens = 0;
    
        if (player.getInventory().hasId(PLATINUM_TOKEN)) // make platTokens equal to how many they have
            platTokens = player.getInventory().findItem(PLATINUM_TOKEN).getAmount();
    
        int totalBloodExchanges = Math.floorDiv(bloodMoney, exchangeRate);
    
        if (totalBloodExchanges > 0) { // Make sure they have enough blood money to complete the exchange
    
            if (platTokens + totalBloodExchanges <= Integer.MAX_VALUE) { // Make sure they can accept the amount of tokens
                int freeSlots = player.getInventory().getFreeSlots();
                if ((player.getInventory().hasId(PLATINUM_TOKEN) && player.getInventory().hasId(BLOOD_MONEY)) || freeSlots > 0) { // If they already have plat tokens and blood money, don't need to check freeSlots
                    player.getInventory().remove(BLOOD_MONEY, totalBloodExchanges * exchangeRate);
                    player.getInventory().add(PLATINUM_TOKEN, totalBloodExchanges);
                } else {
                    player.dialogue(new NPCDialogue(npc, "You don't have enough inventory space."));
                    return;
                }
            }
            else {
                player.dialogue(new NPCDialogue(npc, "You're carrying too many Platinum Tokens to make this transaction."));
                return;
            }
        }
        else {
            player.dialogue(new NPCDialogue(npc, "You need at least " + exchangeRate + " Blood Money to exchange for Platinum Tokens."));
            return;
        }
        player.dialogue(new ItemDialogue().two(BLOOD_MONEY, PLATINUM_TOKEN, "The bank exchanges your blood money for platinum tokens."));
    }),
    new Option("I'd like to exchange my Platinum Tokens for Blood Money", () -> {
        if (!player.getInventory().hasId(PLATINUM_TOKEN)) { // If they don't have any blood money, return
            player.dialogue(new NPCDialogue(npc, "You don't have any Platinum Tokens to exchange."));
            return;
        }
        int exchangeRate = 10000;
        int platTokens = player.getInventory().findItem(PLATINUM_TOKEN).getAmount();
        long bloodMoney = 0;
    
        if (player.getInventory().hasId(BLOOD_MONEY)) // make bloodMoney equal to how many they have
            bloodMoney = player.getInventory().findItem(BLOOD_MONEY).getAmount();
    
        if (bloodMoney + ((long) platTokens * exchangeRate) <= Integer.MAX_VALUE) { // Make sure they can accept the amount of tokens
            int freeSlots = player.getInventory().getFreeSlots();
            if ((player.getInventory().hasId(PLATINUM_TOKEN) && player.getInventory().hasId(BLOOD_MONEY)) || freeSlots > 0) { // If they already have plat tokens and blood money, don't need to check freeSlots
                player.getInventory().remove(PLATINUM_TOKEN, platTokens);
                player.getInventory().add(BLOOD_MONEY, platTokens * exchangeRate);
            } else {
                player.dialogue(new NPCDialogue(npc, "You don't have enough inventory space."));
                return;
            }
        }
        else {
            player.dialogue(new NPCDialogue(npc, "You won't be able to hold the amount of Blood Money you'd receive after completing this transaction"));
            return;
            }
        player.dialogue(new ItemDialogue().two(BLOOD_MONEY, PLATINUM_TOKEN, "The bank exchanges your Platinum Tokens for Blood Money."));
    }),
    Last edited by ExyleServers; 07-01-2022 at 03:00 AM. Reason: edit comment
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Registered Member
    Join Date
    Sep 2022
    Posts
    15
    Thanks given
    0
    Thanks received
    1
    Rep Power
    26
    Very nice, tyvm
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [OSRSPK/Elvarg] Platinum Token exchanging
    By VenomRS in forum Snippets
    Replies: 15
    Last Post: 03-17-2020, 08:41 PM
  2. [REQ] 317 Blood Money and plat tokens
    By Krustorm in forum Models
    Replies: 5
    Last Post: 07-27-2016, 12:29 AM
  3. skilling token exchange?
    By pk3r john in forum Help
    Replies: 4
    Last Post: 11-22-2011, 11:26 PM
  4. Hitman blood money Ranks
    By SWAT in forum PC
    Replies: 4
    Last Post: 10-12-2009, 07:18 AM
  5. Minigame Token Exchanging
    By Rugrats in forum Help
    Replies: 4
    Last Post: 04-19-2009, 09:20 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •