Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 30.09.2005, 12:23   #1
montejo1974
Архивный участник
 
Join Date: Aug 2005
Posts: 42
Default [Share] Showing number of players ingame

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.

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.

Code:
<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.
montejo1974 is offline  
Old 30.09.2005, 13:26   #2
Metalmurphy
Архивный участник
 
Join Date: Feb 2005
Posts: 766
Default

Actually this has been done before
Metalmurphy is offline  
Old 30.09.2005, 14:00   #3
BiGBoY
Архивный участник
 
Join Date: May 2005
Posts: 216
Default

what is ur announce_id=3 interval?
BiGBoY is offline  
Old 30.09.2005, 15:07   #4
montejo1974
Архивный участник
 
Join Date: Aug 2005
Posts: 42
Default

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.
montejo1974 is offline  
Old 30.09.2005, 15:20   #5
Metalmurphy
Архивный участник
 
Join Date: Feb 2005
Posts: 766
Default

You could search it your self u know?

https://postpacific.loc-online.com/f...nline+announce
Metalmurphy is offline  
Old 30.09.2005, 15:35   #6
montejo1974
Архивный участник
 
Join Date: Aug 2005
Posts: 42
Default

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
montejo1974 is offline  
Old 30.09.2005, 16:44   #7
Metalmurphy
Архивный участник
 
Join Date: Feb 2005
Posts: 766
Default

No no i didnt say it was stupid Only that it was done before, and it could have saved you time
Metalmurphy is offline  
Old 30.09.2005, 17:55   #8
Osito2Dancer
Архивный участник
 
Join Date: Mar 2005
Posts: 442
Default

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
Osito2Dancer is offline  
Old 30.09.2005, 20:07   #9
rodier
Архивный участник
 
Join Date: May 2005
Posts: 979
Default

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?
rodier is offline  
Old 30.09.2005, 22:47   #10
BiGBoY
Архивный участник
 
Join Date: May 2005
Posts: 216
Default

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).
BiGBoY is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 20:59.