Last active
August 3, 2018 21:26
-
-
Save jasonw4331/4124fe36b8e6c8ae1adc3c8af468d38f to your computer and use it in GitHub Desktop.
Set a player's skin in PMMP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = 'your/path/to/skin.png'; | |
$img = @imagecreatefrompng($path); | |
$bytes = ''; | |
$l = (int)@getimagesize($path)[1]; | |
for ($y = 0; $y < $l; $y++) { | |
for ($x = 0; $x < 64; $x++) { | |
$rgba = @imagecolorat($img, $x, $y); | |
$a = ((~((int)($rgba >> 24))) << 1) & 0xff; | |
$r = ($rgba >> 16) & 0xff; | |
$g = ($rgba >> 8) & 0xff; | |
$b = $rgba & 0xff; | |
$bytes .= chr($r) . chr($g) . chr($b) . chr($a); | |
} | |
} | |
@imagedestroy($img); | |
$player->setSkin($bytes, 'Standard_Custom'); //Standard_CustomSlim for alex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment