SA-MP Forums Archive
SA-MP Query issue - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SA-MP Query issue (/showthread.php?tid=119328)



SA-MP Query issue - Cartermcpyro - 07.01.2010

Hey. I'm using this modified code to query some SA-MP servers.
http://pastebin.com/m7a25e190

It works fine and dandy if the server is online, but if the server is offline, the script won't work. It'll hang for minutes and then you'll go to a blank page (because the server is offline I guess it's trying to send the packets but not getting a response).

So, how do I stop the script after some time and set the result to offline if the server is offline.


Re: SA-MP Query issue - adsy - 07.01.2010

Код:
$fp = fsockopen("udp://" . $ip, $port, $errno, $errstr);
if(!$fp){
echo "check 1";
}

$timeout = '30';
$fp2 = fsockopen("udp://" . $ip, $port, $errno, $errstr, $timeout);
if(!$fp2){
echo "check 2";
}

$fp3 = fsockopen("udp://" . $ip, $port, $errno, $errstr, 3);
if(!$fp3){
echo "check 3";
}

$fp4 = fsockopen("udp://123.456.789.101", "900", $errno, $errstr);
if(!$fp4){
echo "check 4";
}

$fp5 = fsockopen("udp://123.456.789.101" "900", $errno, $errstr, 3);
if(!$fp5){
echo "check 5";
}
try them on their own rather than with the rest of the scripts first, see if one of them works. replace the ip address with the one you use (and port).

do not place them in a function until you get one that works. i always have problems with functions.