Jump to content

Countdown bug


Guest

Recommended Posts

Guys what is wrong ?

function somethingfor()

	if getTickCount() - getTickStart > 0 and count == 0 then
		sound3 = playSound( "3.mp3", false )
		setSoundMaxDistance( sound3, 5000 )
		count = 1
	elseif getTickCount() - getTickStart > 1000 and count == 1 then	
		if sound3 and isElement(sound3) then stopSound( sound3 ) end
		sound2 = playSound( "2.mp3", false )
		setSoundMaxDistance( sound2, 5000 )
		count = 2
	elseif getTickCount() - getTickStart > 2000 and count == 2 then
		if sound2 and isElement(sound2) then stopSound( sound2 ) end
		sound1 = playSound( "1.mp3", false )
		setSoundMaxDistance( sound1, 5000 )
		count = 3
	elseif getTickCount() - getTickStart > 3000 and count == 3 then
		if sound1 and isElement(sound1) then stopSound( sound1 ) end
		sound0 = playSound( "0.mp3", false )
		setSoundMaxDistance( sound0, 5000 )
		count = 4
	elseif getTickCount() - getTickStart > 4000 and count == 4 then
		count = 5
		if sound0 and isElement(sound0) then stopSound( sound0 ) end
		removeEventHandler( "onClientRender", getRootElement(), somethingfor)
	end
end

function GridCountdown()
	count = 0
	getTickStart = getTickCount ()
	addEventHandler( "onClientRender", getRootElement(), somethingfor)
end

time = {}
    function Countdown (player, cmd)
      if isTimer(time[player]) then return end
        time[player] = setTimer(function() time[player] = nil end,30000,1)
        local screenW, screenH = guiGetScreenSize()
        local name = getPlayerName(player)
        local r,g,b = getPlayerNametagColor (player)
        local accountname = getAccountName (getPlayerAccount(player))
		addEventHandler("onClientRender", getRootElement(), Countdown) 
        dxDrawText(""..name.." has started the countdown", 218 + 1, 149 + 1, 1148 + 1, 190 + 1, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "center", "top", false, false, false, false, false)
        dxDrawText(""..name.." has started the countdown", 218, 149, 1148, 190, tocolor(255, 255, 255, 255), 1.20, "bankgothic", "center", "top", false, false, false, false, false)
        setTimer ( Countdown5, 4000, 1 )
		removeEventHandler("onClientRender", getRootElement(), Countdown)
    end
    function Countdown5 ( root )
          local screenW, screenH = guiGetScreenSize()
		addEventHandler("onClientRender", getRootElement(), Countdown) 
        dxDrawText("1", (screenW * 0.1596) + 1, (screenH * 0.2839) + 1, (screenW * 0.8404) + 1, (screenH * 0.4297) + 1, tocolor(0, 0, 0, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
        dxDrawText("1", screenW * 0.1596, screenH * 0.2839, screenW * 0.8404, screenH * 0.4297, tocolor(255, 255, 255, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
        setTimer ( Countdown4, 1000, 1 )
		removeEventHandler("onClientRender", getRootElement(), Countdown)
		
    end
    function Countdown4 ( root )
        local screenW, screenH = guiGetScreenSize()
		addEventHandler("onClientRender", getRootElement(), Countdown) 
        dxDrawText("2", (screenW * 0.1596) + 1, (screenH * 0.2839) + 1, (screenW * 0.8404) + 1, (screenH * 0.4297) + 1, tocolor(0, 0, 0, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
        dxDrawText("2", screenW * 0.1596, screenH * 0.2839, screenW * 0.8404, screenH * 0.4297, tocolor(255, 255, 255, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
        setTimer ( Countdown3, 1000, 1 )
		removeEventHandler("onClientRender", getRootElement(), Countdown)
    end
    function Countdown3 ( root )
        local screenW, screenH = guiGetScreenSize()
		addEventHandler("onClientRender", getRootElement(), Countdown) 
        dxDrawText("Go Go !!", (screenW * 0.1596) + 1, (screenH * 0.2839) + 1, (screenW * 0.8404) + 1, (screenH * 0.4297) + 1, tocolor(0, 0, 0, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
        dxDrawText("Go Go !!", screenW * 0.1596, screenH * 0.2839, screenW * 0.8404, screenH * 0.4297, tocolor(255, 255, 255, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
        setTimer ( Countdown2, 1000, 1 )
		removeEventHandler("onClientRender", getRootElement(), Countdown)
    end
     
    addCommandHandler( "countdown", Countdown )

 

Edited by Guest
Link to comment
  • Moderators

How about you use this tool to make it a lot easier:

 

Syntax:

addRenderEvent(function functionVar [, string eventName, arguments ...])
  
bool removeRenderEvent(function functionVar [, string eventName])

 

Use:

function renderCountDown (text)
	dxDrawText(text, (screenW * 0.1596) + 1, (screenH * 0.2839) + 1, (screenW * 0.8404) + 1, (screenH * 0.4297) + 1, tocolor(0, 0, 0, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
	dxDrawText(text, screenW * 0.1596, screenH * 0.2839, screenW * 0.8404, screenH * 0.4297, tocolor(255, 255, 255, 255), 4.00, "bankgothic", "center", "top", false, false, false, false, false)
end
addRenderEvent(renderCountDown, "onClientRender", 1)

-- timer

removeRenderEvent(renderCountDown, "onClientRender")
addRenderEvent(renderCountDown, "onClientRender", 2)

-- timer

removeRenderEvent(renderCountDown, "onClientRender")
addRenderEvent(renderCountDown, "onClientRender", 3)

-- timer

removeRenderEvent(renderCountDown, "onClientRender")
addRenderEvent(renderCountDown, "onClientRender", "Go!")

-- timer

removeRenderEvent(renderCountDown, "onClientRender")

+

<Add source code

https://forum.multitheftauto.com/topic/103866-src-client-render-events-enchanting/

/>

 

Link to comment

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