Allocate number to each player within a range

Discussion in 'Plugin Development' started by slater96, Sep 15, 2013.

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

    slater96

    Hello, I want to allocate a number to each player without any duplicates and within a range so that I can teleport them to that number spawn, for example:

    Player 1 - 2
    Player 2 - 5
    Player 3 - 1
    Player 4 - 3
    Player 5 - 4

    Thanks.
     
  2. slater96
    Are you having a problem with an existing code, or do you not know how to do it?

    I'd use a HashMap/Set<String, Integer>, then loop through all players nearby a location, and if you want the numbers to be random, then use a random number generator between ((amount of nearby players - 1) + 1) + 1, then add the player name to the map/set as key, and the random int as value, if the value doesn't already exist.
     
  3. Offline

    Loogeh

    Assist Sets can only hold a key, not a key and a value.
     
Thread Status:
Not open for further replies.

Share This Page