How to teleport all players to different locations - WITH CODE

Discussion in 'Plugin Development' started by TheSkyNetwork, Apr 15, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    TheSkyNetwork

    Hello I was going to ask how can I Teleport all my players to different cords. Like in SurvivalGames how they teleport to different spots, How may I do it ?

    Code:
    if (cmd.getName().equalsIgnoreCase("Start")) {
                this.getServer().getScheduler()
                        .scheduleSyncRepeatingTask(this, new Runnable() {
     
                            public void run() {
                                for (Player player : Bukkit.getServer()
                                        .getOnlinePlayers()) {
                                    player.setLevel(number);
                                    player.setGameMode(GameMode.ADVENTURE);
                                }
                                if (number != 30) {
                                } else {
                                    player.sendMessage(ChatColor.BLUE
                                            + "SurvivalGames:" + ChatColor.GOLD
                                            + " Game starting in 30 seconds");
                                    BarAPI.setMessage(
                                            "Game starting in 30 seconds", 10);
                                }
                                if (number != 20) {
                                } else {
                                    Bukkit.broadcastMessage((ChatColor.BLUE
                                            + "SurvivalGames:" + ChatColor.GOLD + " Game starting in 20 seconds, Now opening up kits"));
                                    for (Player p : Bukkit.getServer()
                                            .getOnlinePlayers())
                                        p.openInventory(SurvivalGamesKits);
                                    BarAPI.setMessage(
                                            "Game starting in 20 seconds", 10);
                                }
                                if (number != 10) {
                                } else {
                                    for (int i = 0; i < 100; i++) {
                                        player.sendMessage("");
                                    }
                                    Bukkit.broadcastMessage(ChatColor.BLUE
                                            + "SurvivalGames:"
                                            + ChatColor.GOLD
                                            + " Game starting in 10 seconds, say GL And HF !");
                                    for (Player p : Bukkit.getServer()
                                            .getOnlinePlayers())
                                        p.chat(ChatColor.BLUE + "GL And HF !");
                                    BarAPI.setMessage(
                                            "Game starting in 10 seconds", 10);
                                }
                                if (number != -1) {
                                    if (number != 0) {
                                        number--;
                                    } else {
                                        Bukkit.broadcastMessage("Count down is over");
                                        for (Player p : Bukkit.getServer()
                                                .getOnlinePlayers()) {
                                            p.setNoDamageTicks(300);
                                            Bukkit.getScheduler().cancelAllTasks();
                                        }
                                    }
                                }
                            }
                        }, 0L, 20L);
            }
    At the end I Need players to get teleport to random locations but with x,y,z

    I Tried array list and that didn't work maybe someone give me a code? or something

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    idontcare1025

    Use player.teleport(a location). You can have an array or list of locations.
    Some pseudo-code:
    Code:java
    1. public void teleport(Location[] locations, Player[] players) {
    2. for (int i = 0; i < players.length; i++) {
    3. players[i].teleport(locations[i];
    4. }
    5. }[/i][/i]
     
  3. Offline

    TheSkyNetwork

    So where should I put this in my code ?

    I need some code so it will fit in with this
    Code:
    Bukkit.broadcastMessage("Count down is over");
                                        for (Player p : Bukkit.getServer()
                                                .getOnlinePlayers()) {
                                            p.setNoDamageTicks(300);
                                            Bukkit.getScheduler().cancelAllTasks();
                                        }
                                    }
                                }
                            }
                        }, 0L, 20L);
            }
    I mean I put it somewhere but how can I teleport?

    Anyone bump?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    AoH_Ruthless

  5. Offline

    idontcare1025

    If you can't figure out how to use my code in there, you should probably do some more simple work with teleporting players before attempting this plugin.
     
  6. Offline

    BillyGalbreath


    Do you know what pseudo-code is? Its improper code that is designed to express an idea of real code. It's not real code, and it wont run. Read the code to understand the idea of what its attempting to do, then you will understand how to translate it into your own real code.

    If you want someone to do the work for you, you are in the wrong sub forum. You would then be looking for the Plugin Requests section.
     
    idontcare1025 likes this.
  7. Offline

    TheSkyNetwork

    You are wrong the Plugin Request is only for PUBLIC PLUGINS not private plugins like this one ! And I do know a lot about Java but I just never heard of "pseudo-code" so I'm sorry about that.
     
  8. Offline

    BillyGalbreath

    Actually, its for both. No where does the plugin requests section require the plugins be open to the public in jar or source formats. The only rule is no money is to be exchanged for the services offered there.
    Pseudo-code is the first thing you learn in programming class 101. Its how you learn logic before attempting syntax, because you can be syntactically correct with everything but if your logic sucks then your code sucks.

    Don't take this as me being mean or rude. I'm teaching. That's what you're here for, isn't it? To learn.
     
Thread Status:
Not open for further replies.

Share This Page