ULX

Author Topic: Utime -- Show how long your players have been connected this session and total  (Read 538185 times)

0 Members and 2 Guests are viewing this topic.

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Thanks for porting this over to 13, I may have found a bug while changing the position values in resetCvars, then entering utime_reset in game, I get:

Code: [Select]
] utime_reset
Warning: vgui.Create failed to create the VGUI component (ControlPanel)

Trace:
1: Line 32 "Trace" lua/includes/extensions/debug.lua
2: Line 13 "Get" lua/includes/modules/controlpanel.lua
3: Line 305 "nil" addons/utime/lua/autorun/cl_utime.lua
4: Line 69 "nil" lua/includes/modules/concommand.lua


controlpanel.Get() - Error creating a ControlPanel!
You're calling this function too early! Call it in a hook!

[ERROR] addons/utime/lua/autorun/cl_utime.lua:310: attempt to index local 'cpanel' (a nil value)
  1. buildCP - addons/utime/lua/autorun/cl_utime.lua:310
   2. unknown - addons/utime/lua/autorun/cl_utime.lua:305
    3. unknown - lua/includes/modules/concommand.lua:69


Note, this is a TTT server.
My TTT server. Join the fun!

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
It seems to be happening to people who join for the first time, here's what I get in clientside_errors.txt

Code: [Select]
[ERROR] addons/utime/lua/autorun/cl_utime.lua:310: attempt to index local 'cpanel' (a nil value)
  1. buildCP - addons/utime/lua/autorun/cl_utime.lua:310
   2. resetCvars - addons/utime/lua/autorun/cl_utime.lua:305
    3. fn - addons/utime/lua/autorun/cl_utime.lua:334
     4. unknown - addons/ulib/lua/ulib/shared/hook.lua:168
      5. GetAll - [C]:-1
       6. fn - addons/ulx/lua/ulx/modules/sh/chat.lua:245
        7. Call - addons/ulib/lua/ulib/shared/hook.lua:168
         8. fn - addons/ulib/lua/ulib/cl_init.lua:40
          9. unknown - addons/ulib/lua/ulib/shared/hook.lua:168
           10. LocalPlayer - [C]:-1
            11. fn - addons/ulib/lua/ulib/cl_init.lua:39
             12. unknown - addons/ulib/lua/ulib/shared/hook.lua:168


controlpanel.Get() - Error creating a ControlPanel!
You're calling this function too early! Call it in a hook!

And this is the block I changed, starting on line 286 of cl_utime.lua
Code: [Select]
function resetCvars()
RunConsoleCommand( "utime_outsidecolor_r", "40" )
RunConsoleCommand( "utime_outsidecolor_g", "40" )
RunConsoleCommand( "utime_outsidecolor_b", "40" )
   
RunConsoleCommand( "utime_outsidetext_r", "255" )
RunConsoleCommand( "utime_outsidetext_g", "255" )
RunConsoleCommand( "utime_outsidetext_b", "255" )
   
RunConsoleCommand( "utime_insidecolor_r", "250" )
RunConsoleCommand( "utime_insidecolor_g", "250" )
RunConsoleCommand( "utime_insidecolor_b", "245" )
   
RunConsoleCommand( "utime_insidetext_r", "0" )
RunConsoleCommand( "utime_insidetext_g", "0" )
RunConsoleCommand( "utime_insidetext_b", "0" )
   
RunConsoleCommand( "utime_pos_x", "1" )
RunConsoleCommand( "utime_pos_y", "90" )
buildCP( controlpanel.Get( "Utime" ) )
end
concommand.Add( "utime_reset", resetCvars )
Just the default color and position. Is this the wrong place to change such things?
My TTT server. Join the fun!

Offline delagious

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
I am getting an issue when people reach 96 hours(4 days) of playtime with this addon.
Whenever someone on my server reaches that time they get 1 week added to their time.
So instead of displaying
Code: [Select]
00w 04d 0h 00m 00s it displays
Code: [Select]
01w 04d 0h 00m 00sThe same error occurs when they reach 264 hours(11 days).
So instead of displaying
Code: [Select]
01w 04d 0h 00m 00sit adds a week and displays
Code: [Select]
02w 04d 0h 00m 00sWhy does it add this extra week when they reach the 4th, 11th, 18th, etc... day of total playtime?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
I am getting an issue when people reach 96 hours(4 days) of playtime with this addon.
Whenever someone on my server reaches that time they get 1 week added to their time.
So instead of displaying
Code: [Select]
00w 04d 0h 00m 00s it displays
Code: [Select]
01w 04d 0h 00m 00sThe same error occurs when they reach 264 hours(11 days).
So instead of displaying
Code: [Select]
01w 04d 0h 00m 00sit adds a week and displays
Code: [Select]
02w 04d 0h 00m 00sWhy does it add this extra week when they reach the 4th, 11th, 18th, etc... day of total playtime?

Wow, not sure how that happened. It will be fixed shortly.

@Krooks, I'm not getting that error using GitHub version of UTime. I deleted my garrysmod folder to simulate a first join, but got no error. I also see no difference (except values) in the code you posted.
« Last Edit: January 27, 2013, 05:12:28 PM by Megiddo »
Experiencing God's grace one day at a time.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Updated:

Quote from: Changelog
v1.42 - *(01/27/13)*
   * [ADD] utime_welcome cvar to disable welcome message.
   * [FIX] Regular slew of bugs introduced by Garry (MAJOR thanks TweaK!).
   * [FIX] Time string calculations being incorrect (Thanks delagious).
Experiencing God's grace one day at a time.

Offline smithy285

  • Newbie
  • *
  • Posts: 7
  • Karma: -6
The download link is dead.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Fixed, thanks.
Experiencing God's grace one day at a time.

Offline Handmade.Mercury

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
I'm experiencing the exact same things that Krooks is experiencing. This is also on a TTT server, after freshly installing the latest ULib and ULX, restarting the server, then installing UTime and restarting the server again. I get the exact same errors on a first join, but after that it's fine.

Also, excuse me if I'm being dense, but how does a client access the UTime menu?

EDIT: I notice in clutime.lua that the menu is supposedly hooked into the GMod spawn menu, but the TTT gamemode doesn't use the spawn menu. Is there another way for me to access the menu? Maybe I'll try looking for a way to hook it into TTT's F1 menu.
« Last Edit: January 28, 2013, 08:44:42 AM by Handmade.Mercury »

Offline smithy285

  • Newbie
  • *
  • Posts: 7
  • Karma: -6
I'm experiencing the exact same things that Krooks is experiencing. This is also on a TTT server, after freshly installing the latest ULib and ULX, restarting the server, then installing UTime and restarting the server again. I get the exact same errors on a first join, but after that it's fine.

Also, excuse me if I'm being dense, but how does a client access the UTime menu?

EDIT: I notice in clutime.lua that the menu is supposedly hooked into the GMod spawn menu, but the TTT gamemode doesn't use the spawn menu. Is there another way for me to access the menu? Maybe I'll try looking for a way to hook it into TTT's F1 menu.

Yeah I have installed it but I have no idea how to use it xD

EDIT: It has now decided to work, it looks awesome exactly what I was looking for, good job, but there is one thing I would love you to add in it and that is the ability to close and open the box, so for example, !timeclose !timeopen, something like that would make this amazing.

EDIT: Works fine for me, I am using TTT ;)
« Last Edit: January 28, 2013, 11:57:32 PM by smithy285 »

Offline seven50six6

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Hello,

I got this working with my TTT server but I am trying to reposition it so that it is in the same place for everyone, even for people with different resolutions. I changed the code to move it beside the "preparing" box but with people who have different resolutions, it appears covering the timer. It also seems like when people join it won't correct the positioning if changed between the time they left last time and rejoined; it shows were it was when they left last time.

Some screenshots of the positioning differences:
http://cloud.steampowered.com/ugc/1119412561814368440/F012A5E6E60F812E6F59CDC6FC821C96A72AC7C5/
http://cloud.steampowered.com/ugc/1119412561814346767/50CE8357A867D592C3C43087F60928432CEA363C/


Also, how do I force utime to reset the positioning on the box whenever a player joins instead of having to use that command? (Which currently caused lua error crashing)
« Last Edit: February 07, 2013, 02:06:53 PM by seven50six6 »

Offline zaph

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Hello,

I got this working with my TTT server but I am trying to reposition it so that it is in the same place for everyone, even for people with different resolutions. I changed the code to move it beside the "preparing" box but with people who have different resolutions, it appears covering the timer. It also seems like when people join it won't correct the positioning if changed between the time they left last time and rejoined; it shows were it was when they left last time.

Some screenshots of the positioning differences:
http://cloud.steampowered.com/ugc/1119412561814368440/F012A5E6E60F812E6F59CDC6FC821C96A72AC7C5/
http://cloud.steampowered.com/ugc/1119412561814346767/50CE8357A867D592C3C43087F60928432CEA363C/


Also, how do I force utime to reset the positioning on the box whenever a player joins instead of having to use that command? (Which currently caused lua error crashing)


bumping for same issue

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
you need to pos it by %  not flat numbers i believe as i cant look at pics because im at school >: (
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Updated:
I was just coming on to report the times, thanks for the fix!
My TTT server. Join the fun!

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Still jumping to 1 week after reaching 4 days for some reason.
Maybe it's because I edit it?
All I do is comment out:
AddCSLuaFile( "autorun/cl_utime.lua" )
on line 3 of sh_utime.lua
and remove the cl_utime.lua file.

I do this to get rid of the display, and built a custom scoreboard to show the times.
To get it to show on my scoreboard I copied this to the scoreboard file:
Code: [Select]
function timeToStr( time )
local tmp = time
local s = tmp % 60
tmp = math.floor( tmp / 60 )
local m = tmp % 60
tmp = math.floor( tmp / 60 )
local h = tmp % 24
tmp = math.floor( tmp / 24 )
local d = tmp % 7
local w = math.floor( tmp / 7 )

return string.format( "%02iw %id %02ih %02im %02is", w, d, h, m, s )
end
Because I wasn't sure how to call it from outside.

Could this be the issue in my case?
My TTT server. Join the fun!

Offline Milk_

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
hm.. whenever somebody on my server almost reaches 2 weeks, they reset back to 1 week.