Jump to content

Recommended Posts

Posted

After failing to find any well written documentation I turned to the next best thing, the source and still came up empty handed with what I'm trying to do. Essentially I am trying to select a random player who is online on the start of a mini-game as long as there are at least 3 players online. I'd also need away to store this player in a variable and be able tell when they are killed, as well as how many players are still alive.

 

I don't even know if its possible so I guess my questions are: is it possible to do this? If so, can anyone help point me in the right direction into figuring this out. I'm not that good yet with Java but I don't really learn by reading or watching videos, I learn best by doing so some hint of the right way to look into this would be extremely helpful.

 

Thanks!

Posted

You might want to check how Command Blocks track players on a server; I think this will be of the most help to you. As for accessing that code, maybe use events? Anyway, the first thing I would do is look at the Command Block functions.

Posted

Not sure you need a mod for this, like MrArcane says you may be able to do it just with command blocks in a map.

 

If you actually want to mod it, then you should look at these methods:

All players on the server: MinecraftServer.getServer().getConfigurationManager.playerEntityList

All players in a world: world.playerEntities

 

You can get the lists, get the size, generate a random number between 0 and size-1 and then get the playerEntity that has that position in the list.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Not sure you need a mod for this, like MrArcane says you may be able to do it just with command blocks in a map.

 

If you actually want to mod it, then you should look at these methods:

All players on the server: MinecraftServer.getServer().getConfigurationManager.playerEntityList

All players in a world: world.playerEntities

 

You can get the lists, get the size, generate a random number between 0 and size-1 and then get the playerEntity that has that position in the list.

 

It isn't the only thing in the mod, just for a feature in the mod. Thank you however for the tip, I'll take a look!

 

Update: That was the right place to look, easier than I figured. Got it all working, thanks!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.