Solved Get other players inventory

Discussion in 'Plugin Development' started by InspectorFacepalm, May 11, 2013.

Thread Status:
Not open for further replies.
  1. So I was wondering how like I would do /checkinventory <name> it will show their inventory
    This code doesn't work for me, any help would be great D: thanks
    Code:
                            PlayerInventory inv = p.getInventory();
     
  2. Offline

    chasechocolate

    Code:java
    1. player.openInventory(target.getInventory());
     
    InspectorFacepalm likes this.
  3. So if I was making something like this
    is this how I would put it
    Code:
                              if (args.length == 0) {
                                    sender.sendMessage(ChatColor.GRAY + "Please specify a player!");
                                    return true;
                            }
                            Player target = Bukkit.getServer().getPlayer(args[0]);
                            if (target == null) {
                                    sender.sendMessage(ChatColor.GRAY + "Could not find player " + args[0] + "!");
                                    return true;
                            }
                            if (args.length == 1) {
    
                              p.openInventory(target.getInventory());
     
  4. Offline

    chasechocolate

    InspectorFacepalm something like:
    Code:java
    1. if(args.length == 1){
    2. Player target = Bukkit.getPlayer(args[0]);
    3.  
    4. if(target == null){
    5. //They are not online
    6. player.sendMessage(ChatColor.RED + "Could not find the player '" + target.getName() + "'!");
    7. return true;
    8. } else {
    9. //They are online
    10. player.openInventory(target.getInventory());
    11. player.sendMessage(ChatColor.GREEN + "You are now viewing " + target.getName() + "'s inventory!");
    12. return true;
    13. }
    14. }
     
    InspectorFacepalm likes this.
  5. thank you man<333
    You're awesome!!
     
  6. Offline

    chasechocolate

    No problem :)
     
    InspectorFacepalm likes this.
Thread Status:
Not open for further replies.

Share This Page