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.
@ray73864
Vault does support group manager, so would it be possible to have an option to also save the group the player is in database? Our server would benefit greatly from that, and also would it be possible to have an option to save the money the player has to the database. Vault has support for iconomy which my server uses.
I've posted a new version with a config change, i'm not sure how well bukkit handles additions to the config file, you may need to remove the config and let it recreate it.
New config option is 'op_only_resync'.
When you set that option to 'true', it will require that the player be OP in order to use the resync command.
Yeah, when i created this plugin, i deliberately chose to not build a webserver into it, or force you into a design, the sole purpose was to fill the SQL table with the necessary information and let you use whatever server-side language you like to get the players and display, be that PHP, RubyOnRails, ASP.NET, Perl, etc...
We were using SimplePlayerList for a while and although the output was very nice on our web server, the java plugin was making our game server very unstable. (Maybe because it was interacting directly with the php on the web server?)
Now i'm using your plugin to store the data in MySQL and i rewrote the PHP of SimplePlayerList to query the MySQL every minute.
Result : http://minr.org/
Thx again for the plugin!
Hi ray73864
Can't wait to try this. As the previous plugin we used for this was causing problems on our server.
Is an up to date version of the source available somewhere ? I found this http://code.google.com/p/online-players-sql/source/browse/#svn%2Ftrunk%2FOnlinePlayersSQL But it looks like it hasn't been updated recently.
Could you make the sync command op only ?
Thx for the plugin.
@oman95891
Group support?
I support what Vault supports for getting the permissions group the player is in, that's all i was ever intending on doing for that.
If vault doesn't support group manager, then it'll be a no, because i'm not going to code in an exception just for group manager because then i may as well code exceptions in for everything vault doesn't support.
Could you add group support? E.g. Groupmanager?
New version of the plugin uploaded and waiting on approval.
Updated to latest version of SQL library so it should only open 1 connection to the database now instead of 1 each time it runs a query.
Have set the plugin.yml file up so that it supports craftbukkituptodate, just need to inform the dev of that plugin so that that feature actually works.
@enigmaspb
Looks simple enough. I shall do that when i update the SQL side of it too.
Haven't had much time lately due to work.
Pls add support http://dev.bukkit.org/server-mods/craftbukkituptodate/
One thing i need to do is update the version of the SQL library that it uses, the one that it uses would open a new connection everytime to run an SQL query, the newest version of the library opens the connection once and then leaves it open for the entire time.
So i guess it is entirely possible if you have a lot of connections every minute or so, it would likely eat up all the available SQL connections, but i've never noticed that issue with our server.
@Pr07o7yp3
I'm not sure what to say, we use it on our server which runs a slightly older version than the one here and we run it just fine on 1.2.5-R4.
I do need to find time again for it, not easy with a busy weekly job.
This plugin rapes my MySQL and other plugin which use it... Please, update it for 1.2.5.
Nice plugin. Please keep it up to date. :)
@waybaker
Will look into it hopefully on the weekend when i have some free time. Would be a nice addition anyway, that way as you say, my player listing reflects the in-game playerlisting.
@ray73864
I don't believe it does work with vault, but the plugin author does list on his page some of the things it does work with and how to tie in:
http://dev.bukkit.org/server-mods/vanish/
@waybaker
Hrmmm, probably could, does VanishNoPacket work with vault? otherwise i would have to hope that i can find all the necessary stuff out from that plugin.
[Fixed the Issue, code removed]
On a side note, we use the VanishNoPacket plugin, any chance you could make it so that if the user is vanished, it can write another variable to the database (isvanished = 1 or isvanished = 0 for example) so that I can adjust my website code to not show the vanished players online?
Its hard to follow someone around and catch them griefing when they know we might be on and watching them.
@Qualtranas
That just means that $result doesn't have anything in it.
Make sure that you are querying the database and sticking the results of that query into $result.
I'm a complete noob at php, but I was wondering if you could help me with this? The database is working fine, but when I try to use
I get this error(the first line being 34):
ok, beta3 is just waiting on approval.
I have fixed and tested the errors. The first error you saw was because it was trying to add a column that already existed, have finally worked out how to check if it exists and if it does, don't error out and don't try to re-add it.
The second error for updating log on times was because i forgot to quote the IP address, have fixed that issue now too.