Thread: [PI] Simple gambling

Results 1 to 7 of 7
  1. #1 [PI] Simple gambling 
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    This is just a simple gambling script for gambling 50k, i can also put out one that contains some sort of a jackpot, but that would contain more than this command
    Code:
    			if (playerCommand.equalsIgnoreCase("gamble50")) {
    				if (c.getItems().getItemAmount(995) >= 50000) {//simple check if the player has the right amount of money
    					Random rand = new Random();//the random number methord
    					int n = rand.nextInt(100) + 1;//the random number methord
    					if (n > 50) {//if the number was over 50 
    						c.getItems().addItem(995, 50000);//this will add 50,000 coins to the players inventory, you can add checks if you want for inv space
    						c.sendMessage("You rolled a :" +n);//the chat
    						c.sendMessage("Congratulations on winning!");
    					}
    					else {//if you lost
    						c.getItems().deleteItem2(995, 50000);//will delete that 50,000
    						c.sendMessage("You rolled a :" +n);//the chat
    						c.sendMessage("Better luck next time!");
    					}
    						
    					
    				}
    				else {//if you didnt have enough money
    					c.sendMessage("You do not have enough money!");
    				}
    					
    			}
    Attached image
    ENJOY
    - 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  
    🍕

    Linus's Avatar
    Join Date
    Dec 2008
    Age
    31
    Posts
    2,779
    Thanks given
    974
    Thanks received
    411
    Rep Power
    0
    Code:
    package server.model.players.content;
    
    import server.core.PlayerHandler;
    import server.event.CycleEvent;
    import server.event.CycleEventContainer;
    import server.event.CycleEventHandler;
    import server.model.players.Client;
    import server.model.players.Player;
    import server.util.Misc;
    
    public class DiceManager {
    
    	static int rollProcentalDice(){
    		return Misc.random(100);
    	}
    	
    	public static void startRoll(final Client c, final String type){
    		if(!c.getItems().playerHasItem(10833)){
    			return;
    		}
    		if(c.lastDiceRoll > System.currentTimeMillis()){
    			c.sendMessage("You need to wait 15 seconds between each dice roll.");
    			return;
    		}
    		c.sendMessage("You roll the dice..");
    		c.lastDiceRoll = System.currentTimeMillis()+15000;
    		for(Player p : PlayerHandler.players) {
    			if (p != null) {
    				Client c3 = (Client) p;
    				if(p.distanceToPoint(c.absX, c.absY) <= 10){
    					c.gfx100(712);
    					c.startAnimation(859);
    					c3.sendMessage("<col=800000>[Dices Rolling]: "+Misc.capitalize(c.playerName)+" is rolling the dice..");
    				}
    			}
    		}
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			@Override
    			public void execute(CycleEventContainer container) {
    				switch(type){
    					case "percentile":
    						int roll = rollProcentalDice();
    						for(Player p : PlayerHandler.players) {
    							if (p != null) {
    								Client c = (Client) p;
    								if(p.distanceToPoint(c.absX, c.absY) <= 10){
    									c.sendMessage("<col=800000>[Dices Rolling]: "+Misc.capitalize(c.playerName)+" rolled "+roll+" on the percentile  dice.");
    								}
    							}
    						}
    						c.sendMessage("You rolled "+roll+" on the percentile  dice.");
    						container.stop();
    					return;
    				}
    			}
    			@Override
    			public void stop() {
    			}
    		}, 4); 
    	}
    	
    }

    ╠╬╣
    ╦╦
    ╠╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╚╩╩╩╩╩╩╝

    ╠╬╬╬╣



    Reply With Quote  
     

  3. #3  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Thats actually pretty good, only thing is my tax bag on my server is invisible, but this is only ment to be a shell for gambling
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  4. #4  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Linus View Post
    Code:
    package server.model.players.content;
    
    import server.core.PlayerHandler;
    import server.event.CycleEvent;
    import server.event.CycleEventContainer;
    import server.event.CycleEventHandler;
    import server.model.players.Client;
    import server.model.players.Player;
    import server.util.Misc;
    
    public class DiceManager {
    
        static int rollProcentalDice(){
            return Misc.random(100);
        }
        
        public static void startRoll(final Client c, final String type){
            if(!c.getItems().playerHasItem(10833)){
                return;
            }
            if(c.lastDiceRoll > System.currentTimeMillis()){
                c.sendMessage("You need to wait 15 seconds between each dice roll.");
                return;
            }
            c.sendMessage("You roll the dice..");
            c.lastDiceRoll = System.currentTimeMillis()+15000;
            for(Player p : PlayerHandler.players) {
                if (p != null) {
                    Client c3 = (Client) p;
                    if(p.distanceToPoint(c.absX, c.absY) <= 10){
                        c.gfx100(712);
                        c.startAnimation(859);
                        c3.sendMessage("<col=800000>[Dices Rolling]: "+Misc.capitalize(c.playerName)+" is rolling the dice..");
                    }
                }
            }
            CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
                @Override
                public void execute(CycleEventContainer container) {
                    switch(type){
                        case "percentile":
                            int roll = rollProcentalDice();
                            for(Player p : PlayerHandler.players) {
                                if (p != null) {
                                    Client c = (Client) p;
                                    if(p.distanceToPoint(c.absX, c.absY) <= 10){
                                        c.sendMessage("<col=800000>[Dices Rolling]: "+Misc.capitalize(c.playerName)+" rolled "+roll+" on the percentile  dice.");
                                    }
                                }
                            }
                            c.sendMessage("You rolled "+roll+" on the percentile  dice.");
                            container.stop();
                        return;
                    }
                }
                @Override
                public void stop() {
                }
            }, 4); 
        }
        
    }
    If you're going to provide a static factory class for this, you might as well treat it as such.

    Code:
    class DiceManagerTwo extends DiceManager {
        // this shouldn't be permitted, you can fix this by making DiceManager's class implementation effectively final.
    }
    Code:
    DiceManager anInstance = new DiceManager();
    
     // this should not be possible, you can resolve this by ensuring
    // that DiceManager's constructor is private and any instancing 
    // would result in an error.
    Code:
    final class DiceManager {
        
        private DiceManager() {
            throw new AssertionError("Error, it is illegal to create an instance of the DiceManager static factory class.");
        }
    }
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    ¯\_(ツ)_/¯


    Join Date
    Jul 2014
    Posts
    1,803
    Thanks given
    928
    Thanks received
    550
    Rep Power
    299
    Thanks for the contribution, I don't think many people would use this though because its kinda basic. I think you could add on to the concept by making an NPC with dialogues to handle gambling, and make it so you can do more than just 50k.
    Reply With Quote  
     

  7. #6  
    Registered Member 1m6n29s9gmxh's Avatar
    Join Date
    Jan 2017
    Posts
    430
    Thanks given
    32
    Thanks received
    100
    Rep Power
    40
    Should probably make it so they can enter their own number to gamble
    Spoiler for Insanity V2 Coders be like ::
    Attached image
    Attached image
    Reply With Quote  
     

  8. #7  
    Registered Member Stevenhax's Avatar
    Join Date
    Jul 2014
    Posts
    387
    Thanks given
    55
    Thanks received
    64
    Rep Power
    42
    Thanks for the contribution.
    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: 3
    Last Post: 07-20-2012, 11:15 PM
  2. [PI] My Gambling Games
    By Dexter Morgan in forum Snippets
    Replies: 20
    Last Post: 12-18-2010, 07:22 PM
  3. Tut-how to add a simple gamble system
    By TLPK-SCAPE in forum Tutorials
    Replies: 7
    Last Post: 11-29-2010, 03:02 AM
  4. [PI] Simple Question
    By dixienormus1 in forum Help
    Replies: 4
    Last Post: 08-10-2010, 07:44 AM
  5. [PI] Simple Question!
    By dixienormus1 in forum Help
    Replies: 1
    Last Post: 07-05-2010, 06:05 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
  •