LukisLT Posted June 30, 2012 Share Posted June 30, 2012 Hi guys, i know.. i'm lazzy, but i need your help, i have made an gui, made bind key for him etc.. now for me the hardest part... how to make this : labels : Time : Date : and i'm trying to make, that i could see after " Time " and " Date " the real time and date.. that is today, i'm still learning Lua codes, so i think here is the best place to ask for help Thanks~ Lukas. Link to comment
TAPL Posted June 30, 2012 Share Posted June 30, 2012 https://wiki.multitheftauto.com/wiki/GetRealTime Link to comment
Castillo Posted June 30, 2012 Share Posted June 30, 2012 function getCurrentDateAndTime ( ) local realTime = getRealTime ( ) local cDate = string.format ( "%04d/%02d/%02d", realTime.year + 1900, realTime.month + 1, realTime.monthday ) local cTime = string.format ( "%02d:%02d:%02d", realTime.hour, realTime.minute, realTime.second ) return cDate, cTime end cDate, cTime = getCurrentDateAndTime ( ) Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 Didn't worked for me, not showing the number there where i want them to show... Link to comment
TAPL Posted June 30, 2012 Share Posted June 30, 2012 Didn't worked for me, not showing the number there where i want them to show... show your code. Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 I used the code of Solid's, and other code is just a gui, with " Time " and " Date " labels i wath to make : "Time : 00:00:00" and "Date 30/6/2012" for example beside the labels, the function he gived, is not showing errors, but not work too. Link to comment
Kenix Posted June 30, 2012 Share Posted June 30, 2012 function GetCurrentDateAndTime ( ) local aRealTime = getRealTime ( ) return string.format ( "%04d/%02d/%02d", aRealTime.year + 1900, aRealTime.month + 1, aRealTime.monthday ), string.format ( "%02d:%02d:%02d", aRealTime.hour, aRealTime.minute, aRealTime.second ) end local sDate, sTime = GetCurrentDateAndTime( ) guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Time: ' .. sTime .. ' Date ' .. sDate , true ) ? Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 Thank you Kenix it works now, only small bug, i need to move text to my possition, and once o close gui, time still showing, not clossing with the gui. but, thank you, you helped me, at least to make the time show. not in gui but still, i will try to fix somehow, or else, i be back here. Thanks~ Lukas. Link to comment
Kenix Posted June 30, 2012 Share Posted June 30, 2012 I don't understand what you mean. Explain better pls. Link to comment
TAPL Posted June 30, 2012 Share Posted June 30, 2012 Thank you Kenix it works now, only small bug, i need to move text to my possition, and once o close gui, time still showing, not clossing with the gui. but, thank you, you helped me, at least to make the time show. not in gui but still, i will try to fix somehow, or else, i be back here.Thanks~ Lukas. You have to use parent argument. https://wiki.multitheftauto.com/wiki/GuiCreateLabel Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 This is little example of what i meant to say in my last message : Link to comment
Kenix Posted June 30, 2012 Share Posted June 30, 2012 You should use parent argument. TAPL said before. Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 Thank you, i will try to do that, learning learning i hope one day i'll be good as you. Link to comment
TAPL Posted June 30, 2012 Share Posted June 30, 2012 Since you already have create the label at the gui, why you don't use guiSetText? i think you already will need to update the time - date at the label you will need to use event onClientRender or a timer to update the time - date in the label. Link to comment
Kenix Posted June 30, 2012 Share Posted June 30, 2012 (edited) you will need to use event onClientRender or a timer to update the time - date in the label. Never use onClientRender for this target. Use timer instead. Think please before post advice. Edited June 30, 2012 by Guest Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 Yes, i have this bug, once i start script, time doesn't tick, like on clock, to see the real time i must " restart script " or " reconncet " to update current time and date. so i will try to add render functions as you just sayd, and thanks for help or timer, so i wount need reconnect just to see current time Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 And one more question, i made bind key function, but there is some mistake, the panel pops up everytime i connect to server, how could i do, that the panel pops up only when i press the " bind key " ? that would be helpfull for me. Link to comment
TAPL Posted June 30, 2012 Share Posted June 30, 2012 And one more question, i made bind key function, but there is some mistake, the panel pops up everytime i connect to server, how could i do, that the panel pops up only when i press the " bind key " ? that would be helpfull for me. you need to use guiSetVisible after create the gui window. Example: theWindow = guiCreateWindow(100,200,50,50,"Example",false) guiSetVisible(theWindow,false) https://wiki.multitheftauto.com/wiki/GuiSetVisible Link to comment
LukisLT Posted June 30, 2012 Author Share Posted June 30, 2012 Yes thanks, i did it and it's worked for me, but last my problem, the function i using, to create time and date labels, it's outside the gui, trying hard, but no succes, to put the text in the gui. Link to comment
Smart. Posted July 1, 2012 Share Posted July 1, 2012 Yes thanks, i did it and it's worked for me, but last my problem, the function i using, to create time and date labels, it's outside the gui, trying hard, but no succes, to put the text in the gui. Thank you Kenix it works now, only small bug, i need to move text to my possition, and once o close gui, time still showing, not clossing with the gui. but, thank you, you helped me, at least to make the time show. not in gui but still, i will try to fix somehow, or else, i be back here.Thanks~ Lukas. You have to use parent argument. https://wiki.multitheftauto.com/wiki/GuiCreateLabel parent: This is the parent that the gui label is attached to. If the relative argument is true, sizes and positioning will be made relative to this parent. If the relative argument is false, positioning will be the number of offset pixels from the parent's origin. If no parent is passed, the parent will become the screen - causing positioning and sizing according to screen positioning. Link to comment
TAPL Posted July 1, 2012 Share Posted July 1, 2012 Yes thanks, i did it and it's worked for me, but last my problem, the function i using, to create time and date labels, it's outside the gui, trying hard, but no succes, to put the text in the gui. Since you already have create the label at the gui, why you don't use guiSetText?i think you already will need to update the time - date at the label you will need to use event onClientRender or a timer to update the time - date in the label. Link to comment
LukisLT Posted July 1, 2012 Author Share Posted July 1, 2012 Well, gui is created, but i didn't made label in the gui for time & date, coz Kenix function makes the label, but the label is out of panel directories, just playing around, and trying to get the text in the panel gui... but no succes so far. Link to comment
Smart. Posted July 1, 2012 Share Posted July 1, 2012 Well, gui is created, but i didn't made label in the gui for time & date, coz Kenix function makes the label, but the label is out of panel directories, just playing around, and trying to get the text in the panel gui... but no succes so far. Show us your code -.- Link to comment
TAPL Posted July 1, 2012 Share Posted July 1, 2012 This is little example of what i meant to say in my last message : Well, gui is created, but i didn't made label in the gui for time & date, coz Kenix function makes the label, but the label is out of panel directories, just playing around, and trying to get the text in the panel gui... but no succes so far. dude you already create the label look at your image ! wasn't you need to update the label? how you're doing it? You need to use guiSetText and delete the label in Kenix function https://wiki.multitheftauto.com/wiki/GuiSetText Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now