admin (no pm's please) Site Admin

 Virtual Cash: 42960
Joined: 22 May 2005 Posts: 19353
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
Posted: Thu Apr 12, 2007 12:32 pm Post subject: NEVERWINTERNIGHTS2 component |
|
|
In beta, so subject to change without notice.
{MYFF.NEVERWINTERNIGHTS2}
[NEVERWINTERNIGHTS2]
title=title here
server1=server name
address1=server address
port1=5121
server2=server name
address2=server address
port2=5121
...
This seems a good opportunity to show the php code, so people can contribute their own similar components!
| Code: |
<?
function com_neverwinternights2($params)
{
global $db;
global $userdata;
global $lang;
global $images;
global $template ;
global $phpEx;
global $board_config;
global $myffcms_options;
global $HTTP_GET_VARS;
$timeout = 5;
//
// Load templates
//
$template->set_filenames(array(
strtolower($params->name) => 'cms_'. strtolower($params->name) .'.tpl')
);
if ($params->show_title== 1)
{
$template->assign_block_vars('switch_'.strtolower($params->name).'_title', array());
}
$i = 1;
$item="server$i";
while(($server = $params->$item)!= "")
{
$status="";
$error="";
$item="address$i";
$address = $params->$item;
if ($address=="") $address=$server;
$item="port$i";
$port = $params->$item;
if ($port=="") $port=5121;
$connect = @fsockopen( "udp://" . $address,$port, $errno, $errstr, $timeout );
if ( ! $connect ) {
$error = "{$errno} - {$errstr}";
$status = "offline";
} else {
socket_set_timeout( $connect, $timeout );
$send = "\xFE\xFD\x00\xE0\xEB\x2D\x0E\x14\x01\x0B\x01\x05\x08\x0A\x33\x34\x35\x13\x04\x36\x37\x38\x39\x14\x3A\x3B\x3C\x3D\x00\x00";
fwrite( $connect, $send );
$output = fread( $connect, 5000 );
if ( ! $output ) {
$error = "no response";
$status = "Error";
} else {
$lines = explode( "\x00", $output );
$players1=$lines[5];
$players2=$lines[6];
$status = $players1."/".$players2;
}
fclose( $connect );
}
$row_array = array(
'STATUS' => $status,
'SERVER' => $server,
'ERROR' => $error
);
$template->assign_block_vars(strtolower($params->name).'_row',$row_array);
$i++;
$item="server$i";
}
$template->assign_vars(array(
strtoupper($params->name).'_TITLE' => $params->title)
);
return $template->cms_pparse($params);
//End output
}
?>
|
_________________
Family Friendly Shareware | | Web Design/Services | Free Forums
forum.myfreeforum.org |
|
| Back to top |
|
 |
Stag eats Deer Pupil


Joined: 18 Mar 2007 Posts: 36 Location: Linköping, Sweden Add Karma
 rated by 0 members
Add Comment
Show Comments
 |
Posted: Tue Apr 17, 2007 6:55 am Post subject: |
|
|
what is this code doing? it doesn't seem similar to the short template nwn2 file _________________ "The early bird suffers from insomnia"

|
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42960
Joined: 22 May 2005 Posts: 19353
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
Stag eats Deer Pupil


Joined: 18 Mar 2007 Posts: 36 Location: Linköping, Sweden Add Karma
 rated by 0 members
Add Comment
Show Comments
 |
Posted: Tue Apr 17, 2007 4:44 pm Post subject: |
|
|
ok is there anyway to make some kind of player online list? like your online in the forum but on the erver? _________________ "The early bird suffers from insomnia"

|
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42960
Joined: 22 May 2005 Posts: 19353
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
Posted: Tue Apr 17, 2007 5:41 pm Post subject: |
|
|
| Stag eats Deer wrote: | | ok is there anyway to make some kind of player online list? like your online in the forum but on the erver? |
probably, but that is not what the code you supplied did!
I have provided an example of how we can implement these things, and if other code is supplied that does what you want, it can probably be incorporated. _________________
Family Friendly Shareware | | Web Design/Services | Free Forums
forum.myfreeforum.org |
|
| Back to top |
|
 |
Stag eats Deer Pupil


Joined: 18 Mar 2007 Posts: 36 Location: Linköping, Sweden Add Karma
 rated by 0 members
Add Comment
Show Comments
 |
Posted: Wed Apr 18, 2007 1:33 pm Post subject: |
|
|
ok thank you
If I find such a code I'll be noticing _________________ "The early bird suffers from insomnia"

|
|
| Back to top |
|
 |