Thread: [PI] Revamped gambling! Better than my last

Results 1 to 6 of 6
  1. #1 [PI] Revamped gambling! Better than my last 
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    This is my gamble command. I have updated this since my last gamble command which was quite a while ago and was, A: Messy, B: Not efficient, C: Not worthy of a release, But this time! This time i have revamped it and made it more efficient but it still probably quite messy so feel free to compact it with this one you can now gamble custom amount and it features a server announcment when someone wins over a certain amount which is changable with an int, note this was 100% made by me and you can use all you want idc lol, Example use ::gamblex 5000
    I was gonna make this into a seperate class and use something like a tax bag for it but i wanted to get a release out quickly
    Enjoy and happy gambling, NOTE: you can incorporate this into a dice bag if you have a later revision of PI, mines only 317
    Heres an image
    Attached image

    Spoiler for Code:

    Code:
    if (playerCommand.startsWith("gamblex")) {
    				String amount = playerCommand.substring(8);
    				int ssss;
    				ssss = Integer.parseInt(amount);
    				int anounceAmount = 10000000;
    				int highBound = 100;
    				int lowBound = 1;
    				
    
    				if (c.getItems().getItemAmount(995) >= ssss) {
    					Random rand = new Random();
    					int n = rand.nextInt(highBound) + lowBound;
    					if (n > 50) {
    						c.getItems().addItem(995, ssss);
    						c.sendMessage("You rolled a :" +n);
    						if (ssss >= 1000) {
    						c.sendMessage("Congratulations on winning "+(ssss /1000)+"k");
    						}
    						if (ssss < 1000) {
    							c.sendMessage("Congratulations on winning "+ssss+"gp");
    						}
    						 for (int j = 0; j < Server.playerHandler.players.length; j++) {
    							
    								 if (Server.playerHandler.players[j] != null) {
    									 
    										 Client all = (Client)Server.playerHandler.players[j];
    										 String pN = c.playerName;
    										
    										 if (ssss >= anounceAmount) {
    											 all.sendMessage("@bla@[@blu@GAMBLE BOT@bla@]: "+pN+" Just WON "+(ssss /1000000)+"m");
    										}
    									 }
    								 }
    						 }
    					
    					else {//if you lost
    						c.getItems().deleteItem2(995, ssss);
    						c.sendMessage("You rolled a :" +n);
    						c.sendMessage("Better luck next time!");
    					}
    						
    					
    					
    				}
    				
    				else {//if you didnt have enough money
    					c.sendMessage("You do not have enough money!");
    				}
    			
    			}


    - S C A P E (Oscar)
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  2. #2  
    Donator

    H1N1's Avatar
    Join Date
    Oct 2009
    Posts
    793
    Thanks given
    25
    Thanks received
    61
    Rep Power
    153
    Can't some one abuse this command?
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2010
    Posts
    19
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Just a quick note, don't use names like ssss. Use names with a meaning. You should look at a variable name and it should be clear to everyone who is reading what that variable is for.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Thanks for the share
    Reply With Quote  
     

  5. #5  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    You could have done much better

    https://gyazo.com/02db76365d5f4336aa43304dfab43b91
    Reply With Quote  
     

  6. #6  
    Extreme Donator

    nbness2's Avatar
    Join Date
    Aug 2011
    Posts
    692
    Thanks given
    274
    Thanks received
    139
    Rep Power
    430
    Tip for future stuff to look more professional

    Use variable names that make sense so anyone else reading the code can just look at the name and (hopefully) correctly infer what the variable is going to be used for.



    Instead of

    Code:
    "You rolled a :"+roll
    >>> You rolled a :81
    I would personally do this

    Code:
    "You have rolled: "+roll
    >>> You have rolled: 81
    Reasons:
    • It would look better to do "have rolled: " compared to "rolled a :" because "rolled a :" has some grammatical consequences (you rolled a eighty one) vs (you have rolled eighty one).
    • Generally I think it's better to look at ": value" than " :value" because it has some separation and adds clarity
    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. Replies: 31
    Last Post: 05-18-2014, 05:38 PM
  2. My 2nd GFX [Much Better Than 1st]
    By Aust1n in forum Showcase
    Replies: 8
    Last Post: 10-07-2012, 06:12 PM
  3. Better client then my last
    By Kenneh in forum Downloads
    Replies: 20
    Last Post: 12-04-2010, 01:34 AM
  4. Login (better than my others.)
    By ThatGuyGlazed in forum Graphics
    Replies: 13
    Last Post: 05-10-2008, 08:23 AM
  5. New background, better than my last one.
    By ThatGuyGlazed in forum Graphics
    Replies: 7
    Last Post: 05-02-2008, 08:58 PM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •