OnlinePlayersSQL
Description
This plugin will update a MySQL database table with a list of players as the join and disconnect from your game.
Originally created for the MCAddictGallery server, it was created so that we could have a live player listing on our website with minimal of fuss.
Currently the plugin tracks the following information:
- Player Name
- Previous World (used for when a player warps from one world to another)
- Current World (the current world the player is in)
- IP Address
- Logon Time (stored as seconds since epoch)
- Players permission group
- Flag to say whether the player is online or not.
Required Plugins to use this one
- Vault
Optional Plugins that provide extra features
- SimplyVanish - Not required, but if you want the players list to not show vanished players, then you will likely want this.
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 op_only_resync: true|false
eg.
MySQLServer: localhost MySQLPort: '3306' MySQLUsername: player_tracker MySQLPassword: fred123 MySQLDatabase: player_tracker MySQLTable: online_players showDebug: false op_only_resync: false
This plugin will check to see if the necessary table exists in 'MySQLDatabase' and if it doesn't, it will create it.
showDebug will put debug information in the console allowing you to follow along what the plugin does when a player connects/disconnects.
op_only_resync determins if only ops can use '/onl resync' or not.
An example php file can be found here: http://dev.bukkit.org/server-mods/online-players-sql/pages/example-php-file/
It should work just fine, though you will need to change values where necessary for your mysql logon information.
Information about each function used can naturally be found at the php.net website.
It didn't really fix anything, since my online status and the logon time don't change :/
The error is below:
I got this on starting the server:
2012-04-11 22:52:44 [WARNING] OP[MySQL] Error in SQL query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
And then, when I connected/disconnected:
2012-04-11 22:53:48 [WARNING] OP[MySQL] Error in SQL query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.1, logon_time = 1334199228 WHERE player='franky1223'' at line 1
0.8 beta 2 has been uploaded, waiting on approval, should fix the SQL query issue.
I think I discovered a problem in your SQL query. The is no space between the logontime and the "where".
Ex: 2012-04-11 14:43:41 [WARNING] OP[MySQL] Error in SQL query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.1, logon_time = 1334169821WHERE player='franky1223'' at line 1
Here is the log of this specific error, my configuration is default except for the database name and login informations. Hope you can fix this soon ;)
@ThisUsernameIsMine
I deliberately chose not to with this plugin, since a FlatDB such as yaml would create loads of I/O overhead, plus it is a pain in the ass to have PHP read and parse the yaml files.
I've never really worked much with SQLite so i'm not really sure how i would make it work with that either.
FlatDB possible or would that eventually be(come) problematic?
Thanks ;-)
Just posted v0.8beta1, waiting on approval.
Should work fine in 1.2.5.
It is a beta, if it has issues, shutdown game, download 0.7, remove mysql table, start game up and everything will be working again.
0.8beta1 does not remove players from the table anymore, instead it just changes the 'online' field from 1 = on to 0 = off when a player disconnects.
websites will need updating to reflect this change.
I have marked 'v0.8beta1' as a beta to reflect the fact that it is in beta, i have only done minimal testing on it.
Just to update, i haven't forgotten about the stuff, just busy doing work related stuff during the week and on some of the weekends.
@ray73864
That's exactly how I imagined it recently! Wow, with a plugin like that, I will be able to manipulate players stats like never before!
IS this possible to post on an Enjin website? http://www.enjin.com/
@franky1223
A new thought just occurred to me on this one. Instead of wiping the players from the database each time, just update an 'online' field in the table, setting it either '1' or '0'.
1 = online 0 = offline
Then people just have to update their live player listings to look at that field to find out who is online.
Much easier than trying to get the code to do 2 different tricks, easier if it just maintains the complete list, with correct indexing, it should be pretty darned quick to look up too.
AFK is one of those complicated ones, vault doesn't actually have anything at all for getting it.
Basically to determine AFK status i need to track all the necessary events (chat, block place, block break, movement, etc...) and record the last time they performed one of those actions.
Then, if the time between performing one of those actions and current time is say greater than or equal to the afktimeout in the config file, then they are afk.
It's not impossible to do, it'll just take me a little time. Most of my dev work for the plugin happens on the weekends due to my full time job during the week.
@rustymetal
Well, I already have Simple AFK which adds [AFK] after the names of my players. So I have no problem with that. But it would be indeed a great addition :D
@Ray73864
I got another for you.
I would like to get the AFK status of players. Again this is handled by different plugins. Maybe vault has a option to check if player is AFK? I need it.
@franky1223
no probs. A config option won't be terribly difficult, just gotta tell all my code to listen to it, but again, not a problem there either.
@ray73864
Omg ray! Thank you for the fast reply! You just made my day :D
Yeah, I would really appreciate the idea of creating an entry in the config, so we wouldn't have another plugin. But I also have basic knowledge of java, and if you could hand me the source code of this plugin, I could make the modifications myself. Or you could do it yourself the way you want and I will wait the necessary time ;)
Anyway, you rock man! Thanks for your plugin :)
@franky1223
I could create a different plugin to do just that if you want, take me a few days to do, but i could call it 'PlayerListingSQL' or something like that.
Or, i could probably set up a config.yml file entry to stop it from removing them and just update instead. Though the name of the plugin is 'OnlinePlayers' for a reason and storing offline ones just wouldn't seem a right fit for it.
Hey would it be possible to make it not delete all MySQL entries? So I could list all players ever playing on the server. And if it could also list if players are online or not. It would be soooo useful since I did not find any other plugin capable of listing players and their permission group together.
0.7 working good for me http://x187x.com/
New version 0.7 uploaded and waiting on approval.
Only difference between this version and 0.6 is the inclusion of a new command "/onl resync". I haven't set permissions up for it since i figured it isn't really that dangerous of a command.
The command will basically remove all players from the SQL table and repopulate it with the currently logged on players.
@Jayyx2
Basically what you want to do, is convert the current time to seconds, subtract the 2 lots of seconds:
eg. current_secs - logon_time, then convert the new seconds to a fancy time format, such as: 1 day 2hrs 30secs.