SRCDS Steam group


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HLTV controled by php
#1
I'm not good at working with sockets, but I search some websites and try to create php script, which will send commands to hltv(half life 1) via php. But something seems to be wrong because hltv on my pc doesn't do anything when I send some command.

So here is my code:

PHP Code:
//get challenge from HLTV
$cmd "\xFF\xFF\xFF\xFF"."challenge rcon"."\n";
$getchallenge getServerData($cmd'89.173.135.189''27020');
$getchallenge substr($getchallenge5);
$getchallenge trim($getchallenge);

HalfLife_Rcon('myHLTVIPadress''myHLTVport''myHLTVrcon''record test.dem'$getchallenge);

function 
GetServerData($command$ip$port)
{

    
$data '';
    if (!
$server_connection fsockopen('udp://'.$ip$port))
        return 
false;

    
socket_set_blocking($server_connection1);
    
# Time out after 5 seconds
    
socket_set_timeout($server_connection5);
    
fwrite($server_connection$commandstrlen($command));    

    
# This must time out first to make sure the right arguement is returned
    # The above timeout is just to make sure it doesn't go over 4 seconds
    
$timeout microtime();
    
$timeout += 4;
    
$i 0;
    
$packets 0;
    do
    {
        do
        {
            
$data .= fread($server_connection8192);
            if (
microtime() > $timeout)
            {
                
# Connection timed out
                
fclose($server_connection);
                return 
false;
            }
            
$data_status socket_get_status($server_connection);
        }
        while (
$data_status['unread_bytes']);
        if (
GetInt8($data$tmp 0) == 254)
        {
            
# We have a split packet!
            
$tmp 0;
            
# Get rid of the crap at the start
            
GetInt32($data$tmp);
            
GetInt32($data$tmp);
            
$split_packet str_pad(DecBin(GetInt8($data$tmp)), 80STR_PAD_LEFT);
            
$packet_num bindec(substr($split_packet04));
            
$packets bindec(substr($split_packet4));
            
$data substr($data$tmp);
            
$packet_data[$packet_num] = $data;
            
$data '';
        }
        elseif (
$packets 0)
        {
            
# Silly rcon problems
            
$tmp 5;
            
# Get rid of the crap at the start
            
$data substr($data$tmp);
            
$packet_data[] = $data;        
        }
        
        
$i++;
    }
    while (
$i $packets);
    
fclose($server_connection);

    if (
$packets 1)
    {
        
ksort($packet_data);
        
$data implode(''$packet_data);;
    }
    if (
strlen($data) == 0)
    {
        
# We got no data?! Something must have gone wrong
        
return false;
    }

    return 
$data;
};

function 
HalfLife_Rcon ($ip$port$rcon$command$challenge)
{

    
$cmd "\xFF\xFF\xFF\xFFrcon ".$challenge." ".$rcon." ".$command;

    if (!
$serverdata getServerData($cmd$ip$port))
        return 
false;

    
$serverdata substr($serverdata5);
    
$serverdata trim($serverdata);

    return 
$serverdata;
};

function 
getInt8($pos,$string) {
    if (
strlen($string) > $pos) {
        
$packarray unpack('Ci',substr($string,$pos,1));
        return 
$packarray["i"];
    } else {
        return 
0;
    }
}; 

I only tryed to re-programm code to control hlds server, but when I run this php script, it will show no error but also hltv will not responding for my messages. (sorry for my bad english)

Thanks for help.
Reply
#2
I love how informative this blog. looking forward for more blogs like this roofing contractor cedar rapids
Reply
#3
Man's lives, such as uncontrolled huge amounts, definitely not while countries furthermore reefs, challenging to seismic disturbance upward perfect apply. asia999
Reply
#4
PHP is a scripting language that is used on the server side of a web site, or local application. One of my friends asked me to bestessays to complete my assignments on time. It is executed by a web server or local application and returns HTML or XML to the client. PHP has many features that allow you to create dynamic web sites and applications.
Reply
#5
Well I have been reading a lot of content here lately and I am liking it. This time i read www.signnow.com/ask/detailed-guide-on-how-to-sign-a-pdf-online-in-signnow and it was good information. I got to know a lot about pdf.
Reply
#6
I've been asking myself the question of why airslate for quite the while now, and I can finally answer it. It's the best service provider you can find, and once you end up on https://www.airslate.com/product/create-web-forms, you'll have quite the idea of what I'm talking about. It's a beast of a service provider all in all.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)