Jump to content

count dxdraw


yoya99

Recommended Posts

hello i have this countdown resource and i want it to make a text at the players screen like playername... starts the countdown ... 3 ,2,1 GO ! or something :( thx

time = {} 
    function Countdown (player, cmd) 
      if isTimer(time[player]) then return end 
        time[player] = setTimer(function() time[player] = nil end,30000,1) 
        local name = getPlayerName(player) 
        local r,g,b = getPlayerNametagColor (player) 
        local accountname = getAccountName (getPlayerAccount(player)) 
        outputChatBox ( "" .. name .. ": #FF9600 Starts the Countdown !", getRootElement(), r, g, b, true ) 
        outputChatBox ( "#FF0000 ===3===", getRootElement(), 255, 255, 255, true ) 
        triggerClientEvent("triggerclientforGridCountdown", getRootElement()) 
        setTimer ( Countdown5, 1000, 1 ) 
    end 
    function Countdown5 ( root ) 
        outputChatBox ( "#FF0000 ===2===", getRootElement(), 255, 255, 255, true ) 
        setTimer ( Countdown4, 1000, 1 ) 
    end 
    function Countdown4 ( root ) 
        outputChatBox ( "#FF0000 ===1===", getRootElement(), 255, 255, 255, true ) 
        setTimer ( Countdown3, 1000, 1 ) 
    end 
    function Countdown3 ( root ) 
        outputChatBox ( "#FF0000 Go Go Go!!!", getRootElement(), 255, 255, 255, true ) 
        setTimer ( Countdown2, 1000, 1 ) 
    end 
      
    addCommandHandler( "countdown", Countdown ) 

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 
addEvent ( "triggerclientforGridCountdown", true ) 
addEventHandler ( "triggerclientforGridCountdown", getRootElement(), GridCountdown ) 

Link to comment

Server

timers = {} 
    function Countdown (player) 
      if isTimer(timers[player]) then return end 
  
        timers[player] = setTimer(function() timers[player] = nil end,30000,1) 
        local name = getPlayerName(player) 
        local r,g,b = getPlayerNametagColor (player) 
        outputChatBox ( " ".. name .. ": #FF9600 Starts the Countdown !", getRootElement(), r, g, b, true ) 
        local i = 4 
        setTimer( 
        function()  
            i=i-1  
            triggerClientEvent("triggerclientforGridCountdown", getRootElement(), i) 
            if (i==0) then 
                outputChatBox ( "#FF0000 Go Go Go!!!", getRootElement(), 255, 255, 255, true ) 
                return 
            end 
            outputChatBox ( "#FF0000 ==="..i.."===", getRootElement(), 255, 255, 255, true )  
        end, 1000, 4 ) 
        setTimer (function() timers[player] = nil end, 30000, 1) 
    end 
    addCommandHandler( "countdown", Countdown ) 

Client

function triggerSound(soundID) 
    sound = playSound( soundID..".mp3", false ) 
end 
  
addEvent ( "triggerclientforGridCountdown", true ) 
addEventHandler ( "triggerclientforGridCountdown", getRootElement(), triggerSound ) 

Link to comment

Server

timers = {} 
    function Countdown (player) 
      if isTimer(timers[player]) then return end 
  
        timers[player] = setTimer(function() timers[player] = nil end,30000,1) 
        local name = getPlayerName(player) 
        local r,g,b = getPlayerNametagColor (player) 
        outputChatBox ( " ".. name .. ": #FF9600 Starts the Countdown !", getRootElement(), r, g, b, true ) 
        local i = 4 
        setTimer( 
        function()  
            i=i-1  
            triggerClientEvent("triggerclientforGridCountdown", getRootElement(), i) 
            if (i==0) then 
                outputChatBox ( "#FF0000 Go Go Go!!!", getRootElement(), 255, 255, 255, true ) 
                return 
            elseif i > 0 then 
                outputChatBox ( "#FF0000 ==="..i.."===", getRootElement(), 255, 255, 255, true )  
            end 
        end, 1000, 5 ) 
        setTimer (function() timers[player] = nil end, 30000, 1) 
    end 
    addCommandHandler( "countdown", Countdown ) 

Client

i = nil 
local x, y = guiGetScreenSize() 
  
function triggerDraw(ID) 
    i = ID 
    if i == 3 then 
        drawBegin() 
    elseif i < 0 then 
        drawStop() 
    end 
end 
addEvent ( "triggerclientforGridCountdown", true ) 
addEventHandler ( "triggerclientforGridCountdown", getRootElement(), triggerDraw ) 
  
function drawOnScreen() 
    if not i then return end 
    if i > 0 then 
        dxDrawText("#FF0000==="..i.."===",0,0,x,y, tocolor(0,0,0,255), 2, "bankgothic", "center", "center", false, false, true, true) 
    else 
        dxDrawText("#FF0000Go Go Go!!!",0,0,x,y, tocolor(0,0,0,255), 2, "bankgothic", "center", "center", false, false, true, true) 
    end 
  
end 
  
function drawBegin() 
    addEventHandler( "onClientRender", getRootElement(), drawOnScreen) 
end 
  
function drawStop() 
    removeEventHandler( "onClientRender", getRootElement(), drawOnScreen) 
end 

Link to comment

If you want sound change triggerDraw function in client with that one :)

function triggerDraw(ID) 
    i = ID 
    if i == 3 then 
        drawBegin() 
    elseif i < 0 then 
        drawStop() 
        return 
    end 
    sound = playSound( i..".mp3", false ) 
end 
addEvent ( "triggerclientforGridCountdown", true ) 
addEventHandler ( "triggerclientforGridCountdown", getRootElement(), triggerDraw ) 

Link to comment

Mhm try to copy it one more time.

Client

i = nil 
local x, y = guiGetScreenSize() 
  
function triggerDraw(ID) 
    i = ID 
    if i == 3 then 
        drawBegin() 
    elseif i < 0 then 
        drawStop() 
        return 
    end 
    playSound( i..".mp3", false ) 
end 
addEvent ( "triggerclientforGridCountdown", true ) 
addEventHandler ( "triggerclientforGridCountdown", getRootElement(), triggerDraw ) 
  
function drawOnScreen() 
    if not i then return end 
    if i > 0 then 
        dxDrawText("#FF0000==="..i.."===",0,0,x,y, tocolor(0,0,0,255), 2, "bankgothic", "center", "center", false, false, true, true) 
    else 
        dxDrawText("#FF0000Go Go Go!!!",0,0,x,y, tocolor(0,0,0,255), 2, "bankgothic", "center", "center", false, false, true, true) 
    end 
  
end 
  
function drawBegin() 
    addEventHandler( "onClientRender", getRootElement(), drawOnScreen) 
end 
  
function drawStop() 
    removeEventHandler( "onClientRender", getRootElement(), drawOnScreen) 
end 

//Owh nvm :)

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