RSSy MYGO.pl Opublikowano Styczeń 4, 2020 o 11:48 RSSy Udostępnij Opublikowano Styczeń 4, 2020 o 11:48 Code: public function GetPlayers( ) { if( !$this->Connected ) { throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED ); } $this->GetChallenge( self::A2S_PLAYER, self::S2A_PLAYER ); $this->Socket->Write( self::A2S_PLAYER, $this->Challenge ); $Buffer = $this->Socket->Read( 14000 ); // Moronic Arma 3 developers do not split their packets, so we have to read more data // This violates the protocol spec, and they probably should fix it: https://developer.valvesoftware.com/wiki/Server_queries#Protocol $Type = $Buffer->GetByte( ); if( $Type !== self::S2A_PLAYER ) { throw new InvalidPacketException( 'GetPlayers: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH ); } $Players = []; $Count = $Buffer->GetByte( ); while( $Count-- > 0 && $Buffer->Remaining( ) > 0 ) { $Player[ 'Id' ] = $Buffer->GetByte( ); // PlayerID, is it just always 0? $Player[ 'Name' ] = $Buffer->GetString( ); $Player[ 'Frags' ] = $Buffer->GetLong( ); $Player[ 'Time' ] = (int)$Buffer->GetFloat( ); $Player[ 'TimeF' ] = GMDate( ( $Player[ 'Time' ] > 3600 ? "H:i:s" : "i:s" ), $Player[ 'Time' ] ); $Players[ ] = $Player; } return $Players; } health, deaths, weapons How do I add? $Player[ 'Health' ] = ? $Player[ 'Deaths' ] = ? $Player[ 'Weapon' ] = ? Przeczytaj cały wpis Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi