WorldTimeTracker

Description

Tracks the time a player spends in each world into an SQL database, useful for giving people different rewards or ranking them up, etc...

WorldTimeTracker is designed to be extremely simple, it stores only what it needs to store, items stored are:

  • Player Name
  • World Name
  • Total Time spent in world

The plugin tracks the total time spent based on a variety of factors, when the player logs onto the server, an in-memory object is set up that matches the table structure, except instead of total time, it merely tracks when they logged on in that particular world.

When the player disconnects, it takes the difference between their connection in that world and their disconnection from that world and adds that to their record in the SQL database.

When the player changes to another world, it goes through the same motions as a disconnection, and then the same motions as a connection but using the new world information.

There should be extremely minimal impact from this plugin, since it only ever updates the SQL database when the player changes worlds or disconnects.

Configuration

config.yml

  • MySQLServer: localhost
  • MySQLPort: '3306'
  • MySQLUsername: <username for db>
  • MySQLPassword: <password for db>
  • MySQLDatabase: <database to use>
  • MySQLTable: <table to use>
  • showDebug: true|false

As per my other plugins that utilise SQL, this plugin will automatically create the table if it doesn't exist, and any table changes that occur in future releases will auto-update the existing table.

Example Usage

Depending on what you want to do, because of how the information is stored, retrieving specific information is very easy, and retrieving total information for a player is also very easy.

One Player - One World

SELECT * FROM WorldTimeTracker WHERE player_name="fred" AND world_name="world"

One Player - All Worlds

SELECT SUM(total_time) FROM WorldTimeTracker WHERE player_name="fred"

Times are all stored as integers, standard PHP date and time functions should be able to turn the integers into meaningful information.


Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes

About This Project

Categories

Members

Recent Files