JuniorMelo Posted August 12, 2013 Posted August 12, 2013 (edited) Hello I have a problem in this script/b] the time does not work Error addEventHandler( "onClientResourceStart", getRootElement(), function() addEventHandler("onClientRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), timestart) end,1000000,1) end) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(0.2537,0.13,0.42,0.715,"Panel Test",true) guiSetAlpha(GUIEditor_Window[1],1) y = guiCreateLabel(25,33,307,30,"Time:",false,GUIEditor_Window[1]) guiLabelSetColor(y,0,255,0) guiSetText ( y, (tostring(convertMS(timeLeft)) or 'BUG')) function timestart() if isTimer(timer) then local timeLeft = math.ceil(getTimerDetails(timer) / 1000) if guiGetVisible(GUIEditor_Window[1],true) then else guiSetText(y,"Time :"..(tostring(convertMS(timeLeft)) or 'BUG')) end end end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end Edited August 12, 2013 by Guest ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
denny199 Posted August 12, 2013 Posted August 12, 2013 Where's "timeLeft" ? Sometimes I dream about cheese
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 Where's "timeLeft" ? if isTimer(timer) then local timeLeft = math.ceil(getTimerDetails(timer) / 1000) ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
tosfera Posted August 12, 2013 Posted August 12, 2013 remove the Local from local timeLeft. try this; addEventHandler( "onClientResourceStart", getRootElement(getThisResource()), function() addEventHandler("onClientRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), timestart) end,1000000,1) end) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(0.2537,0.13,0.42,0.715,"Panel Test",true) guiSetAlpha(GUIEditor_Window[1],1) y = guiCreateLabel(25,33,307,30,"Time:",false,GUIEditor_Window[1]) guiLabelSetColor(y,0,255,0) guiSetText ( y, (tostring(convertMS(timeLeft)) or 'BUG')) function timestart() if isTimer(timer) then timeLeft = math.ceil(getTimerDetails(timer) / 1000) if not guiGetVisible(GUIEditor_Window[1],true) then guiSetText(y,"Time :"..(tostring(convertMS(timeLeft)) or 'BUG')) end end end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 no working ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
tosfera Posted August 12, 2013 Posted August 12, 2013 I'll give it a go. Whats the script supposed to do, start a timer when the resource starts and print it out to the screen? If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
golanu21 Posted August 12, 2013 Posted August 12, 2013 (edited) deleted Edited August 12, 2013 by Guest [Dev]BloWnRPG - We BloW the World [1%]
tosfera Posted August 12, 2013 Posted August 12, 2013 Thats impossible, this wont be accepted; addEventHandler( "onClientResourceStart", getRootElement(), function timestart() If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
golanu21 Posted August 12, 2013 Posted August 12, 2013 Thats impossible, this wont be accepted; addEventHandler( "onClientResourceStart", getRootElement(), function timestart() holy.... I have not seen that.Thanx [Dev]BloWnRPG - We BloW the World [1%]
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 function timestart() addEventHandler("onClientRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), timestart) end,1000000,1) end addEventHandler( "onClientResourceStart", getRootElement(), timestart ) ???? ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
golanu21 Posted August 12, 2013 Posted August 12, 2013 try it but i think is same with your first script [Dev]BloWnRPG - We BloW the World [1%]
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 try it but i think is same with your first script Yes no worked '--' ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
golanu21 Posted August 12, 2013 Posted August 12, 2013 wait, where is the function timestart for that ? addEventHandler("onClientRender", getRootElement(), timestart) [Dev]BloWnRPG - We BloW the World [1%]
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 wait, where is the function timestart for that ? addEventHandler("onClientRender", getRootElement(), timestart) function timestart() if isTimer(timer) then timeLeft = math.ceil(getTimerDetails(timer) / 1000) if not guiGetVisible(GUIEditor_Window[1],true) then guiSetText(y,"Time :"..(tostring(convertMS(timeLeft)) or 'BUG')) end end end ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
golanu21 Posted August 12, 2013 Posted August 12, 2013 GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(0.2537,0.13,0.42,0.715,"Panel Test",true) guiSetAlpha(GUIEditor_Window[1],1) y = guiCreateLabel(25,33,307,30,"Time:",false,GUIEditor_Window[1]) guiLabelSetColor(y,0,255,0) guiSetText ( y, (tostring(convertMS(timeLeft)) or 'BUG')) end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end function timestart() if isTimer(timer) then timeLeft = math.ceil(getTimerDetails(timer) / 1000) end if not guiGetVisible(GUIEditor_Window[1],true) then guiSetText(y,"Time :"..(tostring(convertMS(timeLeft)) or 'BUG')) end end addEventHandler( "onClientResourceStart", getRootElement(getThisResource()), function() addEventHandler("onClientRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), timestart) end,1000000,1) end) [Dev]BloWnRPG - We BloW the World [1%]
tosfera Posted August 12, 2013 Posted August 12, 2013 Melo, explain me. What does the function has to do? You want to see your time left? Why in a GUI? Why dont you just create a label on your screen that keeps updating? If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
golanu21 Posted August 12, 2013 Posted August 12, 2013 Melo, explain me. What does the function has to do? You want to see your time left? Why in a GUI? Why dont you just create a label on your screen that keeps updating? +1, or a dxDrawText [Dev]BloWnRPG - We BloW the World [1%]
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 I can not put "dxDrawText" because I'm going to use the function guiGetVisible ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
golanu21 Posted August 12, 2013 Posted August 12, 2013 yea but you can dxDrawText, without create the gui window [Dev]BloWnRPG - We BloW the World [1%]
tosfera Posted August 12, 2013 Posted August 12, 2013 just try this, is this what you want? addEventHandler( "onClientResourceStart", getRootElement(), function() addEventHandler("onClientPreRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientPreRender", getRootElement(), timestart) end,1000000,1) end) function timestart() guiSetText(label, "Time: "); label = guiCreateLabel(0.0, 0.95, 0.1, 0.1, "Time: ".. convertMS(math.ceil(getTimerDetails(timer) / 1000)), true); end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
JuniorMelo Posted August 12, 2013 Author Posted August 12, 2013 just try this, is this what you want? addEventHandler( "onClientResourceStart", getRootElement(), function() addEventHandler("onClientPreRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientPreRender", getRootElement(), timestart) end,1000000,1) end) function timestart() guiSetText(label, "Time: "); label = guiCreateLabel(0.0, 0.95, 0.1, 0.1, "Time: ".. convertMS(math.ceil(getTimerDetails(timer) / 1000)), true); end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end Yes thank you ........... \__ ▄▂_ .........[█|||███████]▄▄▄▄▄▄▄▄▄▃▂ ..__▂▄▅█████████▅▄▃▂ I███████████████████] ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤ ░░░███████ ]▄▄▄▄▄▄▄▄ ▂▄▅████████▅▄▃▂ I███████████████████] ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
tosfera Posted August 12, 2013 Posted August 12, 2013 No problemo. haha. If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
golanu21 Posted August 12, 2013 Posted August 12, 2013 No problemo. haha. gj tosfera [Dev]BloWnRPG - We BloW the World [1%]
denny199 Posted August 13, 2013 Posted August 13, 2013 just try this, is this what you want? addEventHandler( "onClientResourceStart", getRootElement(), function() addEventHandler("onClientPreRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientPreRender", getRootElement(), timestart) end,1000000,1) end) function timestart() guiSetText(label, "Time: "); label = guiCreateLabel(0.0, 0.95, 0.1, 0.1, "Time: ".. convertMS(math.ceil(getTimerDetails(timer) / 1000)), true); end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end This is wrong. You are creating every frame a label... Use this: addEventHandler( "onClientResourceStart", getRootElement(), function() label = guiCreateLabel(0.0, 0.95, 0.1, 0.1, "Time: ", true); addEventHandler("onClientRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), timestart) end,1000000,1) end) function timestart() guiSetText(label, "Time: " ..convertMS(math.ceil(getTimerDetails(timer) / 1000)) ) end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end Sometimes I dream about cheese
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