TheMaysTRo Posted February 7, 2016 Share Posted February 7, 2016 Hello there ,Im working on my own gamemode , and I want to create a timer when the map start and I will change the map when it ends. My problem is each player have his own timer . Maybe Because im working on client side ? I tried server side and it didn't work . This is my code (client sided ) : theTimer = setTimer(function() end, 60000, 1) -- A timer that does nothing. screenX,screenY = guiGetScreenSize() function createText () remaining, executesRemaining, totalExecutes = getTimerDetails(theTimer) -- Get the timers details if (remaining) then dxDrawRectangle (screenX *.40, screenY * .09, 250, 50, tocolor(0,0,0,150)) text = dxDrawText (remaining/1000, screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) else outputChatBox("Timer no longer exists") end end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end HandleTheRendering ( ) Wish you help me , Thanks . Link to comment
SpecT Posted February 7, 2016 Share Posted February 7, 2016 I'm not really sure how to do that but if you want you can take a look in the Race gamemode. Good luck! Link to comment
TheMaysTRo Posted February 7, 2016 Author Share Posted February 7, 2016 I'm not really sure how to do that but if you want you can take a look in the Race gamemode.Good luck! Tried to do that , its very complicated , to much lines and lua files , Couldn't find the right part . Thanks for your advice Link to comment
Bonus Posted February 7, 2016 Share Posted February 7, 2016 The timer is useless. Just trigger the left time in ms serversided. triggerClientEvent ( "lefttime", root, 10000 ) -- 10sec Then in addEventHandler save this rest time + getTickCount(). To get the rest time you just have to: savedtime - getTickCount() = rest time in ms. -- Client -- local timetoend = 0 addEvent ... addEventHandler ( ..., function ( resttime ) timetoend = getTickCount() + resttime end ) addCommandHandler ( "gettimer", function () outputChatBox ( "It's "..timetoend - getTickCount().."ms left" ) 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