forum Forumsplay_arrow Minecraft fiber_manual_record Mods

1

Bukkit Plugin Help

1 emerald6 replies150 views
created 07/31/2013 2:21 am by Hydrian
last reply 07/31/2013 2:41 am
Hey, I have a array for my bukkit plugin im working on, I also have a array holding a random user, and how can I get the other users from that array to a variable?

so

variable = <array>[rand(getsrandomplayer)]
others = the rest of the array?


How could I do that?
Posted by avatar
Hydrian
Level 43 : Master Gent
111

6 replies

1
07/31/2013 2:41 am
Level 43 : Master Gent
Hydrian
avatar
Ok thanks so much, if you want, I may need further help with my plugin if you wish to help me you may, cmedia.studios add me skype???

Thanks

~Hydri
1
07/31/2013 2:39 am
Level 53 : Grandmaster Programmer
nickfromgreece
avatar
Corrected code:

int random = new Random().nextInt(Bukkit.getOnlinePlayers().length);//random select player
Player[] players = Bukkit.getOnlinePlayers();
Player player = players[random];//make a array with the chosen user in it
Player[] theNotChosen = new Player[PutTheMaxAmountOfPlayersHere];
public void onGameStart(CommandSender sender){
int lengh = 0;
for(Player player : players){
if(!player.equals(player)){
theNotChosen [lengh] = player;
lengh++;
}
}
player.sendMessage("Your It!");
}
1
07/31/2013 2:33 am
Level 43 : Master Gent
Hydrian
avatar
I got

int random = new Random().nextInt(Bukkit.getOnlinePlayers().length);//random select player
Player player = Bukkit.getOnlinePlayers()[random];//make a array with the chosen user in it

public void onGameStart(CommandSender sender){
int lenght = 0;
for(Player player : array){
if(!player.equals(player)){
(theres?)[lenght] = player;
lenght++;
}
}
player.sendMessage("Your It!");
}


Correct Yes?
1
07/31/2013 2:28 am
Level 43 : Master Gent
Hydrian
avatar
where dose theres come into play?
1
07/31/2013 2:30 am
Level 53 : Grandmaster Programmer
nickfromgreece
avatar
it was the others array mispelled that oops
1
07/31/2013 2:23 am
Level 53 : Grandmaster Programmer
nickfromgreece
avatar
Player chosen = array[getThePlayer];
Player[] others = new Player[maxPlayersHere];
int lengh = 0;
for(Player player : array){
if(!player.equals(chosen){
others[lengh] = player;
lengh++;
}
}

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome