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

Checking invisible skins

Discussion in 'Development' started by TheGhan, Oct 30, 2017.

  1. TheGhan

    TheGhan Silverfish

    Messages:
    15
    I want to block players from accessing my server if more than half of the pixels in their skin are transparent. Here is the code I’m using at the moment:
    PHP:
    public static function isInvisibleSkin(Skin $skin) : bool {
        
    $data $skin->getSkinData();
        
    $length strlen($data);
        
    $halfSkin false;
        
    $totalSkin $data === str_repeat("\x00"$length);
        
    $c 0;
        for (
    $i 0$i $length$i++) {
            if (
    $c >= ($length 2) + 3400) {
                
    $halfSkin true;
                
    var_dump($length);
                
    var_dump($c); //DEBUG: I want to see if happens again.
                
    break;
            }
            if (
    $data[$i] === "\x00") {
                
    $c++;
            }
        }
    return 
    $halfSkin || $totalSkin;
    }
    It hasn’t exactly worked for some players - it’s even blocked some players because they have a second layer. How would I fix my code to achieve what I want?
     
    Last edited: Oct 31, 2017
  2. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    First, Try to count what's the length of skin without layers to stop it from kicking Players with second layer.
     
  3. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    R.I.P, Rip all my transperent skins i worked so hard to get

    i cri everytime
     
  4. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    Please read again your reply and correct your mistakes sir... Jk lol
     
  5. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    i trying learn new language (php) when i cany use engis now i never make pmmp fork in scratch :(

    i cri everytime
     
  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.