Connection Script

From Newerth: Savage Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 05:55, 11 January 2008 (edit)
Pancake (Talk | contribs)

← Previous diff
Revision as of 06:03, 11 January 2008 (edit) (undo)
Pancake (Talk | contribs)
(Configuration)
Next diff →
Line 9: Line 9:
= Configuration = = Configuration =
Configuration is very simple. Simply go to the last few lines, and find: Configuration is very simple. Simply go to the last few lines, and find:
- //Run the above script, and connect to the server and exchange packets.+ $data = $server->getData('74.86.152.58', 11235);
- $server = new serverInfo();+ 
- +This is the only line of code required to edit. Enter the Server Address and Port Number, and that is all you need to configure it!
- //Now, display the returned packet from the server.+ 
- echo '<pre>';+Later you will see:
- print_r($server->getData('74.86.152.58', 11235)); + 
- echo '</pre>';+<pre>
- ?>+if(empty($server->error)) {
 + print_r($data);
 +} else {
 + echo $server->error;
 +}
 +</pre>
 + 
 +This checks for any errors in the script. If there are not any errors in the script, then the information retrieved from the server will be displayed.
 + 
 +However, if there are any errors, then the error will be displayed.

Revision as of 06:03, 11 January 2008

Contents

Savage 2 Server Connection Script

The Savage 2 Connection script connects to a Savage 2 server and gets information about the server. More details will be presented later

Requirements

- PHP5 (Won't work with PHP4, but it can be easily modified to work with PHP4) - Apache

Download

You may view the source Here. SImply Copy-And-Paste the code into a new PHP file.

Configuration

Configuration is very simple. Simply go to the last few lines, and find:

$data = $server->getData('74.86.152.58', 11235); 

This is the only line of code required to edit. Enter the Server Address and Port Number, and that is all you need to configure it!

Later you will see:

if(empty($server->error)) {
    print_r($data);
} else {
    echo $server->error;
}

This checks for any errors in the script. If there are not any errors in the script, then the information retrieved from the server will be displayed.

However, if there are any errors, then the error will be displayed.