Question Please boys. Help? hh

Discussion in 'Bukkit Help' started by PiggKingg, Jan 13, 2016.

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

    PiggKingg

    Alright, basically I'm trying to get amount of online players having a Minecart in their inventories. I'm totally confused. Help would be soooo appreciated.
     
  2. Offline

    oceantheskatr

    Here's some code that you can base making yours off of.

    Code:
    // Make variable that will count how many mine
    int amount = 0
    
    // This will iterate through each player that is online
    for (Player p : onlineplayers) {
    
    // This will iterate through each slot in the player's inventory
        for (int i = 0; i < 36; i++) {
    
    // If the slot is null, skip it and proceed to the next one
            if (inv.getItem(i) == null)
                continue;
    // If the slot material is equal to a minecart
            if (inv.getItem(i) == minecart) {
    
    // Add 1 to the amount
                amount++
    
    // By making i == 36, you will go to the next player
                i = 36;
            }
        }
    }
    
    This could SHOULD work. It's up to you to figure out the actual code to use though, I've provided the logic of what you need to do.
     
Thread Status:
Not open for further replies.

Share This Page