Jump to content

Weird thing


FuriouZ

Recommended Posts

Try this

        --Values 
        GUIEditor = {} 
        local timeB = getRealTime() 
        local rRoot = resourceRoot 
        local monthday = timeB.monthday 
        local month = timeB.month 
        local year = timeB.year 
         function drawUserpanel() 
                GUIEditor.sidebar = guiCreateStaticImage(0.84, 0.00, 0.16, 1.00, "img/sidebar.png", true) 
        --Clock labels 
                GUIEditor.clockHoursLabel = guiCreateLabel(0.00, 0.00, 0.797, 0.12, "Hours", true, GUIEditor.sidebar) 
                GUIEditor.clockMinutesLabel = guiCreateLabel(0.00, 0.00, 1.197, 0.12, "Minutes", true, GUIEditor.sidebar) 
                GUIEditor.dateLabel = guiCreateLabel(0.08, 0.09, 0.89, 0.03, ""..monthday.."."..month.."."..year.."", true, GUIEditor.sidebar) 
        setTimer ( function() 
            local timeC = getRealTime() 
            local minutes = timeC.minute 
            local hours = timeC.hour 
            guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") 
            guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") 
        end, 50, 0 
        ) 
        end 
        addEventHandler("onClientResourceStart", rRoot,drawUserpanel) 

Link to comment

use this code, your time variables were global and never updated.

--Values 
GUIEditor = {} 
local rRoot = resourceRoot 
local doRender = false 
function drawUserpanel() 
    GUIEditor.sidebar = guiCreateStaticImage(0.84, 0.00, 0.16, 1.00, "img/sidebar.png", true) 
  
    GUIEditor.clockHoursLabel = guiCreateLabel(0.00, 0.00, 0.797, 0.12, "Hours", true, GUIEditor.sidebar) 
    GUIEditor.clockMinutesLabel = guiCreateLabel(0.00, 0.00, 1.197, 0.12, "Minutes", true, GUIEditor.sidebar) 
    GUIEditor.dateLabel = guiCreateLabel(0.08, 0.09, 0.89, 0.03, "monthday.month.year", true, GUIEditor.sidebar) 
    doRender = true 
    addEventHandler ( "onClientRender", root, executeRender ) 
end 
addEventHandler("onClientResourceStart", rRoot,drawUserpanel) 
  
function executeRender ( ) 
    if ( doRender ) then 
        local time = getRealTime() 
        local hours = time.hour 
        local minutes = time.minute 
        local monthday = time.monthday 
        local month = time.month 
        local year = time.year 
         
        guiSetText ( GUIEditor.clockHoursLabel, hours..":" ) 
        guiSetText ( GUIEditor.clockMinutesLabel, minutes..":" ) 
        guiSetText ( GUIEditor.dateLabel, table.concat ( { monthday, month, year }, "." ) ) 
    else 
        removeEventHandler ( 'onClientRender', root, executeRender ) 
    end 
end 

Link to comment

Oh, sorry, did not see this part:

setTimer ( function() 
    guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") 
    guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") 
end, 50, 0 
) 

You will need to get the 'new' time every time you execute the timer:

setTimer ( function() 
    local time = getRealTime() 
    local minute = time.minute 
    local hours = time.hour 
    guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") 
    guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") 
end, 50, 0 
) 

(Just in case you still don't know where the problem was)

Link to comment
Oh, sorry, did not see this part:
setTimer ( function() 
    guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") 
    guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") 
end, 50, 0 
) 

You will need to get the 'new' time every time you execute the timer:

setTimer ( function() 
    local time = getRealTime() 
    local minute = time.minute 
    local hours = time.hour 
    guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") 
    guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") 
end, 50, 0 
) 

(Just in case you still don't know where the problem was)

God, clock works fine now, updates itself,but date is wrong sould be 21.12.2013 but it is 21.11.133 lol

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...