01.06.2012, 16:14
Hi
I'm trying to learn a bit of socket, mainly about sa:mp protocol
I'm using the BlueG socket plugin to try to get how many players a server has and some other server info.
Do you know the game-monitor? It can get a lot of server info, as players online, map name, gamemode name, maxplayers, password needed and a lot more
So, is possible to get the same information using the socket plugin? how?
I researched a lot about the subject and I found it: http://pastebin.com/WTR6wP8V
It's a way to get some server information using the PHP plugin method, but I don't know much about PHP
I tried, but my best discovery was that this part of code is the responsable for the "socket protocol" information
but I still don't understand and don't know how to use that with BlueG socket plugin
and an other ask about socket (if some knowledgeable soul can help), socket works just with strings?
I mean, a socket is just a packet, or, a string sent to a "target" ?
if anyone has any good source of learning for noobs about socket, I would be grateful if shared
by the way, back to the main question, "what should I write on a socket to get the server information as response"?
thanks
I'm trying to learn a bit of socket, mainly about sa:mp protocol
I'm using the BlueG socket plugin to try to get how many players a server has and some other server info.
Do you know the game-monitor? It can get a lot of server info, as players online, map name, gamemode name, maxplayers, password needed and a lot more
So, is possible to get the same information using the socket plugin? how?
I researched a lot about the subject and I found it: http://pastebin.com/WTR6wP8V
It's a way to get some server information using the PHP plugin method, but I don't know much about PHP
I tried, but my best discovery was that this part of code is the responsable for the "socket protocol" information
PHP код:
$fp = @fsockopen('udp://' . $ip, $port, $errno, $errstr,3) or $this->erro($errstr,__LINE__,__FILE__,$errno);
if($fp){
$packet = 'SAMP';
$packet .= chr(strtok($ip, '.'));
$packet .= chr(strtok('.'));
$packet .= chr(strtok('.'));
$packet .= chr(strtok('.'));
$packet .= chr($port & 0xFF);
$packet .= chr($port >> 8 & 0xFF);
fwrite($fp, $packet.'i');
stream_set_timeout($fp,10);
fread($fp, 11);
$conInfo=stream_get_meta_data($fp);
if($conInfo['timed_out']){
$this->erro("Connection timed out!");
}
and an other ask about socket (if some knowledgeable soul can help), socket works just with strings?
I mean, a socket is just a packet, or, a string sent to a "target" ?
if anyone has any good source of learning for noobs about socket, I would be grateful if shared
by the way, back to the main question, "what should I write on a socket to get the server information as response"?
thanks