1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Set skin

Discussion in 'Development' started by SergeyIvanov, Dec 11, 2016.

  1. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    How to set skin to player? Skin is in file plugins skin.png.
     
  2. kaliiks

    kaliiks Zombie

    Messages:
    250
    PHP:
    $player->setSkin($player->getSkinData(), 'Steve??');
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    This won't sork with a png. I don't have the conversion code at hand right now though..
     
  4. svile

    svile Spider

    Messages:
    14
    using the gd extension:

    PHP:
    $path 'your/path/to/skin.png';
    $img = @imagecreatefrompng($path);
    $skinbytes '';
    $l = (int)@getimagesize($path)[1];

    for (
    $y 0$y $l$y++) {
        for (
    $x 0$x 64$x++) {
            
    $argb = @imagecolorat($img$x$y);
            
    $a = ((~((int)($argb >> 24))) << 1) & 0xff;
            
    $r = ($argb >> 16) & 0xff;
            
    $g = ($argb >> 8) & 0xff;
            
    $b $argb 0xff;
            
    $skinbytes .= chr($r) . chr($g) . chr($b) . chr($a);
        }
    }

    @
    imagedestroy($img);

    $player->setSkin($skinbytes'Standard_Custom');
    //Standard_CustomSlim for alex

    //n.b : this code is just an example, there are no checks for the gd extension , the file existence, PNG file header, .png extension, image size but you should add them
     
    Last edited: Apr 9, 2017
  5. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Why the @ everywhere? If something wrong happens, an error should be properly triggered. If you want to silence them, you should be responsible for handling them.
     
  6. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    Ok, but how to set skin of mcpe?
     

    Attached Files:

  7. svile

    svile Spider

    Messages:
    14
    because i told him:
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    yeah, just wondering why you still add the stfu operator in that case :D
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.