plugin visitor counter

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
jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

plugin visitor counter

Post by jouko100 » 29 Aug 2010 08:34

name plugin to players.php and put it to plugins dirtectory and add line <plugin>players.php</plugin> to plugins.xml

example http://yfrog.com/n960352038p

Code: Select all

<?php
Aseco::registerEvent('onPlayerConnect', 'PComing');

global $buttonmainposition;

$buttonmainposition = '-50 -30 1';


function PComing($aseco, $player){

global $hits;
 
// hits**********************************************************************
//make file at first time**************************************************
$log = 'hits.txt';
if (!file_exists($log)) {
$avaa = fopen($log, "w");
fwrite($avaa, "0");
fclose($avaa);
}

$myFile = "hits.txt";
$fh = fopen($myFile, 'r');
$hits = fread($fh, filesize($myFile));
fclose($fh);

$hits=$hits+1;

//save hits*******************************
$log = 'hits.txt';
$avaa = fopen($log, "w");
fwrite($avaa, $hits);
fclose($avaa);
//*******TOTAL PLAYERS****************************

$xml = '<manialink id="081547000012233">


      <format style="TextCardInfoSmall" textsize="1" />

      <frame posn="'.$buttonmainposition.'">

 
//TOTAL players****************************************************************
 <label posn="55 -31.8 1" sizen="5 2" halign="center" valign="center" text="$i$s$f00'.$hits.'" action="1270085103"/>
<label posn="55 -29.8 1" sizen="5 2" halign="center" valign="center" text="$i$s$f00Visitor counter" action="1270085103"/>




      </frame>

   </manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));

}
?>

mww
wheelbarrow operator
wheelbarrow operator
Posts: 15
Joined: 27 Aug 2010 15:54
Owned TM-games: TMU

Re: plugin visitor counter

Post by mww » 03 Sep 2010 19:41

There have to be some misteake.
when the number of players is 10, when he add one more to hits there is 2 next... i think that it is reading only one bit from file but i dont know how to fix it.

anybody can help?

Gekko
speedy pilot
speedy pilot
Posts: 550
Joined: 03 Sep 2006 18:20
Owned TM-games: ALL
Location: Naples - Italy
Contact:

Re: plugin visitor counter

Post by Gekko » 03 Sep 2010 20:44

A suggestion:

Use the Xml Parser, iuncluded in the xaseco, to do a file with only 1 line inside
<num_players>8</numplayers>

Is very easy to use it.
You can look at the declaration of the function to understand fow to use it.
You can PARSE the $num_players variable in this way:

$num_players['PLAYERS'][0] = the number you get from connections and from disconnections
And save it after parsing each time, or when you want.

You can also do a long XML file with time and dates:
<hour>12</hour>
<players>15</players>

doing a long file and using ParseArray($file) you can do a long stat based on hour.
You need only the imagination to develope new ideas.
;)

mww
wheelbarrow operator
wheelbarrow operator
Posts: 15
Joined: 27 Aug 2010 15:54
Owned TM-games: TMU

Re: plugin visitor counter

Post by mww » 03 Sep 2010 22:47

Any other suggestions? I didn't understand what to do.

If anybody can tell me step by step (I spoked with Gekko, and unforetunatly he dont have time couse of TPS ;D) what to do or have simplier explanation or easier way plz write here or contact me.

Thanks in advance

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: plugin visitor counter

Post by jouko100 » 04 Sep 2010 03:29

if u restart xaseco and server is running it counts players in server as new players.Not big deal and i cant handle it.
if there is players in server,dont restart xaseco.This is only bug what i know.
I dont understood gekko neither.

mww
wheelbarrow operator
wheelbarrow operator
Posts: 15
Joined: 27 Aug 2010 15:54
Owned TM-games: TMU

Re: plugin visitor counter

Post by mww » 04 Sep 2010 09:32

I need only visits counted in file, i dont need on screen so i did that:

Code: Select all

<?php
Aseco::registerEvent('onPlayerConnect', 'PComing');

global $buttonmainposition;

$buttonmainposition = '-50 -30 1';


function PComing($aseco, $player){

global $hits;

// hits**********************************************************************
//make file at first time**************************************************
$log = 'hits.txt';
if (!file_exists($log)) {
$avaa = fopen($log, "w");
fwrite($avaa, "0");
fclose($avaa);
}

file_put_contents($log,file_get_contents($log)+1);

//*******TOTAL PLAYERS****************************

$xml = '<manialink id="081547000012233">


      <format style="TextCardInfoSmall" textsize="1" />

      <frame posn="'.$buttonmainposition.'">


//TOTAL players****************************************************************
<label posn="55 -31.8 1" sizen="5 2" halign="center" valign="center" text="$i$s$f00'.$hits.'" action="1270085103"/>
<label posn="55 -29.8 1" sizen="5 2" halign="center" valign="center" text="$i$s$f00Visitor counter" action="1270085103"/>




      </frame>

   </manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));

}
?>
So how to turn off visible icon on xaseco?
Last edited by mww on 04 Sep 2010 09:54, edited 1 time in total.

Gekko
speedy pilot
speedy pilot
Posts: 550
Joined: 03 Sep 2006 18:20
Owned TM-games: ALL
Location: Naples - Italy
Contact:

Re: plugin visitor counter

Post by Gekko » 04 Sep 2010 09:52

Delete the part from:

$xml ....... to ..... false));

and you are ok. :D

Greco
happy cruiser
happy cruiser
Posts: 144
Joined: 13 May 2009 18:40
Owned TM-games: TMN

Re: plugin visitor counter

Post by Greco » 06 Sep 2010 14:19

very good

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: plugin visitor counter

Post by nocturne » 08 Sep 2010 18:43

I don't get it... it doesn't count the actual number of visitors, but rather the amount of connections -- in a week we can easily get 10k connections, with perhaps only a few hundred unique players.

If you want actual info instead of useless info for bragging rights, you might as well just use the count of lines from the players table, which would show the actual amount of unique visitors.
Chief Janitorial Supervisor of the Let'sRock! TM community : www.LetsRock-TM.com

Yorkshire
smooth traffic navigator
smooth traffic navigator
Posts: 192
Joined: 21 May 2008 08:39
Owned TM-games: TMUF

Re: plugin visitor counter

Post by Yorkshire » 09 Sep 2010 04:08

Yeah, what nocturn said. Isn't there also a last connected time/date in players (at work so can't check)?

If there is you could make it do whatever you want, like last day/week/hour etc.

Much better.

Cheers.

Nick.

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland

Re: plugin visitor counter

Post by jouko100 » 09 Sep 2010 05:53

nocturne wrote:I don't get it... it doesn't count the actual number of visitors, but rather the amount of connections -- in a week we can easily get 10k connections, with perhaps only a few hundred unique players.

If you want actual info instead of useless info for bragging rights, you might as well just use the count of lines from the players table, which would show the actual amount of unique visitors.
yes it counts connections like it is supposed to do

Post Reply