Page 1 of 1

plugin visitor counter

Posted: 29 Aug 2010 08:34
by jouko100
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));

}
?>

Re: plugin visitor counter

Posted: 03 Sep 2010 19:41
by mww
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?

Re: plugin visitor counter

Posted: 03 Sep 2010 20:44
by Gekko
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.
;)

Re: plugin visitor counter

Posted: 03 Sep 2010 22:47
by mww
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

Re: plugin visitor counter

Posted: 04 Sep 2010 03:29
by jouko100
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.

Re: plugin visitor counter

Posted: 04 Sep 2010 09:32
by mww
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?

Re: plugin visitor counter

Posted: 04 Sep 2010 09:52
by Gekko
Delete the part from:

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

and you are ok. :D

Re: plugin visitor counter

Posted: 06 Sep 2010 14:19
by Greco
very good

Re: plugin visitor counter

Posted: 08 Sep 2010 18:43
by nocturne
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.

Re: plugin visitor counter

Posted: 09 Sep 2010 04:08
by Yorkshire
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.

Re: plugin visitor counter

Posted: 09 Sep 2010 05:53
by jouko100
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