Raised This Month: $51 Target: $400
 12% 

Trash this one


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
omer
Senior Member
Join Date: Nov 2011
Old 04-16-2012 , 05:00   Trash this one
Reply With Quote #1

Trash this one

Last edited by omer; 05-08-2012 at 10:52.
omer is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-16-2012 , 07:48   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #2

PHP Code:
<?php

require_once('JG_Cache.php');
require_once(
'SourceQuery.class.php');

$servers = array(
// add servers like this:
//'server_01' => array ('name' => 'My shitty server', 'ip' => 'abc.example.com', 'port' => '27015'),
//'server_02' => array ('name' => 'My crap server', 'ip' => '1.2.3.4', 'port' => '27015'),
  
'server_03' => array('name' => 'My awesome server''ip' => 'dks.servehalflife.com''port' => '27016')
);


foreach (
$servers as $server) {

  
$cache = new JG_Cache('/tmp');
  
$info $cache->get($server['name'], 60); // second paramater = cache time in seconds

  
if ($info === false) {
    
$query = new SourceQuery();
    try {
      
$query->Connect($server['ip'], $server['port']);
      
$info $query->GetInfo();
    } catch (
SourceQueryException $e) {
      
$info $e->getMessage();
    }
    
$cache->set($server['name'], $info);
  }

  if (
is_array($info)) {
    echo 
'<div style="color:#fff;">' $server['ip'] . ':' $server['port'] . ' | map: ' $info['Map'] . ' | players: ' $info['Players'] . '/' $info['MaxPlayers'] . '</div>';
  }
  else {
    echo 
'<div style="color:#ff0000;">' $server['ip'] . ':' $server['port'] . ' (offline)</div>';
  }
}
Requires these two classes:in the same directory.

I didn't add the id, because that will be a problem if you add more servers (ids need to be unique). Use a class instead.
__________________
steamID converter with OpenSearch browser plugin

Last edited by 8088; 04-16-2012 at 07:59. Reason: err0r
8088 is offline
matrixmark
Senior Member
Join Date: Jun 2010
Old 04-27-2012 , 08:03   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #3

Thanks for posting this 8088 it's pretty awesome and almost what I was looking for

Just wondering is there anyways for this to be able to find the player names that are in server? and display them?

If not no biggie but just wondering.

Thanks again.
matrixmark is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-27-2012 , 08:15   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #4

Quote:
Originally Posted by matrixmark View Post
Thanks for posting this 8088 it's pretty awesome and almost what I was looking for

Just wondering is there anyways for this to be able to find the player names that are in server? and display them?

If not no biggie but just wondering.

Thanks again.
Yes. Read readme for more information.
https://github.com/xPaw/PHP-Source-Query-Class
__________________
xPaw is offline
matrixmark
Senior Member
Join Date: Jun 2010
Old 04-28-2012 , 15:56   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #5

Quote:
Originally Posted by rx1983 View Post
this my model server status:
http://www.csro.com.br/servidores/index.php
NIce is that a custom one you made? or a publicly available one?
matrixmark is offline
omer
Senior Member
Join Date: Nov 2011
Old 05-09-2012 , 08:44   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #6

Quote:
Originally Posted by rx1983 View Post
this my model server status:
http://www.csro.com.br/servidores/index.php
Can you give me this one?
__________________

omer is offline
matrixmark
Senior Member
Join Date: Jun 2010
Old 05-09-2012 , 08:49   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #7

Quote:
Originally Posted by omer View Post
Can you give me this one?
I doubt very much he will do that lol. Not one like that anyways and very unlikely for free.
matrixmark is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 05-09-2012 , 09:51   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #8

Quote:
Originally Posted by omer View Post
Can you give me this one?
Why are you still asking for help in a thread that you want trashed?
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-16-2012 , 08:17   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #9

@8088, my class recently was updated and it requires $Engine param to be set in Connect(), so you might want to edit that. It defaults to Source.
__________________

Last edited by xPaw; 04-16-2012 at 08:18.
xPaw is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-16-2012 , 08:28   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #10

I noticed the change, but don't they all use the same protocol, except for HLTV?
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
Reply



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 -4. The time now is 10:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode