Thread: [Kronos] How to mics random tele home?

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36
  1. #1 [Kronos] How to mics random tele home? 
    Registered Member
    Join Date
    Nov 2020
    Posts
    78
    Thanks given
    41
    Thanks received
    2
    Rep Power
    23
    Tele home is always in the same pos(X.Y), I want it Mics random teleports.

    This is my code:

    public static final Position HOME = Position.of(3085, 3488, 0);
    I will thanks and rep for the helpers.
    Reply With Quote  
     

  2. #2  
    Registered Member
    JayArrowz's Avatar
    Join Date
    Sep 2008
    Posts
    67
    Thanks given
    60
    Thanks received
    64
    Discord
    View profile
    Rep Power
    392
    Code:
    Position randomHomePos = Position.of(Misc.random(2) + HOME.getX(), Misc.random(2) + HOME.getY(), HOME.getZ());
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2020
    Posts
    78
    Thanks given
    41
    Thanks received
    2
    Rep Power
    23
    Quote Originally Posted by JayArrowz View Post
    Code:
    Position randomHomePos = Position.of(Misc.random(2) + HOME.getX(), Misc.random(2) + HOME.getY(), HOME.getZ());
    [Only registered and activated users can see links. ]

    I imported the first Mics but the 2nd one still in red error.
    Reply With Quote  
     

  4. #4  
    Registered Member
    JayArrowz's Avatar
    Join Date
    Sep 2008
    Posts
    67
    Thanks given
    60
    Thanks received
    64
    Discord
    View profile
    Rep Power
    392
    Quote Originally Posted by Ilgaz View Post
    [Only registered and activated users can see links. ]

    I imported the first Mics but the 2nd one still in red error.
    You should not declare that there, you need to find where the HOME variable gets USED (NOT DECLARED). Then place the position on top of that.

    What you are searching for should look like this:
    Code:
    player.startTeleport(HOME);
    Once you find the code above or similar code to it then change it to:

    Code:
    Position randomHomePos = Position.of(Misc.random(2) + HOME.getX(), Misc.random(2) + HOME.getY(), HOME.getZ());
    player.startTeleport(randomHomePas);
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Registered Member
    Join Date
    Nov 2020
    Posts
    78
    Thanks given
    41
    Thanks received
    2
    Rep Power
    23
    Quote Originally Posted by JayArrowz View Post
    You should not declare that there, you need to find where the HOME variable gets USED (NOT DECLARED). Then place the position on top of that.

    What you are searching for should look like this:
    Code:
    player.startTeleport(HOME);
    Once you find the code above or similar code to it then change it to:

    Code:
    Position randomHomePos = Position.of(Misc.random(2) + HOME.getX(), Misc.random(2) + HOME.getY(), HOME.getZ());
    player.startTeleport(randomHomePas);
    [Only registered and activated users can see links. ]

    Now I'm getting random error.. Ugh..
    Reply With Quote  
     

  7. #6  
    Registered Member
    JayArrowz's Avatar
    Join Date
    Sep 2008
    Posts
    67
    Thanks given
    60
    Thanks received
    64
    Discord
    View profile
    Rep Power
    392
    Quote Originally Posted by Ilgaz View Post
    [Only registered and activated users can see links. ]

    Now I'm getting random error.. Ugh..
    Please read carefully what i said.

    This is a declaration:
    Code:
    public static Position HOME = Position.of(x, x, x);

    This is using the declared variable:
    Code:
    player.startTeleport(HOME);
    Also it seems you dont have Misc.java?
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    Nov 2020
    Posts
    78
    Thanks given
    41
    Thanks received
    2
    Rep Power
    23
    Quote Originally Posted by JayArrowz View Post
    Please read carefully what i said.

    This is a declaration:
    Code:
    public static Position HOME = Position.of(x, x, x);

    This is using the declared variable:
    Code:
    player.startTeleport(HOME);
    Also it seems you dont have Misc.java?
    I'm sorry. My English is not that good so I don't got you. This is my code:

    public static final Position HOME = Position.of(3085, 3488, 0);
    Position randomHomePos = Position.of(Misc.random(2) + HOME.getX(), Misc.random(2) + HOME.getY(), HOME.getZ());
    player.startTeleport(randomHomePas);
    If u can replace my code with everything u said I wil appricate.
    Reply With Quote  
     

  9. #8  
    RuneCasino


    Join Date
    Jul 2007
    Posts
    1,618
    Thanks given
    170
    Thanks received
    228
    Rep Power
    326
    Don't listen to JayArrowz, you have Misc.java just not the random method. Also avoid using Positon.of I ran into buggy errors with teleporting/player saving. Use new Position(3085, 3488, 0); instead.

    Also use this for random ints:

    Code:
           Random ran = new Random(); 
      
            // Print next int value 
            // Returns number between 0-9 
            int nxt = ran.nextInt(10);
    So your whole code should look like this:

    Code:
           Random ran = new Random(); 
    
    
    public static final Position HOME = new Position(3085, 3488, 0);
    Position randomHomePos = new Position(ran.nextInt(2) + HOME.getX(), ran.nextInt(2) + HOME.getY(), HOME.getZ());
    player.getMovement().teleport(randomHomePos);
    If you want you can add this method to Misc.java to use the random method in the future for other things:

    Code:
           public static int random(int randomInt) {
    		Random ran = new Random();
            	// Print next int value 
            	// Returns number between 0-9 
    		int nxt = ran.nextInt(randomInt);
    	        return nxt;
           }
    Reply With Quote  
     

  10. Thankful user:


  11. #9  
    Registered Member
    Join Date
    Nov 2020
    Posts
    78
    Thanks given
    41
    Thanks received
    2
    Rep Power
    23
    Quote Originally Posted by Armo View Post
    Don't listen to JayArrowz, you have Misc.java just not the random method. Also avoid using Positon.of I ran into buggy errors with teleporting/player saving. Use new Position(3085, 3488, 0); instead.

    Also use this for random ints:

    Code:
           Random ran = new Random(); 
      
            // Print next int value 
            // Returns number between 0-9 
            int nxt = ran.nextInt(10);
    So your whole code should look like this:

    Code:
           Random ran = new Random(); 
    
    
    public static final Position HOME = new Position(3085, 3488, 0);
    Position randomHomePos = new Position(ran.nextInt(2) + HOME.getX(), ran.nextInt(2) + HOME.getY(), HOME.getZ());
    player.getMovement().teleport(randomHomePos);
    If you want you can add this method to Misc.java to use the random method in the future for other things:

    Code:
           public static int random(int randomInt) {
    		Random ran = new Random();
            	// Print next int value 
            	// Returns number between 0-9 
    		int nxt = ran.nextInt(randomInt);
    	        return nxt;
           }
    Nice one bro. Awesome to have you here

    Quote Originally Posted by Armo View Post
    Don't listen to JayArrowz, you have Misc.java just not the random method. Also avoid using Positon.of I ran into buggy errors with teleporting/player saving. Use new Position(3085, 3488, 0); instead.

    Also use this for random ints:

    Code:
           Random ran = new Random(); 
      
            // Print next int value 
            // Returns number between 0-9 
            int nxt = ran.nextInt(10);
    So your whole code should look like this:

    Code:
           Random ran = new Random(); 
    
    
    public static final Position HOME = new Position(3085, 3488, 0);
    Position randomHomePos = new Position(ran.nextInt(2) + HOME.getX(), ran.nextInt(2) + HOME.getY(), HOME.getZ());
    player.getMovement().teleport(randomHomePos);
    If you want you can add this method to Misc.java to use the random method in the future for other things:

    Code:
           public static int random(int randomInt) {
    		Random ran = new Random();
            	// Print next int value 
            	// Returns number between 0-9 
    		int nxt = ran.nextInt(randomInt);
    	        return nxt;
           }
    [Only registered and activated users can see links. ]

    Oh I did not notice this.
    Reply With Quote  
     

  12. #10  
    RuneCasino


    Join Date
    Jul 2007
    Posts
    1,618
    Thanks given
    170
    Thanks received
    228
    Rep Power
    326
    Quote Originally Posted by Ilgaz View Post
    Nice one bro. Awesome to have you here



    [Only registered and activated users can see links. ]

    Oh I did not notice this.
    Add public static final to the randomHomePos line of code so it should look like this:


    Code:
    public static final Position randomHomePos = new Position(ran.nextInt(2) + HOME.getX(), ran.nextInt(2) + HOME.getY(), HOME.getZ());
    Then add this code to wherever you want it to be called (Command, clicking a teleport, teleport interface, etc)

    Code:
    player.getMovement().teleport(World.randomHomePos);
    Reply With Quote  
     

Page 1 of 4 123 ... 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. How to Portfoward A Bt-Home-Hub V.2[PICS]
    By A I R Z in forum Tutorials
    Replies: 1
    Last Post: 08-17-2009, 12:23 PM
  2. Replies: 8
    Last Post: 07-17-2009, 05:11 PM
  3. how to make a new home in a 474
    By DSscape™ in forum Tutorials
    Replies: 12
    Last Post: 06-14-2009, 04:55 AM
  4. How to Drop random Item Amounts
    By tucybro in forum Tutorials
    Replies: 7
    Last Post: 06-08-2009, 11:11 PM
  5. Replies: 15
    Last Post: 10-02-2008, 03:27 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
  •