Jump to content

Visitor Count + Active Visitor?


Recommended Posts

Hello again! Another question for the Oak Log.

I was wondering if it would be possible to add a visitor counter (and I don't mean one of those horrendous neon colored ones usually offered online. Something more classy, and MD fitting? Tan toned) and an active visitor notifier?

So essentially at the bottom of the main page you would be able to see how many people are reading it, or how many people have read it. Does that make sense?

Thank you.


Link to comment
Share on other sites

That should be possible already, at least in my head it is.

If you set a variable to be 0, then run +1 on it, and display the....hmm lemme see if i can write it

@va==0 //sets variable

if (uv(mp) => 2){ //cos i cant think of how else to do this
@va + 1 = @vb; //adds one on when page visited

echo "You are the " @vb " visitor"; //prints the number of visitors

or something....doubt this works, but basic idea anyway

Edited by Grido
Link to comment
Share on other sites

Grido, you're on the right track. You are only missing the persistent storage.

Indiscriminantly count visitors:
[code]//get vistor count from storage
//check to see if the counter has previously been set
if(isset(@vv) && (@vv > 0)){
//increase counter by 1
++@vv ;
//initiliaze counter (initialize to 0 if you don't want to count your first view of the clickable)
@vv = 1;
//save the counter to storage
//output the information you want
echo "There have been " . @vv . " visitors here";[/code]

Here's an example of counting unique visitors and number of visits by each player, based on the player id:
[code]//get vistors from storage
//see if array is already initialzed and if user has already visited
if(@vv != null && (@vv['uv(id)'] > 0)){
//increment the player's visits
echo "You have visited here " . @vv['uv(id)'] . " times<br />";
//initiliaze the player's visists
@vv = array('uv(id)' => 1);
echo "This is your first visit<br />";
//save the visitors to storage
echo "There have been " . count(@vv) . " unique visitors here";[/code]

Regarding the styling, wrap the output in a div and style as you desire.

Edited by Rendril
Link to comment
Share on other sites

After a long talk and some coding, we produced the following:

@vo = mds_storage("OAKSTORYLOG", "toau"); //retrieving the int label for the variable
if(@storage[@vo] == null){//initializing the stored array if not already done.
@storage[@vo] = array(0, array());
@storage[@vo][0]++; //increment the general counter (total people)
if(@storage[@vo][1][uv(id)] != null && (@storage[@vo][1][uv(id)] > 0)){//check if it is instantialized or not
@storage[@vo][1][uv(id)]++;//increment personal counter
@storage[@vo][1][uv(id)] = 1;//if the personal counter doesn't exist, create one.
//replacing things in the content panel.
@content[1] = str_replace("[[NAME]]", uv(name), @content[1]); //replaces [[NAME]] with name of current viewer
@content[1] = str_replace("[[COUNT]]", @storage[@vo][0], @content[1]); //replaces [[COUNT]] with total visitors
@content[1] = str_replace("[[UNIQUE]]", count(@storage[@vo][1]), @content[1]);//replaces [[UNIQUE]] with unique visitors
@content[1] = str_replace("[[YOURVISITS]]", @storage[@vo][1][uv(id)], @content[1]); //replaces [[YOURVISITS]] with your personal count.
echo @content[1];[/code]

It keeps track of three things:
1. Total visits
2. Unique visits
3. Your personal visits.

In the Content panel, make sure you have something like the following:

<!-- content separator -->
Hello [[NAME]]<br><br>
There have been [[COUNT]] visits in total, and [[UNIQUE]] people have visited.<br><br>
You have visited [[YOURVISITS]] times.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    Total Topics
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

  • Create New...