liveplayers plugin works with Xaseco only v0.96b

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

liveplayers plugin works with Xaseco only v0.96b

Post by w1lla » 28 Apr 2008 17:13

This plugin used to be a work between lgrfbs and me and i thought i should test it with the new tmf release so this has confirmation that it works

Code: Select all

<?php
// Count the players for the systembar graph.
// Version: 0.0.0.1
// Beta: 0.0.0.9
// Date: 2008-03-21 to 2008-03-23
// Version History ----------------------------------------------
//.3a edited by w1lla
//.4 to .6 lgrfbs
//.7 W1lla added the nick to the .txt file
//.8 to .9 lgrfbs (.8 = Clean up .9 = Add more info and a new file output. Clean up loggdata.
//W1lla's input idea's.
// w1lla added ip to live players to find the ip adress of the player and added ladderscore.
//thinking off
// i am thinking about to add ladder nation rank to see if that might be fun.
//Also dont know if it could but parsing the liveplayers.txt to a .html
// fixed the playerminus key.
// _____________________________________________________

Aseco::registerEvent('onStartup', 'init_sp');
Aseco::registerEvent("onPlayerConnect", "PlayerPlus");
Aseco::registerEvent("onPlayerDisconnect", "PlayerMinus");

// Setup -------------------------
$SaveFolder="stat-players";
$SaveToFile=$SaveFolder."/No_of_players.txt"; 
$SaveToFile2=$SaveFolder."/Players_live.txt";
//--------------------------------
// the "$aseco->console_text" do not work here, I use "print" instead.
print "plugin.players.lgrfbs.php} start ------------------------------\n";
print "plugin.players.lgrfbs.php} Write to: ".$SaveToFile."\n";





function init_sp(&$aseco){
// Setup -------------------------
$SaveFolder="stat-players";
$SaveToFile=$SaveFolder."/No_of_players.txt"; 
$SaveToFile2=$SaveFolder."/Players_live.txt"; 
//--------------------------------
$aseco->console_text ("plugin.players.lgrfbs.php} init_sp.");
if (!is_dir($SaveFolder))
{
  $aseco->console_text ('plugin.players.lgrfbs.php} Make the folder. ['.$SaveFolder.']');
  mkdir($SaveFolder, 0777);
  $aseco->console_text ('plugin.players.lgrfbs.php} Done.');
} else {
  $aseco->console_text ('plugin.players.lgrfbs.php} The folder are allready done. - '.$SaveFolder);
}
}





function PlayerPlus(&$aseco, $player){
// Setup -------------------------
$SaveFolder="stat-players";
$SaveToFile=$SaveFolder."/No_of_players.txt"; 
$SaveToFile2=$SaveFolder."/Players_live.txt"; 
$LiveFile="1";
//--------------------------------
$aseco->console_text ('plugin.players.lgrfbs.php} PlayerPlus ');
$id=$player->id;
$login=$player->login;
$nickname=$player->nickname;
$country=$player->nation;
$ladder=$player->ladderrank;
$ip=$player->ip;
$ladderscore=$player->ladderscore;
  // Debug code
$aseco->console_text ('plugin.players.lgrfbs.php} - Debug Info --------');
$aseco->console_text ('plugin.players.lgrfbs.php} ........ID:'.$id);
$aseco->console_text ('plugin.players.lgrfbs.php} ......Nick:'.$nickname);
$aseco->console_text ('plugin.players.lgrfbs.php} .....Login:'.$login);
$aseco->console_text ('plugin.players.lgrfbs.php} ....Nation:'.$country);
$aseco->console_text ('plugin.players.lgrfbs.php} Ladderrank:'.$ladder);
$aseco->console_text ('plugin.players.lgrfbs.php} IP:'.$ip);
$aseco->console_text ('plugin.players.lgrfbs.php} LadderScore:'.$ladderscore);
$aseco->console_text ('plugin.players.lgrfbs.php} ---------------------');
//--------------------------------

$Gamers=0;
$nickname = $player->nickname;
//$aseco->console_text ('plugin.players.lgrfbs.php} Nick:'.$nickname);
$login= $player->login;
//$aseco->console_text ('plugin.players.lgrfbs.php} Login:'.$login);
   
// exist file?
if (file_exists($SaveToFile)) 
{
  $aseco->console_text ("plugin.players.lgrfbs.php} The file ".$SaveToFile." exists");
  // Read the file number of Gamers
  $Index=0;
  //Debug Code
  //$aseco->console_text ('plugin.players.lgrfbs.php} open file for reading.');
  $fp = fopen($SaveToFile, 'r');
  while(!feof($fp))
  {
   $Index=$Index+1;
   $line=fgets($fp);
   if ($Index==1){}
   if ($Index==2){$Gamers=$line;}
   //Debug code
   //$aseco->console_text ("plugin.players.lgrfbs.php} R_Gamers:".$Gamers);
   //$aseco->console_text ("plugin.players.lgrfbs.php} R_Index:".$Index);
   //$aseco->console_text ("plugin.players.lgrfbs.php} R_Line:".$line);
  }
  // Debug Code
  //$aseco->console_text ("plugin.players.lgrfbs.php} The file ".$SaveToFile." does not exist");
}
// Add a player to ...
$Gamers=$Gamers+1;
// $aseco->console_text ("plugin.players.lgrfbs.php} Gamers:".$Gamers);
// Write new data into file
$Data_01="Player: ". $login;//." Nick:".$nickname;
//$aseco->console_text ("plugin.players.lgrfbs.php} Data_01:".$Data_01);
//$aseco->console_text ("plugin.players.lgrfbs.php} Open - Write to file");
//$fp = fopen(No_of_players.txt, 'a'); //or die("can't open No_of_players.txt");
//  fwrite($fp,$SaveToFile, $Data_01."a");
//  fwrite($fp,$SaveToFile, $Gamers."a");
//fclose($fp);
system('echo '.$Data_01.' > '.$SaveToFile);
system('echo '.$Gamers.' >> '.$SaveToFile);
system('echo '.$nickname.' >> '.$SaveToFile);

// Loggfile -live-
if ($LiveFile=="1")
{
  $D = date("Y-m-d h:i:s");
  system('echo ------- '.$D.' --------- >> '.$SaveToFile2);
  system('echo ID:'.$id.' >> '.$SaveToFile2);
  system('echo Nick:'.$nickname.' >> '.$SaveToFile2);
  system('echo Login:'.$login.' >> '.$SaveToFile2);
  system('echo Nation:'.$country.' >> '.$SaveToFile2);
  system('echo Ladderrank:'.$ladder.' >> '.$SaveToFile2);
  system('echo IP:'.$ip.' >> '.$SaveToFile2);
  system('echo LadderScore:'.$ladderscore.' >> '.$SaveToFile2);  
  system('echo ------------------------------------- >> '.$SaveToFile2);
}

// more info can be puted here under.
$aseco->console_text ('plugin.players.lgrfbs.php} PlayerPlus end ------------------------------------------');
}





function PlayerMinus(&$aseco, $player){
// Setup -------------------------
$SaveFolder="/home/subfil/Aseco/plugins/stat-players/";
$SaveFolder="stat-players";
$SaveToFile=$SaveFolder."/No_of_players.txt"; 
//--------------------------------
$aseco->console_text ("plugin.players.lgrfbs.php} PlayerMinus");
$id=$player->id;
$login=$player->login;
$nickname=$player->nickname;
$country=$player->nation;
$ladder=$player->ladderrank;
$ip=$player->ip;
$ladderscore=$player->ladderscore;
  // Debug code
$aseco->console_text ('plugin.players.lgrfbs.php} - Debug Info --------');
$aseco->console_text ('plugin.players.lgrfbs.php} ........ID:'.$id);
$aseco->console_text ('plugin.players.lgrfbs.php} ......Nick:'.$nickname);
$aseco->console_text ('plugin.players.lgrfbs.php} .....Login:'.$login);
$aseco->console_text ('plugin.players.lgrfbs.php} ....Nation:'.$country);
$aseco->console_text ('plugin.players.lgrfbs.php} Ladderrank:'.$ladder);
$aseco->console_text ('plugin.players.lgrfbs.php} IP:'.$ip);
$aseco->console_text ('plugin.players.lgrfbs.php} LadderScore:'.$ladderscore);
$aseco->console_text ('plugin.players.lgrfbs.php} ---------------------');
//--------------------------------

// Read the file
$Index=0;
//$aseco->console_text ('plugin.players.lgrfbs.php} open file for reading.');
$fp = fopen($SaveToFile, 'r');
while(!feof($fp))
{
  $Index=$Index=2;
  $line=fgets($fp);
  if ($Index==1){}
  if ($Index==2){$Gamers=$line;}
  // Debug Code
  //$aseco->console_text ("plugin.players.lgrfbs.php} R_Gamers:".$Gamers);
  //$aseco->console_text ("plugin.players.lgrfbs.php} R_Index:".$Index);
  //$aseco->console_text ("plugin.players.lgrfbs.php} R_Line:".$line);
}
//$aseco->console_text ("plugin.players.lgrfbs.php} The file ".$SaveToFile." does not exist");

// Subd a player to ...
$Gamers=$Gamers-1;
if ($Gamers<0){$Gamers=0;}
//$aseco->console_text ("plugin.players.lgrfbs.php} Gamers:".$Gamers);
// Write new data into file
$Data_01="Player: ". $login;//." Nick:".$nickname;
//$aseco->console_text ("plugin.players.lgrfbs.php} Data_01:".$Data_01);
//$aseco->console_text ("plugin.players.lgrfbs.php} Open - Write to file");
//$fp = fopen(No_of_players.txt, 'w'); //or die("can't open No_of_players.txt");
//  fwrite($fp,No_of_players.txt, $Data_01."w");
//  fwrite($fp,No_of_players.txt, $Gamers."w");
//fclose($fp);
system('echo '.$Data_01.' > '.$SaveToFile);
system('echo '.$Gamers.' >> '.$SaveToFile);
$aseco->console_text ('plugin.players.lgrfbs.php} PlayerMinus end ------------------------------------------');
}
// the "$aseco->console_text" do not work here, I use "print" instead.
print "plugin.players.lgrfbs.php} End --------------------------------\n";
?>
if u have any questions or comments please leave it in this topic and for the people that dont really believe the ladderscore thingy maybe a tip of code to see that it works.

Code: Select all

plugin.players.lgrfbs.php} Ladderrank:147083
plugin.players.lgrfbs.php} LadderScore:126.43

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: liveplayers plugin works with Xaseco only v0.96b

Post by lgrfbs-sweden » 04 May 2008 16:24

Nice to see the script again, I had no time to manage the speed w1lla come with ideas. :)
Have setup a wikipage for my plugins here:
http://lgrfbs.dyndns.org/Zwiki/pmwiki.p ... secoPlugin

But if you want to be on the page so you are welcome to add to the page!
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

xpkiller
pedestrian
pedestrian
Posts: 9
Joined: 05 Jul 2009 21:14
Owned TM-games: TMUF

Re: liveplayers plugin works with Xaseco only v0.96b

Post by xpkiller » 05 Jul 2009 21:34

Hello, I'm new here in the forum and have already had some experience here, now I have a question. I have this plugin installed and it runs fine. Now I would like in the game in a Navbutton the player (Nick) show who are online. Is that with this plugin to make? Unfortunately, I have no idea what I have to do? thanks for an answer. my server run with xaseco 1.09

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: liveplayers plugin works with Xaseco

Post by lgrfbs-sweden » 06 Jul 2009 11:57

I have update this script so it works under Xaseco 1.09 but if you only run the xaseco plugin on the server and not added the perl script in crontab on you server you will only get a textfile with all players in/out log on that server. This plugin package have 2 parts as must be installed for it to work as it was intended.

This plugin do nothing with the navbar, then you run lgrfbs.player.count.php & sysinfo.pl you will get this:
Image
But with yours server data of course.
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

xpkiller
pedestrian
pedestrian
Posts: 9
Joined: 05 Jul 2009 21:14
Owned TM-games: TMUF

Re: liveplayers plugin works with Xaseco only v0.96b

Post by xpkiller » 06 Jul 2009 20:20

Thank you for the quick reply. :thumbsup:
My server runs on Windows, unfortunately without perl.
Greeting xpkiller

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: liveplayers plugin works with Xaseco only v0.96b

Post by lgrfbs-sweden » 06 Jul 2009 23:32

Perl can be run on windows and windows have scheduler so you can use the perl script this way in windows to.
See for exempel:
http://www.microsoft.com/windowsxp/usin ... efrag.mspx
http://www.nncron.ru/
http://www.pcreview.co.uk/forums/thread-515864.php
http://perl.about.com/od/gettingstarted ... erlwin.htm

Have fun and good luck!
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

Post Reply