Ulysses

Ulysses Stuff => Releases => Topic started by: MRDRMUFN on August 13, 2012, 08:36:34 PM

Title: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: MRDRMUFN on August 13, 2012, 08:36:34 PM
I have taken the UtimeM plugin and have modified it work with the 'gm_mysqloo' module. This allows Linux servers to store Utime data on a MySQL database.
Works for both windows and Linux servers.

Requires:
ULib, gm_mysqloo

Released under Creative Commons

[EDIT] uploaded revision 1 "Fixes random disconnects"
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: JamminR on August 13, 2012, 08:51:33 PM
Thanks!
I love seeing an old release become new and better through the talents of our community.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: MRDRMUFN on August 13, 2012, 08:59:32 PM
No problem  ;D. there might be some debug code still in there you can just remove those print msg's if they get annoying
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Megiddo on August 14, 2012, 06:17:24 PM
Nice!
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: MKServers on August 15, 2012, 09:42:14 PM
Very nice, very nice. Will be used on [MK] so thank you.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: MRDRMUFN on August 15, 2012, 10:58:37 PM
Thanks this is my first personal coding project that i've actually finished  :D
I did it because i needed it for my own server.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: emilhem on August 19, 2012, 08:52:53 AM
Awesome! Karma for you!

Now if you could do the same for UBan (http://forums.ulyssesmod.net/index.php/topic,921.0.html) that would be even more awesome!
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: MoSs on August 20, 2012, 04:34:43 AM
heads up! default port for mysql is 3306, in the lua file the port is 3308

just wanted to point it out in case someone gets confused why it doesn't connect to the db :)
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Q4-Bi. on October 10, 2012, 11:52:10 AM
Looks nice =) Finally i found what i've been looking for.

Almost, could it be possible to track people from different servers like , Current server time and total server time?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: MRDRMUFN on October 11, 2012, 10:29:25 AM
it works exactly as Utime did. I've only modified the library it relies on. Also you should use the Rev-1 version i uploaded. It fixes a serious bug i had with the first version. Critical bug if you use Auto-promote. Sorry just got around to uploading it.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: saintwubbles on October 24, 2012, 04:44:58 PM
Thank you for your work on this, it was one of the things I was worried about for gmod13.

As Emilhem said, a port of uban would be really useful.

Edit: Did it myself http://forums.ulyssesmod.net/index.php/topic,921.msg26717.html#msg26717
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Bite That Apple on December 31, 2012, 03:34:11 AM
Thank you for this. I used to have a version of utime that did this exactly, and you could also change a player's time while IG. Unfortunately due to the Garry's Mod 13 upgrade, it kinda killed the derma panals, which made Utime just record time in a database as this one does.

I hope one day you might do the same with this really amazing version of utime so ply:IsSuperAdmin can change players time IG, or maybe even integrate it with xgui.

Nice work though  ;D
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: maddogsuperior on April 29, 2013, 07:48:56 AM
Currently in the process of trying to get this to work...
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Sidewaykill on May 11, 2013, 06:14:31 AM
If you do, post it here :D
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on June 28, 2013, 09:44:42 PM
Here is my rewrite of this addon. It (hopefully) fixes a rare case where the time would get saved after a player joined but before the db responded, causing their time to reset to zero. It also properly handles a database connection loss.

The only difference, functionally, from MRDRMUFN's version is that it does not store the team, you will have to modify the queries if you want it to save that info.

https://dl.dropboxusercontent.com/u/7934790/gmod/utimem.zip
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 03, 2013, 02:28:24 AM
I'm getting this error when a player joins.


Code: [Select]
[ERROR] addons/utimem/lua/autorun/cl_utime.lua:310: attempt to index local 'cpanel' (a nil value)
1. buildCP - addons/utimem/lua/autorun/cl_utime.lua:310
2. resetCvars - addons/utimem/lua/autorun/cl_utime.lua:305
3. fn - addons/utimem/lua/autorun/cl_utime.lua:406
4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
5. GetAll - [C]:-1
6. fn - addons/ulx/lua/ulx/modules/sh/chat.lua:245
7. Call - addons/ulib/lua/ulib/shared/hook.lua:183
8. fn - addons/ulib/lua/ulib/cl_init.lua:40
9. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
 
 
[anulka.w1106|3|STEAM_0:0:61718709] Lua Error:
controlpanel.Get() - Error creating a ControlPanel!
You're calling this function too early! Call it in a hook!
 
[anulka.w1106|3|STEAM_0:0:61718709] Lua Error:
 
[ERROR] addons/utimem/lua/autorun/cl_utime.lua:310: attempt to index local 'cpanel' (a nil value)
1. buildCP - addons/utimem/lua/autorun/cl_utime.lua:310
2. resetCvars - addons/utimem/lua/autorun/cl_utime.lua:305
3. fn - addons/utimem/lua/autorun/cl_utime.lua:406
4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
 
 
[anulka.w1106|3|STEAM_0:0:61718709] Lua Error:
controlpanel.Get() - Error creating a ControlPanel!
You're calling this function too early! Call it in a hook!
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: JamminR on August 03, 2013, 04:09:39 AM
Make sure your using the latest 'fix' by Tweak. It appears several posts after the original release, June 29 I think.
Also make sure you've got the latest svn of Utime from https://github.com/Nayruden/Ulysses/
Seems I remember seeing the cpanel bug you mention fixed months if not years ago.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 03, 2013, 11:33:11 AM
I was using his fix, I will try the latest svn. Are you suggesting that I should mix the latest svn with Tweak's fix?

EDIT: Newest svn gives me the same error, strange thing is I only get it on my Zombie Survival server and not on my sandbox...
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 03, 2013, 12:44:37 PM
Yeah you can mix them, if you overwrite just the SVN's sv_utime.lua with mine. I think the cpanel error is from running it on gamemodes without a spawnmenu. I'll see about including the fixed client file with mine.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 04, 2013, 08:41:49 AM
Yeah you can mix them, if you overwrite just the SVN's sv_utime.lua with mine. I think the cpanel error is from running it on gamemodes without a spawnmenu. I'll see about including the fixed client file with mine.

It will mean the world to me if you could fix the UtimeMOO so it works with a gamemode without a spawnmenu :D


EDIT: I assume utime uses pdata, so is there a way to import the pdata to mysql?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 05, 2013, 04:15:24 PM
Not sure what you mean by pdata, the original utime stores data in the SQLite database (sv.db). It's possible to migrate the data from SQLite to MySQL with a script, or maybe there is a way to just dump it to CSV and import it straight to MySQL, I dunno. The table structure is a little different. I did it using Lua but I don't have the script anymore...

Anyway, you can just grab the cl_utime file from the official SVN and overwrite it, that should make it not error when there is no spawnmenu.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 06, 2013, 01:20:40 PM
Not sure what you mean by pdata, the original utime stores data in the SQLite database (sv.db). It's possible to migrate the data from SQLite to MySQL with a script, or maybe there is a way to just dump it to CSV and import it straight to MySQL, I dunno. The table structure is a little different. I did it using Lua but I don't have the script anymore...

Anyway, you can just grab the cl_utime file from the official SVN and overwrite it, that should make it not error when there is no spawnmenu.

Oh my bad, I assumed that all addons used "pdata" I've seen some other ones have it. I will try to import it directly.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 07, 2013, 04:50:13 PM
Not sure what you mean by pdata, the original utime stores data in the SQLite database (sv.db). It's possible to migrate the data from SQLite to MySQL with a script, or maybe there is a way to just dump it to CSV and import it straight to MySQL, I dunno. The table structure is a little different. I did it using Lua but I don't have the script anymore...

Anyway, you can just grab the cl_utime file from the official SVN and overwrite it, that should make it not error when there is no spawnmenu.

I successfully extracted the SQLite data and imported it to my MySQL db and it works on my sandbox and zombie survival server! Thanks :D
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 08, 2013, 05:17:55 AM
Scratch that it worked on the zombie survival server. I still get this error and I've updated the cl_utime file....

Code: [Select]
[antbert|15|STEAM_0:1:70488492] Lua Error:
 
[ERROR] addons/utimem/lua/autorun/cl_utime.lua:310: attempt to index local 'cpanel' (a nil value)
  1. buildCP - addons/utimem/lua/autorun/cl_utime.lua:310
   2. resetCvars - addons/utimem/lua/autorun/cl_utime.lua:305
    3. fn - addons/utimem/lua/autorun/cl_utime.lua:334
     4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
 
 
[antbert|15|STEAM_0:1:70488492] Lua Error:
controlpanel.Get() - Error creating a ControlPanel!
You're calling this function too early! Call it in a hook!
 
[antbert|15|STEAM_0:1:70488492] Lua Error:
 
[ERROR] addons/utimem/lua/autorun/cl_utime.lua:310: attempt to index local 'cpanel' (a nil value)
  1. buildCP - addons/utimem/lua/autorun/cl_utime.lua:310
   2. resetCvars - addons/utimem/lua/autorun/cl_utime.lua:305
    3. fn - addons/utimem/lua/autorun/cl_utime.lua:334
     4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
      5. TraceLine - [C]:-1
       6. unknown - addons/utimem/lua/autorun/cl_utime.lua:143
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 08, 2013, 09:08:41 PM
And you're using the cl_utime.lua from the official SVN?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 09, 2013, 08:12:05 AM
And you're using the cl_utime.lua from the official SVN?http://forums.ulyssesmod.net/Themes/default/images/bbc/email.gif


I'm using this svn: "https://github.com/Nayruden/Ulysses/ (https://github.com/Nayruden/Ulysses/)".
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 09, 2013, 05:11:22 PM
Hmm, that is weird. And zombie survival does not have a spawnmenu, correct? You might be able to get away with just commenting out that block of code (lines 322-330) just to suppress the error for now...
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 10, 2013, 03:29:52 PM
Hmm, that is weird. And zombie survival does not have a spawnmenu, correct? You might be able to get away with just commenting out that block of code (lines 322-330) just to suppress the error for now...

Uhm, not sure what you mean with a spawn menu, but Zombies can change class if they press F3.

Edit: *facepalm* did you mean "Q" where you spawn props/etc?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 11, 2013, 01:33:41 AM
yeah that
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: alexys95 on August 11, 2013, 09:17:35 AM
Okay, well no it does not have a spawn menu.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: BlueGhostHD on August 12, 2013, 07:01:40 PM
I need help setting up mysqloo for linux, I've done it for pc, but I don't understand what to do for linux and which files to use.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: JamminR on August 12, 2013, 07:26:14 PM
I need help setting up mysqloo for linux, I've done it for pc, but I don't understand what to do for linux and which files to use.
See the bottom of this post, which provides different files/links and locations.
http://facepunch.com/showthread.php?t=1220537
(all i know to do to help, but figure thats a start)
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: BlueGhostHD on August 12, 2013, 07:42:56 PM
See the bottom of this post, which provides different files/links and locations.
http://facepunch.com/showthread.php?t=1220537
(all i know to do to help, but figure thats a start)

I've tried all of that, followed tutorials, etc. but it still won't work! :(
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 12, 2013, 11:43:37 PM
"Doesn't work" tells us absolutely nothing. Are you getting an error in your console? Have you installed the dll in lua/bin and libmysql alongside the srcds executable? Are you sure your database connection info is correct?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: BlueGhostHD on August 13, 2013, 12:13:17 AM
"Doesn't work" tells us absolutely nothing. Are you getting an error in your console? Have you installed the dll in lua/bin and libmysql alongside the srcds executable? Are you sure your database connection info is correct?

Don't worry, I decided to backup all my work, and change the OS to Windows, because I've always preferred it over Linux :P

Edit: Now with mysqloo working, this addon shows no connectivity to the database I used.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: esfservers on August 20, 2013, 04:59:05 PM
[ERROR] addons/utimemoo/lua/autorun/cl_utime.lua:137: attempt to index global 'utilx' (a nil value)
  1. unknown - addons/utimemoo/lua/autorun/cl_utime.lua:137

Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: TweaK on August 21, 2013, 06:33:57 PM
[ERROR] addons/utimemoo/lua/autorun/cl_utime.lua:137: attempt to index global 'utilx' (a nil value)
  1. unknown - addons/utimemoo/lua/autorun/cl_utime.lua:137
I think you got an ancient version or something... try the one I posted
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Neoon on July 11, 2014, 03:59:46 PM
Uses sqlite instead of mysql so it dosent works, please fix it.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: crotoss on July 21, 2014, 07:35:21 PM
I am having an issue where random players get their times reset. They're still in the database just their time resets at 0.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Malkeur on August 02, 2014, 08:22:40 AM
I'd be down to try this but I'm curious, can you convert the data from the sv.db that the original utime uses to the mysql version this uses? I'd much rather use mysql.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Bite That Apple on August 02, 2014, 03:28:30 PM
I'd be down to try this but I'm curious, can you convert the data from the sv.db that the original utime uses to the mysql version this uses? I'd much rather use mysql.

That's a lot of work to convert mysqli to mysql in this game. I suppose someone would have to make another addon.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: crotoss on September 29, 2014, 07:06:33 PM
Using the version provided by TweaK https://dl.dropboxusercontent.com/u/7934790/gmod/utimem.zip

I still seem to have issues with peoples time being occasionally reset. Anyone else encountering this problem?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Luk | twitch.tv/doctorluk on April 06, 2015, 11:40:06 AM
I'm replying to this topic as my issue is directly related to the modified script released by TweaK.

The aim of using MySQL for Utime is to use it on a website and get some quick info about some players and stuff.

The stock UTime addon does not save the Steam-ID, nor the current name of the player. This addon does that, which is a nice feature that I need.

However, an issue with the names is that they are not being saved in UTF-8, so german umlauts are being destroyed and all other characters that many people use are destroyed, too.

I've already changed the encoding in my MySQL table to utf8_unicode_ci, but the names are still being butchered and I suspect lua to be doing that.

Is there a way to get the script to input UTF-8 encoded characters?

As an example:
Code: [Select]
Jünger² Gaboris being saved as
Code: [Select]
Jünger² Gabor
This is an excerpt of the update-query:
Code: [Select]
query( "UPDATE utime SET totaltime = " .. math.floor( ply:GetUTimeTotalTime() ) .. ", steamid = '" ..
ply:SteamID() .. "', playername = '" .. db:escape( ply:Nick() ) .. "' WHERE player = " ..
ply:UniqueID() .. ";", function() end )

-------------------------------------
I did it!

The thing that was missing was "SET NAMES 'utf8';" as the first query before any other queries. Also the playername row must be encoded in utf8_unicode_ci to allow UTF-8 encoded entries.

Here is how to install it:
I already have a UTime MySQL table with entries
1. Open your table structure via phpmyadmin
2. Edit the row "playername"
3. Change the collation to "utf8_unicode_ci"
If you do not have phpmyadmin and can only use SQL queries, use this one:
Code: [Select]
USE <database>;
ALTER TABLE  `utime` CHANGE  `playername`  `playername` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;
and replace "<database>" with the name of your database where utime is installed.

This is the first time I install UTime with MySQL
1. You do not have to change anything, the script automatically constructs the playernames table with UTF-8 encoding

You find the modified scripts in an attachment to this post which you can only see when being logged in.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Bite That Apple on May 03, 2015, 07:12:54 PM
I still seem to have issues with peoples time being occasionally reset. Anyone else encountering this problem?

It's not really fixable. It's supposed to be a really RARE issue though, because of utime saving the database information at 67 seconds, it's possible that before the player's time/data is loaded, the server saved when their data is at 0, small chance though.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Aaron113 on May 03, 2015, 08:40:16 PM
It's not really fixable. It's supposed to be a really RARE issue though, because of utime saving the database information at 67 seconds, it's possible that before the player's time/data is loaded, the server saved when their data is at 0, small chance though.
Looks like it's fixed in the version posted right above you.  All he did was add a simple loaded check on the player.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Bite That Apple on May 04, 2015, 05:23:51 PM
Looks like it's fixed in the version posted right above you.  All he did was add a simple loaded check on the player.

From what I read he's just fixing certain names, but at the same time I didn't thoroughly check everything he did.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Luk | twitch.tv/doctorluk on May 26, 2015, 08:20:37 AM
IIRC I only did some minor changes on the UTF-8 encoding, nothing else.

But I'm struggling with the occasional resets, too. My server is almost always full (16 Players) and in the last three days about 8 people complained about their time being reset. Is it possible that MySQL + LUA is unreliable?
Another quick browse through the code does not show anything interesting.

I desperately need Utime for MySQL for my !motd and other stats delivered via a webserver and this is slowly driving me nuts.
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Tekop on May 28, 2015, 01:37:36 AM
Do you know when the players who get reset joins? Have the server been empty for a long period before they do?
I've had something like that happen where the db connection would reset to "gone away"/ time out the first time it's used. I edited Pointshops (https://github.com/adamdburton/pointshop/blob/master/lua/pointshop/providers/mysql.lua#L83) way to do it with a "wrapper" which takes some sql string, a callback to be called with returned data and a optimal tries argument to limit the number of retries.
I wouldn't mind trying getting my hands dirty since I would have made my own version anyways... Is it okay to use github rather than uploading archives here?
Title: Re: UtimeMOO - Utime for MySQL (Linux Compatible)
Post by: Luk | twitch.tv/doctorluk on June 02, 2015, 02:51:49 PM
I don't see any connection between server usage and the occasional resets. I've used an external MySQL Server (different VHost, same Hostmachine, so latency <1ms) and moved it on the same VHost, but that didn't change a thing (why would it, if the latency difference is about 0.5ms... *scratches head*).

I'm thinking about combining SQLite and MySQL where SQLite is actually used for storing/reading the time, but the time is regularly being pushed to MySQL, too. I only have one server, so that should do it. Although I'm still heavily annoyed by the inconsistency.