Al3grab Posted October 28, 2011 Posted October 28, 2011 (edited) Hi , i want to make a counting by dxDrawText like : 1 2 3 4 5 , i made it using setTimer : my code : function Count() local sw, sh = guiGetScreenSize() function txt1 ( ) dxDrawText( "1", 44, sh-450, sw, sh, tocolor ( 255, 255, 0, 255 ), 4, "default" ) end function txt2() dxDrawText( "2", 44, sh-450, sw, sh, tocolor ( 255, 150, 0, 255 ), 4, "default" ) end function txt3() dxDrawText( "3", 44, sh-450, sw, sh, tocolor ( 255, 100, 0, 255 ), 4, "default" ) end function txt4() dxDrawText( "4", 44, sh-450, sw, sh, tocolor ( 255, 50, 0, 255 ), 4, "default" ) end function txt5() dxDrawText( "5", 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end addEventHandler("onClientRender",getRootElement(), txt1) setTimer(function() removeEventHandler("onClientRender",getRootElement(), txt1) addEventHandler("onClientRender",getRootElement(), txt2) end,1000,1,true) setTimer(function() removeEventHandler("onClientRender",getRootElement(), txt2) addEventHandler("onClientRender",getRootElement(), txt3) end,2000,1,true) setTimer(function() removeEventHandler("onClientRender",getRootElement(), txt3) addEventHandler("onClientRender",getRootElement(), txt4) end,3000,1,true) setTimer(function() removeEventHandler("onClientRender",getRootElement(), txt4) addEventHandler("onClientRender",getRootElement(), txt5) end,4000,1,true) setTimer(function() removeEventHandler("onClientRender",getRootElement(), txt5) end,5000,1,true) end it works fine but if i want to count much than 5 maybe 50 or 40 ! is there an easier way ? Edited October 28, 2011 by Guest ING : [xXx]~Al3grab
JR10 Posted October 28, 2011 Posted October 28, 2011 local count = 0 addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() count = count + 1 end, 1000 , 50 ) --You can change the number of counts, that 50 over there. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
CapY Posted October 28, 2011 Posted October 28, 2011 local count = 0 addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() count = count + 1 end, 1000 , 50 ) --You can change the number of counts, that 50 over there. Sh and sw are not defined.
JR10 Posted October 28, 2011 Posted October 28, 2011 local sw, sh = guiGetScreenSize() local count = 0 addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() count = count + 1 end, 1000 , 50 ) --You can change the number of counts, that 50 over there. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Al3grab Posted October 28, 2011 Author Posted October 28, 2011 local count = 0 addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() count = count + 1 end, 1000 , 50 ) --You can change the number of counts, that 50 over there. You Are Smart ! Thanks , but ! , count should be like this "0" , so i edited it and now it works local n = 0 local count = ""..n.."" addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() n = n + 1 count = ""..n.."" end, 1000 , 50 ) ING : [xXx]~Al3grab
CapY Posted October 28, 2011 Posted October 28, 2011 local count = 0 addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() count = count + 1 end, 1000 , 50 ) --You can change the number of counts, that 50 over there. You Are Smart ! Thanks , but ! , count should be like this "0" , so i edited it and now it works local n = 0 local count = ""..n.."" addEventHandler ( "onClientRender" , root , function() dxDrawText( count, 44, sh-450, sw, sh, tocolor ( 255, 0, 0, 255 ), 4, "default" ) end) setTimer ( function() n = n + 1 count = ""..n.."" end, 1000 , 50 ) That's the same thing.
Al3grab Posted October 28, 2011 Author Posted October 28, 2011 it didn't worked first time ING : [xXx]~Al3grab
karlis Posted October 28, 2011 Posted October 28, 2011 it need string indeed, just do tostring(n) when drawing it. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Al3grab Posted October 28, 2011 Author Posted October 28, 2011 it need string indeed, just do tostring(n) when drawing it. thanks , but its already works now =D ,thx to JR10 ING : [xXx]~Al3grab
JR10 Posted October 28, 2011 Posted October 28, 2011 You're welcome. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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