Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-31-2008, 03:21 PM php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
Okay been searching the net for a while now and all i turn up is linux version nothing with will run remotely or with windows

What I am trying to do is create a script for my clan site, (i've asked this before yes i know but it wasnt fully answered) that on the site it will connect to the specific server defined (I have 2) and gather some important details.

IE, host name, game type, max players, current players, time on the server for current players, current map, frags for current players, and list which mods are currently running(not so important on the last one)

so this way when people go to my website they see for example

Server A
Game : CS
Players : 5/14 (View current players) (<- link there)
Current Map : de_dust2
Time Remaining : 15mins and 24 seconds

Then the same with server b.

I know i have to use fsock i beleive to interact with the server on UDP port 27015. I found this but i dont understand that at all hxxp://www.valve-erc.com/srcsdk/Code/Networking/serverqueries.html#A2S_INFO

I figure the easist way to do the initial connect is with functions as this will allow me to add more servers down the road if i wish.

And I am not at all to familar with object programing yet, still to **** confusing for me so i just stick with functions and other non object based programming in php.

Hope some one has experiance with php.

and btw, uA Php admin script dont work on php5 and hardly works on php4. (which i dont use any more)
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
 
Register now for full access!
Old 02-01-2008, 11:57 AM Re: php and hlds
Extreme Talker

Posts: 182
Trades: 0
I was excited to read your post. I recently worked on a project that made use of the Master Server Query Protocol. That is the protocol you are looking for. It's fun stuff!

Master Server Query Protocol
http://developer.valvesoftware.com/w...Query_Protocol

This site uses it to pull live data:
http://gametiger.net/

Helpful pre-built scripts:
http://warsow.fatalerror.be/projects/php/
http://gameq.sourceforge.net/ - This should be what you need!

This can be complicated if you are writing the code from scratch, as I did. I spent many hours googling and reading before I even halfway understood the protocol. You're best bet is probably going to be GameQ. Take some time to read through everything on the GameQ site that I linked you to. It should be really easy to implement into your clan site. If you have any problems, please post back!

Good Luck!
bhgchris is offline
Reply With Quote
View Public Profile
 
Old 02-01-2008, 03:31 PM Re: php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
actually at 2am last night after 8-10 hrs of just writing out the base code and help on another forum with a c++ script that was posted helped me complete it nicely.

I got it working in the bare bones form and am in the process of getting the independent player data now.

You can see if it works for you on my site http://amwclan.exofire.net/test/inde...erver=p3x-m249

It is bare bones now, i will take a look at the gameq for ideas.

This was my first venture in to using classes and so for is intersting. but it uses rcon to query the server for the information. so far looking good.

I also put in a few if / else statments that will detect if the visitor is on the internal lan if the server is a home based dedicated and allow the owner to query the server from the web from the same computer. I havent tried from the web yet, but it is working for me.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 02-01-2008, 11:59 PM Re: php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
okay i was working on it today ironing out the bugs and all, and impleting a simple template system to make it so users could adapt it when i go and release it. and now i am getting an error on line 301

error
Code:
Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\amw\sources\gameserver\classes\serverclass.php on line 301
Code
PHP Code:
    function parse$parse_array $template ) {
        
$fp fopen($template'r');
        
$html fread($fpfilesize($template));
        
fclose($fp);
        
clearstatcache();
        foreach (
$parse_array as $key => $value) {
            
$key "###" $key "###";
            
$html str_replace$key $value $html );
        }
        return 
$html;

    } 
Above function is called by this
PHP Code:
    function maintpl()
    {
        
$this->curtpl $this->tplpath.$this->tplmain;
        
$this->ServerInfo();  // This returns the the $parse_array
        
$data $this->parse$parse_array$this->curtpl );
    } 
I think it is because the array isnt getting returned correctly, im gonna fool with it, but if you guys got any ideas/thoughts that would be greatly appreciated.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 02-02-2008, 12:16 AM Re: php and hlds
Extreme Talker

Posts: 182
Trades: 0
I'm glad you got your problem solved. Post back if you run into any problems.

You are exactly right about the error, the array is not being passed.

PHP Code:

    
function maintpl()
    {
        
$this->curtpl $this->tplpath.$this->tplmain;

        
# You are not setting this call = to $parse_array...
        # $parse_array = $this->ServerInfo(); <- what you need
        
$this->ServerInfo();  // This returns the the $parse_array

        # ...So when you get here, $parse_array is empty.
        
$data $this->parse$parse_array$this->curtpl ); // 
    

During debugging, it usually helps to have all errors being reported.

http://php.net/error_reporting

Put something like this at the top of your header file:
PHP Code:
# Set error reporting level
error_reporting E_ALL ); 
This will save you a lot of headache.

The above error_reporting setting would have told you that $parse_array was undefined.
bhgchris is offline
Reply With Quote
View Public Profile
 
Old 02-02-2008, 02:34 AM Re: php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
meh still cant get the thing to work right, i changed the error reporting to E_ALL. now the page is blank.

A fresh set of eyes in the AM may help. any more ideas/thoughts
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 02-02-2008, 03:33 AM Re: php and hlds
Extreme Talker

Posts: 182
Trades: 0
Did you also add $parse_array = $this->ServerInfo();?

Yes, usually leaving and coming back will fix the problem
bhgchris is offline
Reply With Quote
View Public Profile
 
Old 02-02-2008, 10:45 AM Re: php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
yea i did, now it is just blanking out, i just woke up. gonna reread the code and see if i can find the problem

HA figured out why it was blanking out, the call to connect to the server got deleted. -_- now on to that pesky players list
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1

Last edited by amw_drizz; 02-02-2008 at 11:08 AM.. Reason: prevent double post
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 02-09-2008, 01:39 PM Re: php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
I been working on this script and I think it is to a point that I can release it to the public as beta

You can find the sourceforge.net file list here http://sourceforge.net/project/showf...roup_id=217231

I will keep that updated with the new version that i release.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 03-12-2008, 09:50 PM Re: php and hlds
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
This is pointed towards someone who fully understands the Valve Server Query Protocols.

Right now I am requiring the use of the rcon password to get server status, And I know there is a way to get the same form of information with out the use of an rcon password. As I understand that some people may be reluctant to share such of information in a config file even though it isn't publicly viewable.

How would I change something like this

PHP Code:
$command "\xff\xff\xff\xffrcon $this->challenge_number \"$this->server_password\" $command\n"
to something that would not require the rcon password? This is so I can remove the rcon password requirement
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to php and hlds
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35390 seconds with 12 queries