Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- @Filename : getPlayerInfo.php
- @Description : Parses all the useful information from player.dat
- to a user-friendly array
- @Written by Pr4w for Bukkit.org
- @Usage : getPlayerInfo('Pr4w', '/opt/minecraft/World1/');
- This outputs a $playerInfo['Pr4w'] variable that you can mess with
- Outputs : Position, Health, Inventory
- Have fun :)
- */
- // This requires an NBT Parser
- require('nbt.class.php');
- function getPlayerInfo($player, $worldLocation) {
- // Make the function output to $playerInfo
- global $playerInfo;
- // Make it more user friendly
- $file = $worldLocation . $player . ".dat";
- // Use the NBT Parser to load the .dat file
- $nbt = new nbt();
- $nbt->loadFile($file);
- // Get position sub-array
- $pos = $nbt->root[0]['value'][11]['value']['value'];
- // Get health sub-array
- $health = $nbt->root[0]['value'][8]['value'];
- // Get item sub-array ?
- $items = $nbt->root[0]['value'][10]['value']['value'];
- // Merge
- $playerInfo[$player] = array (
- 'position' => array (
- 'x' => $pos[0],
- 'y' => $pos[1],
- 'z' => $pos[2]
- ),
- 'health' => $health,
- 'inventory' => $items
- );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement