Raised This Month: $12 Target: $400
 3% 

CS1.6 RCON Player Info


Post New Thread Reply   
 
Thread Tools Display Modes
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
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 01-06-2020 , 09:51   Re: CS1.6 RCON Player Info
Reply With Quote #2

https://github.com/xPaw/PHP-Source-Query

Still not the right section. Post in off-topic/General
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG
xtance
Junior Member
Join Date: Feb 2018
Old 01-06-2020 , 09:54   Re: CS1.6 RCON Player Info
Reply With Quote #3

You need to make a plugin with server command, that will send a JSON string to the console of server, containing players, healths, etc.
Then you make a php script where you execute that command and pick up that string, decode it and work with it.

Sadly, I have no amxx experience, but here's how to do it in SourcePawn. Probably easy to remake for AMXX:
Code:
PrintToServer("[");
	for (int i = 1; i<=MaxClients; i++){
		if (IsClientInGame(i) && !IsFakeClient(i)){
			PrintToServer("{\"name\": \"%s\", \"steamid\": %i, \"k\": %i, \"d\": %i},",sName[i],iSteam[i],GetClientFrags(i),GetClientDeaths(i)); //i put kills and deaths here, you can put health
		}
	}
PrintToServer("]ArrayEnd");
return Plugin_Handled;
Then, in php script:
PHP Code:
$q = new SourceQuery();
$q->Connect($ip$port3SourceQuery::SOURCE);
$q->SetRconPassword($password);
$p $q->Rcon("sm_web_getplayers"); //your command
$pieces explode("ArrayEnd"$p); //my retarded workaround
$arr str_replace(",\n]","]",$pieces[0]); //and another one
$players json_decode($arrtrue); 
Now you can iterate over $players with foreach and get whatever you need

Last edited by xtance; 01-06-2020 at 09:57.
xtance is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-06-2020 , 21:07   Re: CS1.6 RCON Player Info
Reply With Quote #4

I guess I didn't realize that the information you were requesting wasn't already in the protocol so I thought it was only PHP changes required. But, it looks like you do need to have a plugin handle this because the information you're looking for is not provided by the built-in protocol.

EDIT: Attached is a plugin based on xtance's code above with the exception that I used the command name "web_getplayers" so you'll need to change that in the Rcon command in PHP. Test it out to make sure that it works properly to get info from the server. Then, the content of the message can be changed to be what you need.
Attached Files
File Type: sma Get Plugin or Get Source (extra_rcon_info.sma - 327 views - 703 Bytes)
__________________

Last edited by fysiks; 01-06-2020 at 21:28.
fysiks is offline
xRENN1Ex
Junior Member
Join Date: Dec 2019
Old 01-07-2020 , 02:40   Re: CS1.6 RCON Player Info
Reply With Quote #5

sorry I did what you said but I did not get results. I want to make the event I need to link at the bottom. Do you want to help something like this.

I've used GAMEQ but it's a bit lacking regarding content.

https://www.csduragi.com/monitor/cs8.csduragi.net

@fyiks : So how do I link it with php. to be web-based or by recording information sql can we pull?

Last edited by xRENN1Ex; 01-07-2020 at 02:40.
xRENN1Ex is offline
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 01-07-2020 , 12:34   Re: CS1.6 RCON Player Info
Reply With Quote #6

So why not use what I sent? Does everything + supports more games if you intend on expanding outside of HL1.
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG
xRENN1Ex
Junior Member
Join Date: Dec 2019
Old 01-08-2020 , 01:59   Re: CS1.6 RCON Player Info
Reply With Quote #7

Quote:
Originally Posted by DruGzOG View Post
So why not use what I sent? Does everything + supports more games if you intend on expanding outside of HL1.
I'm using your submissions but the gameq content does not have health, team pull functions
xRENN1Ex is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode