PDA

View Full Version : [Share] Showing number of players ingame


montejo1974
30.09.2005, 12:23
Hi people:

My (our) first share:

This weird php only show the number of players ingame, and maybe some people think that is an stupid idea...but I am not good making geodata so I share this :P

It is based, on a well formed SQL process that refresh the message. So if someone want the SQL part please PM. I suppose you can do it yourselves. :D

On other way, I know is less efficient that it would be....but I have two jobs, a wife and an incoming son (just only 30 days more!!!), and again, I am not very good on making geodata (our first goal on the server) so maybe this weekend I optimize it, and post it later.

<meta http-equiv="refresh" content="60">
<?php
$ip = "localhost";
$port = "2009";
$conn = mssql_connect ("127.0.0.1", "user", "pass");
$db = mssql_select_db ("lin2world");
$sql = "select announce_msg from login_announce where announce_id=3";
$result = mssql_query ($sql, $conn);
if (mssql_fetch_row($result))
{
$com="50;1;3;".mssql_result($result, 0,0);
}

$mess = "Status:";
$fp = fsockopen($ip, $port, $errno, $errstr);
if (!$fp)
{
$mess .= "Error: <font color=red>$errstr ($errno)</font>";
}
else
{
$out = str_replace(";", "\t", $com)."\r\n";
fwrite($fp, $out);
stream_set_timeout($fp, 2);
$answ = fgets($fp, 8);
if ($answ == 1 and strlen($answ) == 1)
{
$mess .= "<font color=yellow>Respuesta de CacheD: {$answ}</font>";
}
else
{
$mess .= "<font color=red>Error. Respuesta de CacheD: {$answ}</font>";
}
fclose($fp);
}

echo $mess;
?>

Ok, so that's all folks!

P.D.:Yes, I know my english sounds very spanish (and is not good), but I am from Spain.

Metalmurphy
30.09.2005, 13:26
Actually this has been done before ;)

BiGBoY
30.09.2005, 14:00
what is ur announce_id=3 interval?

montejo1974
30.09.2005, 15:07
Metalmurphy: Sorry, could you tell me the posts where has been done before??

BigBoy: The "announce_id=3" is the record where I put the message to show, and I think that metalmurphy is going to post the topic soon ;)

Basically, this maintain the message actualized. The other post tell how to calculate the number of users playing (I think), although I calculate the number on a different way, as I did it before that post.

Metalmurphy
30.09.2005, 15:20
You could search it your self u know? :p

https://postpacific.mmorpg-game.online/forum/viewtopic.php?t=1461&highlight=online+announce

montejo1974
30.09.2005, 15:35
I reassert myself...thats the way to do it one time, now with this it's every minute, so if this is a stupid share sorry and please tell me so my next share will be better (a photo of my incoming son, of course) :P

Metalmurphy
30.09.2005, 16:44
No no i didnt say it was stupid :p Only that it was done before, and it could have saved you time ;)

Osito2Dancer
30.09.2005, 17:55
You know theres a table in Lin2world that records how many players there are? That's a lot of "computer-time-saving" method for retrieving the info. No need for SQL triggers and such, just a simple "select user_count from asdafasa" ^^

Oso

rodier
30.09.2005, 20:07
hmm I tried the old script one time and announce table going to hell... because script fullfill that table with something weird ;]

but how this script work? its manual script? I want script that write announce with actual ppl online every X minutes.. I think this put actual status only when you manually launch it.. or not?

BiGBoY
30.09.2005, 22:47
Yes Rodier thats why i was asked for interval, bcoz i never managed to set announce to automaticaly show in predefined interval. All it happened was that it changed in login_announce the value and was shown to players which just loged in to game (at interval=0).