Jump to content

Weird thing


FuriouZ

Recommended Posts

Posted

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) 

Posted

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 

Posted (edited)

Thanks to you all :)

I used mcer's code, thanks all works fine now,but month and year is still wrong

[EDIT]: Fixed and deleted code.

Edited by Guest
Posted

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)

Posted
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

Posted
local month = time.month + 1 
local year = time.year + 1900 

Thanks AlcatRaz ! and all who helped me , all is fine now :)

I still have one last question, how to do if the clock is 11:04 then it is 11:04 not 11:4

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...