Thread: Platinum Tokens? There's gotta be a better way to do this....

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 Platinum Tokens? There's gotta be a better way to do this.... 
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Code:
    		case 6943:
    			if(itemId == 995) {
    				if (c.getItems().playerHasItem(995, 2000000000)) {
    				c.getItems().deleteItem(995, 2000000000);
    			     c.getItems().addItem(13204, 2000000);
    			     c.sendMessage("@blu@You exchange your 2 billion coins for platinum tokens!");
    			}
    			}
    			 if(itemId == 13204) {
    				if (c.getItems().playerHasItem(13204, 2000000)) {
    				c.getItems().deleteItem(13204, 2000000);
    			     c.getItems().addItem(995, 2000000000);
    			     c.sendMessage("@blu@You exchange your 2 million platinum tokens for coins!");
    			}
    			}
    			break;
    There's gotta be a better way to do this.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jan 2017
    Posts
    196
    Thanks given
    15
    Thanks received
    22
    Rep Power
    11
    Ofcourse.. your code only work if player have an X amount of them
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by Sami2427 View Post
    Ofcourse.. your code only work if player have an X amount of them
    thanks captain obvious.... lol
    care to share how to change it?
    Reply With Quote  
     

  4. #4  
    Registered Member de Lirim's Avatar
    Join Date
    Dec 2016
    Posts
    98
    Thanks given
    2
    Thanks received
    18
    Rep Power
    14
    Quote Originally Posted by zayuhh View Post
    thanks captain obvious.... lol
    care to share how to change it?
    Code:
    if (c.getItems().playerHasItem(13204, 2000000)) {
    Attached image
    Reply With Quote  
     

  5. #5  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Code:
    		if(itemID == 995 && usedOnObjectID == 6943) {
    			int tokens = c.getItems().getItemAmount(995) / 1000;
    			c.getItems().deleteItem(995, tokens*1000);
    			c.getItems().addItem(13204, tokens);
    			player.sendMessage("You exchange your coins for platinum tokens.");
    		}
    		
    		if(itemID == 13204 && usedOnObjectID == 6943) {
    			int tokens = c.getItems().getItemAmount(13204);
    			c.getItems().deleteItem(13204, tokens);
    			c.getItems().addItem(995, tokens*1000);
    			c.sendMessage("You exchange your coins for platinum tokens.");
    		}
    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Registered Member 1m6n29s9gmxh's Avatar
    Join Date
    Jan 2017
    Posts
    430
    Thanks given
    32
    Thanks received
    100
    Rep Power
    40
    Quote Originally Posted by Nighel View Post
    Code:
    		if(itemID == 995 && usedOnObjectID == 6943) {
    			int tokens = c.getItems().getItemAmount(995) / 1000;
    			c.getItems().deleteItem(995, tokens*1000);
    			c.getItems().addItem(13204, tokens);
    			player.sendMessage("You exchange your coins for platinum tokens.");
    		}
    		
    		if(itemID == 13204 && usedOnObjectID == 6943) {
    			int tokens = c.getItems().getItemAmount(13204);
    			c.getItems().deleteItem(13204, tokens);
    			c.getItems().addItem(995, tokens*1000);
    			c.sendMessage("You exchange your coins for platinum tokens.");
    		}
    Would also prob insert a
    Code:
    if (tokens * 1000 > Integer.MAX_VALUE){
                 c.sendMessage("You cannot go over max cash.");
                 return;
    }
    Spoiler for Insanity V2 Coders be like ::
    Attached image
    Attached image
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by OsFury View Post
    Would also prob insert a
    Code:
    if (tokens * 1000 > Integer.MAX_VALUE){
                 c.sendMessage("You cannot go over max cash.");
                 return;
    }
    Quote Originally Posted by Nighel View Post
    Code:
    		if(itemID == 995 && usedOnObjectID == 6943) {
    			int tokens = c.getItems().getItemAmount(995) / 1000;
    			c.getItems().deleteItem(995, tokens*1000);
    			c.getItems().addItem(13204, tokens);
    			player.sendMessage("You exchange your coins for platinum tokens.");
    		}
    		
    		if(itemID == 13204 && usedOnObjectID == 6943) {
    			int tokens = c.getItems().getItemAmount(13204);
    			c.getItems().deleteItem(13204, tokens);
    			c.getItems().addItem(995, tokens*1000);
    			c.sendMessage("You exchange your coins for platinum tokens.");
    		}
    I've added this code, and it works pretty flawlessly. However, you can use coins on the bank with less than 1000 coins, and it gives you a platinum token every time, doesn't delete the cash even.
    Reply With Quote  
     

  9. #8  
    Developer


    Join Date
    Aug 2012
    Posts
    2,493
    Thanks given
    180
    Thanks received
    1,732
    Rep Power
    2487
    Quote Originally Posted by OsFury View Post
    Would also prob insert a
    Code:
    if (tokens * 1000 > Integer.MAX_VALUE){
                 c.sendMessage("You cannot go over max cash.");
                 return;
    }
    ur code wouldnt be possible with jvm

    instead u could do something like

    Code:
    if (tokens * 1000 < 0){
                 c.sendMessage("You cannot go over max cash.");
                 return;
    }
    Reply With Quote  
     

  10. Thankful user:


  11. #9  
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by Savions View Post
    ur code wouldnt be possible with jvm

    instead u could do something like

    Code:
    if (tokens * 1000 < 0){
                 c.sendMessage("You cannot go over max cash.");
                 return;
    }
    care to assist? you can use coins on the bank with less than 1000 coins, and it gives you a platinum token every time, doesn't delete the cash even.
    Reply With Quote  
     

  12. #10  
    Donator


    Join Date
    Jul 2011
    Posts
    570
    Thanks given
    135
    Thanks received
    142
    Rep Power
    291
    Quote Originally Posted by Savions View Post
    ur code wouldnt be possible with jvm

    instead u could do something like

    Code:
    if (tokens * 1000 < 0){
                 c.sendMessage("You cannot go over max cash.");
                 return;
    }
    Wouldnt this also be ineffective because token * 1000 will return positive or negative dependent on how many they have. E.g. anything token amount greater than ~ 2147m tokens and less than ~ 4294m will be negative, but anything greater than 4294m and less than ~6400m will return positive.

    He should just insert a check using item.getAmount() and say that they can't use more than 2147m tokens at a time.

    I may be wrong though.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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. Better way to do this?
    By mige5 in forum Application Development
    Replies: 1
    Last Post: 11-27-2014, 09:35 PM
  2. Better way to do this
    By Jamili in forum Help
    Replies: 5
    Last Post: 03-30-2012, 04:14 AM
  3. Better way to do this?
    By TheeRash in forum Help
    Replies: 6
    Last Post: 12-24-2011, 05:17 PM
  4. Must be a better way of doing this?
    By Harlan in forum Help
    Replies: 7
    Last Post: 09-23-2011, 08:59 AM
  5. Replies: 2
    Last Post: 07-26-2010, 02:44 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •