PHP check info about a samp server - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: PHP check info about a samp server (
/showthread.php?tid=407649)
PHP check info about a samp server -
XDamienX007 - 14.01.2013
Hi!
Before starting, i must tell you i'm french, so i've a bad (very bad..) english ...
So, i've download this:
https://sampforum.blast.hk/showthread.php?tid=355574
And i added this:
PHP код:
public function getServerPassword()
{
@fwrite($this->sock, $this->assemblePacket("i"));
fread($this->sock, 11);
$serverInfo = array();
$serverInfo['password'] = (integer) ord(fread($this->sock, 1));
return $serverInfo['password'];
}
But the website tell me:
Warning: fread(): Length parameter must be greater than 0 in C:\xampp\htdocs\SampQuery.class.php on line 112
The script:
PHP код:
public function getBasicPlayers() {
@fwrite($this->sock, $this->assemblePacket("c"));
fread($this->sock, 11);
$playerCount = ord(fread($this->sock, 2));
$players = array();
if($playerCount > 0) {
for($i = 0; $i < $playerCount; ++$i) {
$strLen = ord(fread($this->sock, 1));
if(!$strLen) { echo "Problиme"; } // I've added it, and it appears correctly
$players[$i] = array
(
"name" => (string) fread($this->sock, $strLen), // Lign 112
"score" => (integer) $this->toInt(fread($this->sock, 4))
);
}
}
return $players;
}
The do the test on my computer (local) with XAMPP (yes, i've windows..)
If you must more information for help me, tell me it
Thank you in advance, and i hope you understand me!
Bye!
(Move this post if wrong section)
Re: PHP check info about a samp server -
3ventic - 14.01.2013
Why not use the default function in the package called getInfo?
Re : PHP check info about a samp server -
XDamienX007 - 14.01.2013
Because i don't know how get only password value.
I'm newbie about PHP

I learn it but i don't understand all ^^
I test different script, and i search eventually errors