OrbTanT Posted July 17, 2014 Share Posted July 17, 2014 How to create a countdown within a dxdrawrectagle addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 200, 325, 112, 356, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) end ) To operate in front of dxtext "Time" Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 I was trying to do a count down in minutes, and in the case GetTickCount creates an account of 0 up to the time determined Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 I tried to use missiontimer more I don't understand very well how it works, or how adds in a dxdraw Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 Anyone has any idea of how to create a countdown in dxdrawtectangle? Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 Anyone has any idea of how to create a countdown in dxdrawtectangle? viewtopic.php?f=91&t=33882 Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 I don't understand very well, I was trying to do something as soon as you open the dxdrawtectangle, start to count down from 3 minutes(3:00). Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 I don't understand very well, I was trying to do something as soon as you open the dxdrawtectangle, start to count down from 3 minutes(3:00). segundos = 30 replace it with 30000 = 3 min , Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 More on the timer will be showing 3:00? Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 More on the timer will be showing 3:00? function drawDX () X,Y = guiGetScreenSize () X = X * (2.5/3) Y = Y * (1/4) dxDrawText ( getElementData(getLocalPlayer(),"secondsRemaining"), X, Y, X, Y, tocolor(255, 255, 255, 255), 5) end function showDX () addEventHandler ( "onClientRender", getRootElement(), drawDX ) end addEvent ( "showDX", true ) addEventHandler ( "showDX", getRootElement(), showDX ) function hideDX () removeEventHandler ( "onClientRender", getRootElement(), drawDX ) end addEvent ( "hideDX", true ) addEventHandler ( "hideDX", getRootElement(), hideDX ) segundos = 30000 timerEnabled = false function onS () if timerEnabled then setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source) end end addEventHandler ( "onPlayerSpawn", getRootElement(), onS ) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) end setTimer(countDown,1000,30) end addCommandHandler("inciarcontador",escreve) function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) timerEnabled = false end end function onStart () timerEnabled = false end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 I can to use this script with the dxdrawrectangle I created? addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 200, 325, 112, 356, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) end ) I put the script but does not start the counter Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 I can to use this script with the dxdrawrectangle I created? addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 200, 325, 112, 356, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) end ) I put the script but does not start the counter well , iam not very good at dx , becuase i use labels easy , but what i post will do the job without your code , it will change auto .. Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 Counter only appears when I type /counter, I'd like to leave in format of minutes. How to leave only for the counter start as soon as you open the dxdrawrectagle Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 I will try to reuse this counter just like to leave it in the form of minutes. Link to comment
Blaawee Posted July 17, 2014 Share Posted July 17, 2014 Incase if you would like to change the format to minutes and seconds like this 3:00 . I think this usefull function will do the job function msToTimeStr( ms ) if not ms then return '' end local s = math.floor( ms / 1000 ) local seconds = tostring( math.fmod( s, 60 ) ) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring( math.floor( s / 60 ) ) if #minutes == 1 then minutes = '0' .. minutes end return minutes .. ':' .. seconds end Example: function justForTest() end function msToTimeStr( ms ) if not ms then return '' end local s = math.floor( ms / 1000 ) local seconds = tostring( math.fmod( s, 60 ) ) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring( math.floor( s / 60 ) ) if #minutes == 1 then minutes = '0' .. minutes end return minutes .. ':' .. seconds end myTimer = setTimer( justForTest, 180*1000, 1 ) addEventHandler( "onClientRender", root, function( ) if isTimer( myTimer ) then remaining, _, _ = getTimerDetails(myTimer) remaining = msToTimeStr( remaining ) if remaining then dxDrawText( remaining, 100, 350, 300, 350, tocolor( 255, 255, 0 ), 1, 'arial' ) end end end ) Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 Thank you Blaawee worked perfectly, and to all who helped me Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 Help me on something, I tried to add a score, when a team kills the player from the other team, adds +1 at score, more does not operate. client: addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 225, 325, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) end ) function justForTest() end function msToTimeStr( ms ) if not ms then return '' end local s = math.floor( ms / 1000 ) local seconds = tostring( math.fmod( s, 60 ) ) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring( math.floor( s / 60 ) ) if #minutes == 1 then minutes = '0' .. minutes end return minutes .. ':' .. seconds end myTimer = setTimer( justForTest, 180*1000, 1 ) addEventHandler( "onClientRender", root, function( ) if isTimer( myTimer ) then remaining, _, _ = getTimerDetails(myTimer) remaining = msToTimeStr( remaining ) if remaining then dxDrawText( remaining, 120, 442, 350, 300, tocolor(255, 255, 255, 255), 1.0, "pricedown", "left", "top", false, false, true, false, false) end end end ) local Bscore = 0 local Wscore = 0 function onRender() local team = getPlayerTeam(localPlayer) if(getTeamName(team) == "Team1" or getTeampame(team) == "Team2") then dxDrawText("Team2", 70, 340, 319, 426, tocolor(0, 255, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Team1", 70, 380, 319, 426, tocolor(255, 0, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) dxDrawText(tostring(Bscore), 240, 340, 319, 426, tocolor(0, 255, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) dxDrawText(tostring(Wscore), 240, 380, 319, 426, tocolor(255, 0, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) end end addEventHandler("onClientRender", root, onRender) server: function onWasted(killer, weapon, bodypart) local kteam = getPlayerTeam(killer) if(getTeamName(kteam) == "Team1")then Wscore = Wscore + 1 elseif(getTeamName(kteam) == "Team2")then Bscore = Bscore + 1 end end addEventHandler("onClientPedWasted", getRootElement(), onWasted) Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 (edited) --- ClientSide all of it , addEventHandler('onClientPlayerWasted', root, function ( attacker ) if ( attacker and attacker ~= source ) and getPlayerTeam(getTeamName( attacker ) == 'Team1' ) then setElementData ( attacker, Wscore +1 ) elseif ( attacker and attacker ~= source ) and getPlayerTeam(getTeamName( attacker ) == 'Team2' ) then setElementData ( attacker, Bscore + 1 ) end end ) addEventHandler("onClientRender", root, function() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 225, 325, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) end ) function justForTest() end function msToTimeStr( ms ) if not ms then return '' end local s = math.floor( ms / 1000 ) local seconds = tostring( math.fmod( s, 60 ) ) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring( math.floor( s / 60 ) ) if #minutes == 1 then minutes = '0' .. minutes end return minutes .. ':' .. seconds end myTimer = setTimer( justForTest, 180*1000, 1 ) addEventHandler( "onClientRender", root, function( ) if isTimer( myTimer ) then remaining, _, _ = getTimerDetails(myTimer) remaining = msToTimeStr( remaining ) if remaining then dxDrawText( remaining, 120, 442, 350, 300, tocolor(255, 255, 255, 255), 1.0, "pricedown", "left", "top", false, false, true, false, false) end end end ) local Bscore = 0 local Wscore = 0 function onRender() if ( getPlayerTeam( localPlayer ) and getPlayerTeam( localPlayer ) == getTeamFromName ( "Team1" ) ) or ( getPlayerTeam( localPlayer ) and getPlayerTeam( localPlayer ) == getTeamFromName ( "Team2" ) ) then dxDrawText("Team2", 70, 340, 319, 426, tocolor(0, 255, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Team1", 70, 380, 319, 426, tocolor(255, 0, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) dxDrawText(tostring(Bscore), 240, 340, 319, 426, tocolor(0, 255, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) dxDrawText(tostring(Wscore), 240, 380, 319, 426, tocolor(255, 0, 0, 255), 1.4, "default-bold", "left", "top", false, false, true, false, false) end end addEventHandler("onClientRender", root, onRender) Edited # Edited July 17, 2014 by Guest Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 Not going to have the server side? Link to comment
Et-win Posted July 17, 2014 Share Posted July 17, 2014 I would put it serverside Max+, not clientside... onPlayerWasted Look who killed who and etc, set the score and trigger the score to the client's. Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 Not going to have the server side? nope , becuase its all client Events .. remove the serverSide scripts , and /debugscript 3 to see if there is any erros ? Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 I would put it serverside Max+, not clientside...onPlayerWasted Look who killed who and etc, set the score and trigger the score to the client's. why do it very hard with triggers and etc ? while you can use it all in ClientSide ? Link to comment
Et-win Posted July 17, 2014 Share Posted July 17, 2014 Ow wait, nvm me. Was thinking about client-side is only for the client, but of course it's for all players. Link to comment
OrbTanT Posted July 17, 2014 Author Share Posted July 17, 2014 WARNING:pasta/client.lua:67:Bad 'team"pointer @ 'getTeamName'(1) WARNING:pasta/client.lua:67:Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got boolean] Link to comment
Max+ Posted July 17, 2014 Share Posted July 17, 2014 WARNING:pasta/client.lua:67:Bad 'team"pointer @ 'getTeamName'(1)WARNING:pasta/client.lua:67:Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got boolean] Edited my post copy it again .. 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