Jump to content

[Solved] Counting With dxDrawText


Al3grab

Recommended Posts

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 ?

:D

Edited by Guest
Link to comment
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. 

Link to comment
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.

Link to comment
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. 

Link to comment
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 ) 
  

Link to comment
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.

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