Skip to content

Instantly share code, notes, and snippets.

@jasonw4331
Last active August 3, 2018 21:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasonw4331/4124fe36b8e6c8ae1adc3c8af468d38f to your computer and use it in GitHub Desktop.
Save jasonw4331/4124fe36b8e6c8ae1adc3c8af468d38f to your computer and use it in GitHub Desktop.
Set a player's skin in PMMP
<?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