falconthunder Posted March 1, 2019 Share Posted March 1, 2019 Hello, I need a marker timer script which starts a timer on screen for that player who hit marker X and stopped when that player hit marker Y. And when that player hits marker X again without hitting marker Y, it restarts/reset timer again. Help me pls. Link to comment
Moderators Patrick Posted March 1, 2019 Moderators Share Posted March 1, 2019 1 hour ago, falconthunder said: Hello, I need a marker timer script which starts a timer on screen for that player who hit marker X and stopped when that player hit marker Y. And when that player hits marker X again without hitting marker Y, it restarts/reset timer again. Help me pls. local sx, sy = guiGetScreenSize() function renderTime() local currentTime = getTickCount() local elapsedTime = (currentTime - startTime) / 1000 dxDrawText(elapsedTime, 0, 0, sx, sy/4, tocolor(255,255,255,255), 2, "default-bold", "center", "center") end addEventHandler("onClientMarkerHit", startMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to startMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- timer already started, need to reset it startTime = getTickCount() else -- timer not running, you need to start the onClientRender and display time on client's screen started = true startTime = getTickCount() addEventHandler("onClientRender", root, renderTime) end end end) addEventHandler("onClientMarkerHit", endMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to endMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- if the timer is running need to stop it. local currentTime = getTickCount() local elapsedTime = currentTime - startTime outputChatBox("Your time is: " .. elapsedTime) removeEventHandler("onClientRender", root, renderTime) started = false end end end) 1 Link to comment
falconthunder Posted March 1, 2019 Author Share Posted March 1, 2019 (edited) It will be better if you show me how I can set Marker X and Marker Y location in this script. Idk where to add xyz locations of markers in this script. Edited March 1, 2019 by falconthunder Link to comment
Moderators Patrick Posted March 1, 2019 Moderators Share Posted March 1, 2019 28 minutes ago, falconthunder said: It will be better if you show me how I can set Marker X and Marker Y location in this script. Idk where to add xyz locations of markers in this script. local startMarker = createMarker(0,0,3, "cylinder", 1, 0, 255, 0) -- The start marker (Here you can change the marker's position and color) local endMarker = createMarker(0,10,3, "cylinder", 1, 255, 0, 0) -- The end marker (Here you can change the marker's position and color) local sx, sy = guiGetScreenSize() function renderTime() local currentTime = getTickCount() local elapsedTime = (currentTime - startTime) / 1000 dxDrawText(elapsedTime, 0, 0, sx, sy/4, tocolor(255,255,255,255), 2, "default-bold", "center", "center") end addEventHandler("onClientMarkerHit", startMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to startMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- timer already started, need to reset it startTime = getTickCount() else -- timer not running, you need to start the onClientRender and display time on client's screen started = true startTime = getTickCount() addEventHandler("onClientRender", root, renderTime) end end end) addEventHandler("onClientMarkerHit", endMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to endMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- if the timer is running need to stop it. local currentTime = getTickCount() local elapsedTime = currentTime - startTime outputChatBox("Your time is: " .. elapsedTime) removeEventHandler("onClientRender", root, renderTime) started = false end end end) 1 Link to comment
falconthunder Posted March 1, 2019 Author Share Posted March 1, 2019 (edited) 10 minutes ago, stPatrick said: local startMarker = createMarker(0,0,3, "cylinder", 1, 0, 255, 0) -- The start marker (Here you can change the marker's position and color) local endMarker = createMarker(0,10,3, "cylinder", 1, 255, 0, 0) -- The end marker (Here you can change the marker's position and color) local sx, sy = guiGetScreenSize() function renderTime() local currentTime = getTickCount() local elapsedTime = (currentTime - startTime) / 1000 dxDrawText(elapsedTime, 0, 0, sx, sy/4, tocolor(255,255,255,255), 2, "default-bold", "center", "center") end addEventHandler("onClientMarkerHit", startMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to startMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- timer already started, need to reset it startTime = getTickCount() else -- timer not running, you need to start the onClientRender and display time on client's screen started = true startTime = getTickCount() addEventHandler("onClientRender", root, renderTime) end end end) addEventHandler("onClientMarkerHit", endMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to endMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- if the timer is running need to stop it. local currentTime = getTickCount() local elapsedTime = currentTime - startTime outputChatBox("Your time is: " .. elapsedTime) removeEventHandler("onClientRender", root, renderTime) started = false end end end) sry for this, i am nub scripter ERROR: editor_test\timer.lua:5: attempt to call global 'guiGetScreenSize' (a nil value) Edited March 1, 2019 by falconthunder Link to comment
Moderators Patrick Posted March 1, 2019 Moderators Share Posted March 1, 2019 13 minutes ago, falconthunder said: sry for this, i am nub scripter ERROR: editor_test\timer.lua:5: attempt to call global 'guiGetScreenSize' (a nil value) This is a client side script. 1 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