header('Content-Type: image/png'); $player_name = 'wide_load'; $width = 200; $height = 200; $cache_file = "cache/player_skins/faces/{$player_name}_{$width}x{$height}.png"; if (!file_exists($cache_file) || time() - filemtime($cache_file) > 86400){ $skin = imagecreatefromstring(file_get_contents("http://skins.minecraft.net/MinecraftSki ... _name}.png")); $face = imagecreatetruecolor($width, $height); imagecopyresized($face, $skin, 0, 0, 8, 8, $width, $height, 8, 8); imagecopyresized($face, $skin, 0, 0, 40, 8, $width, $height, 8, 8); imagepng($face, $cache_file); } readfile($cache_file);It seems pretty self-explanatory, feel free to ask questions
Minecraft Player Face Rendering
Minecraft Player Face Rendering
This is actually really simple to do and can make a impressive auto-avatar to your website
Last edited by Helx on Thu Mar 28, 2013 9:45 am, edited 1 time in total.
Reason: Updated to play nice with migrated accounts (there's a new URL for skins)
Reason: Updated to play nice with migrated accounts (there's a new URL for skins)
Re: Minecraft Player Face Rendering
How would I use this in a MineQuery player list (like massivecraft.com)?
Sorry, I've just never used this kind of thing with an array
Sorry, I've just never used this kind of thing with an array
Re: Minecraft Player Face Rendering
You would just need to change the player_name so the name of the player you want.
Re: Minecraft Player Face Rendering
Ah, thanksjacek wrote:You would just need to change the player_name so the name of the player you want.
Re: Minecraft Player Face Rendering
It would make the most sense to put the above code in a separate file and use a $_GET to pass in the player name
$player_name = $_GET['player_name'];Then you can use the script in a img tag
<img src="the_script.php?player_name=wide_load" alt="" />then it's fully dynamic.
Re: Minecraft Player Face Rendering
Would it be to much trouble to ask you to explain or possibly make a video on how to put this into the Minequery script you made?
Re: Minecraft Player Face Rendering
It sort of explained above :S What don't you understand ?Silent79 wrote:Would it be to much trouble to ask you to explain or possibly make a video on how to put this into the Minequery script you made?
Re: Minecraft Player Face Rendering
Sorry .. new to PHP ... I have been playing around with it. I think I have it figured out. Trial and error ...
Re: Minecraft Player Face Rendering
Okay You can always post in the support section if you come up with a specific question
-
- Posts: 1
- Joined: Fri Feb 10, 2012 5:21 pm
Re: Minecraft Player Face Rendering
I followed the previous tutorial(s) you did on Minequery and had incorporated that into the site I host of a Minecraft server. I was displaying the list of logged in users via [playerList], and used this code (placed inside mcface.php) to display the face instead!
foreach ($info[playerList] as $player) { echo "<img width=\"100\" height=\"100\" src=\"/mcface.php?player_name=" . $player . "\" title=\"{$player}\" /> "; }I also incorporated this into the user profile system to auto create an avatar for any user that logs into our Minecraft server since this code creates the image, I just check if it exists and if so it displays as the users avatar. They still have an options to upload their own avatar, it's pretty neat I think...
Oh and some of the players kept asking to create a face for them to use on other sites, so I setup this form:
http://nightrebellion.com/face
It uses the same code and allows the user to generate the face and click to download...
Thanks for sharing
Re: Minecraft Player Face Rendering
Looks good ! That is pretty much what I use it for too http://somethingcraft.co.uk/player_prof ... =wide_load
Re: Minecraft Player Face Rendering
May I ask how you did the MOB/player kills part? I understand that you probably used LogBlock for the blocks (because I have done that, http://s.stratuscraft.net/lb/?player=abcedea)jacek wrote:Looks good ! That is pretty much what I use it for too http://somethingcraft.co.uk/player_prof ... =wide_load
I know LogBlock has a player death logger, with what killed you/you killed. But I have no idea how to use that...
Re: Minecraft Player Face Rendering
I found LogBlock to be a bit too slow for that kinds of stats, my database has over 8 million entries in it and summing all of those took a good few seconds. It's a custom plugin https://github.com/betterphp/PlayerStatsabcedea wrote:May I ask how you did the MOB/player kills part? I understand that you probably used LogBlock for the blocks (because I have done that, http://s.stratuscraft.net/lb/?player=abcedea)
I know LogBlock has a player death logger, with what killed you/you killed. But I have no idea how to use that...
Re: Minecraft Player Face Rendering
Ah, ok. I'll take a look at it.jacek wrote:It's a custom plugin https://github.com/betterphp/PlayerStats
(That explains why that webpage loaded so fast XD)
Re: Minecraft Player Face Rendering
exactly ! Since we have 8 worlds on the server it used to take a good 30 seconds sometimes to load !abcedea wrote:(That explains why that webpage loaded so fast XD)
Re: Minecraft Player Face Rendering
Sorry to bring back an old thread, but how the hell did you break Air blocks!?!?!jacek wrote:Looks good ! That is pretty much what I use it for too http://somethingcraft.co.uk/player_prof ... =wide_load
http://i.imgur.com/APYmk.png
Re: Minecraft Player Face Rendering
I would imagine superpick or some kind of black magic :/jobud9 wrote:how the hell did you break Air blocks!?!?!
Re: Minecraft Player Face Rendering
Yep, or bugs. Or I think placing water buckets. I should filter them out reallyabcedea wrote:I would imagine superpick or some kind of black magic :/jobud9 wrote:how the hell did you break Air blocks!?!?!
Re: Minecraft Player Face Rendering
Oh boy, sorry for reviving an old thread but I could use some help with this script. Im doing my best with my very very very basic understanding of php to incorporate this in to my sites CMS(php-fusion) for users auto avatars. Also excuse me if I misuse the terminology here. Upon registering a user has to input their username in order to register. So I have your code.
The dq query for this is
Heres what im using to test it at least
In addition I also need a if/else for an invalid username say its unable to load an image then else it would load like a noavatar.png image.
I hope you understand what im trying to get it as im having trouble explaining this without knowing all the terms. Thanks in advance!
<?php header('Content-Type: image/png'); $user_minecraft = 'wide_load'; $width = 100; $height = 100; $cache_file = "player_skins/{$user_minecraft}_{$width}x{$height}.png"; if (!file_exists($cache_file) || time() - filemtime($cache_file) > 86400){ $skin = imagecreatefromstring(file_get_contents("http://s3.amazonaws.com/MinecraftSkins/ ... craft}.png")); $face = imagecreatetruecolor($width, $height); imagecopyresized($face, $skin, 0, 0, 8, 8, $width, $height, 8, 8); imagecopyresized($face, $skin, 0, 0, 40, 8, $width, $height, 8, 8); imagepng($face, $cache_file); } readfile($cache_file); ?>My issue here is that 'wide_load' needs to call from the db query for a players username
The dq query for this is
".$data['user_minecraft'].">I need to somehow make these files work with each other so that I can replace all the avatar code to this.
Heres what im using to test it at least
echo "<img src=h.../mcavatar.php?player_name=".$data['user_minecraft'].">\n";The script runs fine and will load the player face of "wide_load"
In addition I also need a if/else for an invalid username say its unable to load an image then else it would load like a noavatar.png image.
I hope you understand what im trying to get it as im having trouble explaining this without knowing all the terms. Thanks in advance!
Re: Minecraft Player Face Rendering
If you have ?player_name=something in the URL you can get that value in the code using $_GET so for this it would be $_GET['player_name']
So just
So just
$user_minecraft = $_GET['player'_name'];should do it.