Author Topic: UTimeM - UTime for MySQL  (Read 36636 times)

0 Members and 1 Guest are viewing this topic.

Offline saintwubbles

  • Newbie
  • *
  • Posts: 15
  • Karma: 3
Re: UTimeM - UTime for MySQL
« Reply #30 on: June 24, 2010, 05:56:45 AM »
Just a suggestion, could you add IP and first visit logging. I have done this myself but I think it might be useful for other people.

Offline Buggzie

  • Newbie
  • *
  • Posts: 48
  • Karma: 2
Re: UTimeM - UTime for MySQL
« Reply #31 on: June 25, 2010, 04:50:22 AM »
Could you possibly help me make a persistent?

thanks to meg and jay they helped make it persistent for me.

Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: UTimeM - UTime for MySQL
« Reply #32 on: June 29, 2010, 08:21:05 PM »
There's an error with this now since Garry's Update. Here's the Lua error: I'm pretty sure it still records time, but this error never stops.

Code: [Select]
Timer Error: autorun\cl_utime.lua:43: attempt to index upvalue 'gpanel' (a nil value)

Offline saintwubbles

  • Newbie
  • *
  • Posts: 15
  • Karma: 3
Re: UTimeM - UTime for MySQL
« Reply #33 on: June 30, 2010, 07:08:07 AM »
You can remove cl_utime.lua temporarily to stop the errors till a fix is available, the serverside stuff isn't affected.

Offline RynO-SauruS

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 17
Re: UTimeM - UTime for MySQL
« Reply #34 on: June 30, 2010, 10:50:08 AM »
I've fixed this error, but on the regular version of UTime. Is the cl_utime.lua file in this the same as the one in the original? If so I can attach the fixed file.


YouTube music player by RynO-SauruS

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: UTimeM - UTime for MySQL
« Reply #35 on: June 30, 2010, 11:47:18 AM »
I've fixed this error, but on the regular version of UTime. Is the cl_utime.lua file in this the same as the one in the original? If so I can attach the fixed file.

I think so
Experiencing God's grace one day at a time.

Offline RynO-SauruS

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 17
Re: UTimeM - UTime for MySQL
« Reply #36 on: June 30, 2010, 12:20:38 PM »
OK I've attached a slightly modified file that fixes the error that someone920 mentioned,
and also I've found a place where I fixed another error I was getting a long time ago.

And to Megiddo, the part I changed to fix the error that someone920 mentioned is this:

(Starting at line 31 and ending at line 38)
Code: [Select]
function initialize( ent )
if ent == LocalPlayer() then -- Player has been initialized
gpanel = vgui.Create( "UTimeMain" )
gpanel:SetSize( gpanel.Wide, gpanel.Small )
hook.Remove( "OnEntityCreated", "UtimeInitialize" )
end
end
hook.Add( "OnEntityCreated", "UtimeInitialize", initialize )

I changed it to this:

(Starting at line 31 and ending at line 36)
Code: [Select]
function initialize()
gpanel = vgui.Create( "UTimeMain" )
gpanel:SetSize( gpanel.Wide, gpanel.Small )
hook.Remove( "InitPostEntity", "UtimeInitialize" )
end
hook.Add( "InitPostEntity", "UtimeInitialize", initialize )

Let me know if this is flawed in some way.
« Last Edit: June 30, 2010, 12:26:58 PM by RynO-SauruS »


YouTube music player by RynO-SauruS

Offline saintwubbles

  • Newbie
  • *
  • Posts: 15
  • Karma: 3
Re: UTimeM - UTime for MySQL
« Reply #37 on: July 01, 2010, 06:16:16 PM »
Thanks RynO-SauruS, that works for me.

Edit: My small modifications to the mySQL queries in sv_utime.lua adding firstvisit and IP logging.

line 60
Code: [Select]
result = xquery( "CREATE TABLE utime (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,player INTEGER UNSIGNED NOT NULL,ip VARCHAR(30) NOT NULL,totaltime INTEGER UNSIGNED NOT NULL,lastvisit INTEGER UNSIGNED NOT NULL,firstvisit INTEGER UNSIGNED NOT NULL,steamid VARCHAR(45) NOT NULL,playername VARCHAR(100) NOT NULL,team VARCHAR(45),PRIMARY KEY (id))" );
line 86
Code: [Select]
xquery( "UPDATE utime SET ip = '" .. ply:IPAddress() .. "', lastvisit = " .. os.time() .. " WHERE player = " .. uid .. ";" )
line 101
Code: [Select]
local result, succ, err = mysql.query(db, "INSERT into utime ( ip, player, totaltime, lastvisit, steamid, playername, team, firstvisit ) VALUES ( '" .. ply:IPAddress() .. "', " .. uid .. ", 0, " .. os.time() .. ", '" .. sid .. "', '" .. mysql.escape(db, nam) .. "', '" .. mysql.escape(db, tem) .. "', " .. os.time() .. ");")
I hope this would be useful for someone.
« Last Edit: July 01, 2010, 06:53:48 PM by saintwubbles »

Offline Robin

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: UTimeM - UTime for MySQL
« Reply #38 on: July 21, 2010, 04:49:49 AM »
For everyone who got problems with it, means when it lags while the server is sending a query,

Replace all

   -- Disconnect from server.
   local succ, error = mysql.disconnect(db)
   if(not succ) then
      print("[UTime] Error disconnecting from server!")
   end

with
       -- Disconnect from server.
       mysql.disconnect(db)

Becouse some servers don't send confirmations for a closed mysql connection back.
Thats why the Server freezes until that functions times out.

Offline ACProdigy

  • Newbie
  • *
  • Posts: 21
  • Karma: 10
  • Beriddled with nonsense
Re: UTimeM - UTime for MySQL
« Reply #39 on: July 01, 2011, 09:24:05 AM »
Wow, its been a long time since I've been here. It looks like things have changed since the last release, things broke, and the community was able and willing to patch the code as time went on. (Good job and thanks).

I'll be updating this plugin with some updates for compatibility, bugfixes, slightly refactored code, and user-defined options!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UTimeM - UTime for MySQL
« Reply #40 on: July 01, 2011, 07:43:45 PM »
Welcome back, and, great to hear!
:)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline strategos

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 2
  • I wanna be the guy
    • Community
Re: UTimeM - UTime for MySQL
« Reply #41 on: September 19, 2011, 10:54:38 AM »
Can anyone confirm if this still works?

Also, will gm_mysql work alongside the MysqlOO module by andyvincent?

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: UTimeM - UTime for MySQL
« Reply #42 on: January 25, 2012, 04:06:12 PM »
Could this be made into a mysqloo version?
I don't think its possible to run mysql and mysqloo together, and alot of addons use mysqloo, so it would be a good idea to create a mysqloo version for the compatibility

Offline MRDRMUFN

  • Newbie
  • *
  • Posts: 9
  • Karma: 6
    • Ingenious Gaming
Re: UTimeM - UTime for MySQL
« Reply #43 on: January 26, 2012, 07:41:17 PM »
Im with blackfire88 on this. ULX needs a mysqloo version of utime. I've tried to patch it to work myself, but a serious issue happened that im not experienced enough in scripting to solve. I managed to get it to propagate the database and fill it in the same format as the mysql utime. but i cant for the life of me manage to get it to load times on player join.
Here is a link to my edited version -> http://dl.dropbox.com/u/34509350/UTimeM.zip 

The reason i need this to work so bad is that my server runs on linux, and GmMysql isnt linux compatible.
My goal is to eventually Merge ranks and player times from my gmod and minecraft servers. Combined with
IRC for Multiserver chat system where members can play on the separate systems and still communicate and
earn game credit/time.

Offline MKServers

  • Newbie
  • *
  • Posts: 10
  • Karma: 3
Re: UTimeM - UTime for MySQL
« Reply #44 on: August 14, 2012, 06:28:27 PM »
Im with blackfire88 on this. ULX needs a mysqloo version of utime. I've tried to patch it to work myself, but a serious issue happened that im not experienced enough in scripting to solve. I managed to get it to propagate the database and fill it in the same format as the mysql utime. but i cant for the life of me manage to get it to load times on player join.
Here is a link to my edited version -> http://dl.dropbox.com/u/34509350/UTimeM.zip 

The reason i need this to work so bad is that my server runs on linux, and GmMysql isnt linux compatible.
My goal is to eventually Merge ranks and player times from my gmod and minecraft servers. Combined with
IRC for Multiserver chat system where members can play on the separate systems and still communicate and
earn game credit/time.

I require some help of my own(Here is a MySQLOO Utime).http://forums.ulyssesmod.net/index.php/topic,5737.0.html
So the following WILL require a little knowledge of how Utime saves. It is all numbers. I need a way for my PHP Loading screen to read these number, and break them up into Month, Day, and Year. I am not asking for much, I having been searching for a while and can't figure this out, so any help would be appreciated.
I do know alot about coding, I run my own server, [MK] Servers as my name would show, and i have coded my own things with MySQL and PHP but cant find a way for PHP to read the Utime numbers. Please help me.
Thank you all in advance.
« Last Edit: August 14, 2012, 06:56:02 PM by MKServers »