View Single Post
Author Message
xRENN1Ex
Junior Member
Join Date: Dec 2019
Old 01-06-2020 , 01:07   CS1.6 RCON Player Info
Reply With Quote #1

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' ] = ?
xRENN1Ex is offline