Speckmops / ts3admin.class

The ts3admin.class is a powerful api for communication with Teamspeak 3 Servers from your website! Your creativity knows no bounds!
GNU General Public License v3.0
112 stars 35 forks source link

wrong user icon (e.g. "-421249225") #60

Closed RedstoneFuture closed 6 years ago

RedstoneFuture commented 6 years ago

Hello. With this code:

    #print clients to browser
    foreach($clients['data'] as $client) {

        $iconid = $client['client_icon_id'];
        echo '<img width="16" height="16" alt="test" src="/ts3-status/icons/icon_' . $iconid . '">';

        echo $client['client_nickname'] . '<br>';
    }

at the one player I get the correctly icon, at the other not: https://redstoneworld.de/ts3-status/tsstatus.php . Then I get a icon ID e.g. "-421249225" ... This icon is not in "/home/teamspeak3/TeamSpeak3-Server/files/virtualserver_12/internal/icons" , but the player have the correctly icon in teamspeak. Must I restart the ts3? Is this a cached icon or what is the problem, please?

lgund commented 6 years ago

Must I restart the ts3?

No. You need to bitwise change the value. I can´t explain it good in english. So here is the source. If you have question above it I can try to explain the source.

if($iconid < 0) { $iconid = sprintf('%u', $iconid & 0xffffffff); };

RedstoneFuture commented 6 years ago

@lgund Vielen dank schonmal für die Hilfe. Müsste nicht alles eine normale ID in Form einer Zahl haben? Was denkt sich TeamSpeak dabei, dass man sowas umrechnen muss?

lgund commented 6 years ago

TeamSpeak kann dagegen nichts tun. Wenn ich richtig liege ist dir Bitfolge eines Integers auf die Anzahle seiner Bits beschränkt. Das MSB ist das Vorzeichen und wenn das 1 ist, so wird die Zahl negativ. Mit der Bitweisen "Verundung" wird nun das wieder zu einer positiven Zahl umgewandelt. Warum allerdings Teamspeak nicht einfach kleinere Zahlen für die Iconid verwendet weiß ich allerdings nicht.

https://de.wikipedia.org/wiki/Integer_(Datentyp)

RedstoneFuture commented 6 years ago

@lgund Ok, ich verstehe. Nun funktionierts auch. Danke sehr! :)