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

Solved Get players and steam id with php rcon


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-15-2020 , 06:11   Re: Get players and steam id with php rcon
Reply With Quote #11

Ok so i use this code now.
PHP Code:
<?php
require 'SourceQuery.class.php';    
$Query = new SourceQuery( );
    
try
{
$Query->Connect'SERVER IP'27015 );        
$Query->SetRconPassword'RCON PASSWORD' );     
       
$YourStatusString $Query->Rcon'status' );    

function 
parse_hlds_status($StatusString)
{
    
// parse everything up to the player list
    
$StatusArray preg_split("/(\r\n|\n|\r)/"$StatusString);
    
    
$out['hostname'] = array_shift($StatusArray);
    
$out['version'] = array_shift($StatusArray);
    
$out['tcp/ip'] = array_shift($StatusArray);
    
$out['map'] = array_shift($StatusArray);
    
$out['maxplayers'] = array_shift($StatusArray);
    
    
array_shift($StatusArray); // Get rid of blank line
    
    // Parse player list
    
$PlayerListString $StatusArray// Including header row
    
array_pop($PlayerListString);
    
    
// Parse headers
    
$header str_getcsv(array_shift($PlayerListString), $delimiter " ");
    
    
// Parse players
    
$PlayerList array_map('parse_player_line'$PlayerListString);
    
array_walk($PlayerList'_combine_array'$header);
    
    
$out['Players'] = $PlayerList;
    
    return 
$out;
}

// Define private functions
function _combine_array(&$row$key$header)
{
    
$row array_combine($header$row);
}

function 
parse_player_line($string)
{
    
$temp str_getcsv($string$delimiter " ");
    
array_shift($temp);
    return 
$temp;




print_r(parse_hlds_status($YourStatusString)); 
    


$Query->Disconnect( );
    }
catch( 
SQueryException $e )
    {
$Query->Disconnect( );
    }
echo 
'';
?>
Getting this error.
PHP Code:
Warningarray_combine(): Both parameters should have an equal number of elements in mywebsite.com/public_html/rcon/ServerRcon.php on line 43 
Line 43 is this code.
PHP Code:
    $row array_combine($header$row); 
4ever16 is offline
 



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 02:22.


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