Get online player inventory on Website

Discussion in 'Plugin Requests' started by Rilekt, Aug 16, 2015.

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

    Rilekt

    //Refresh all time the same error
     
  2. Offline

    567legodude

    @Rilekt To be honest I think your best bet is to create a Socket, and have a .php that can read that socket. Then on your main webpage, you reference that .php to return the inventory of whoever you want.
     
    Rilekt likes this.
  3. Offline

    Rilekt

    So, how to create socket to checking player's inventory? :G
     
  4. Offline

    timtower Administrator Administrator Moderator

    Depends, are you developing yourself?
     
  5. Offline

    Cydonia.Online

    Add this to jsonapi's methods.json file then restart minecraft...

    Code:
    {
      "name": "getInventoryContents",
      "desc": "Gets each itemstack in the specified player's inventory.",
      "returns": ["ItemStack[]", "Types of the items in the player's inventory"],
      "call": "this.getPlayerExact(0).getInventory().getContents()",
      "args": [
      ["String", "The name of the player"]
      ]
      },
    
    This is pretty much the same as the last bit of code you was given, but instead of "methods" you should use "args"...

    Next the PHP...

    Code:
    <?php
    require('JSONAPI.php');
    
    $api = new JSONAPI("localhost", 20059, "user", "password", "salt");
    
    echo '<pre>'; var_dump($api->call("getInventoryContents", array("PlayerName"))); echo '</pre>';
    
    ?>
    
    Obviously you'll want the latest copy of SDK... https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php

    Also you'll want to change user, password, salt, and PlayerName, to whatever you have configured and want.

    Hope this helps :)
     
Thread Status:
Not open for further replies.

Share This Page