View Single Post
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