Jump to content

Dia real


Recommended Posts

Na própria wiki tem o código, só você usar do jeito que quiser.

function showtime ()
	local time = getRealTime()
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second

        local monthday = time.monthday
	local month = time.month
	local year = time.year

        local formattedTime = string.format("%04d-%02d-%02d %02d:%02d:%02d", year, month + 1, monthday, hours, minutes, seconds)
	outputChatBox ( "Local Time: ".. formattedTime )
end
addCommandHandler("showtime", showtime)
Link to comment

Só mudar as coordenadas, testa ai..

	local time = getRealTime()
   	local dia = time.monthday
	local mes = time.month
	local ano = time.year
	local formattedTime = string.format("%04d-%02d-%02d %02d:%02d:%02d", dia, mes + 1, ano)
	dxDrawText (formattedTime, x, y , x, y , tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)

 

Edited by Nice_x #Scripting;
Link to comment
20 minutes ago, Nice_x #Scripting; said:

Só mudar as coordenadas, testa ai..


	local time = getRealTime()
   	local dia = time.monthday
	local mes = time.month
	local ano = time.year
	local formattedTime = string.format("%04d-%02d-%02d %02d:%02d:%02d", dia, mes + 1, ano)
	dxDrawText (formattedTime, x, y , x, y , tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)

 

Coordenadas? explique-me mais.

Faça assim pra obter hora e data atualmente:

addCommandHandler ("agora", function (thePlayer, cmd)
	local now = getRealTime () -- Recebe os dados do momento atual.
	local hours = now.hour
	local minutes = now.minute
	local seconds = now.second
	local days = now.monthday
	local months = now.month
	local years = now.year
	if (hours < 10) then -- Adiciona um 0 na frente, caso seja menor que 10.
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (days < 10) then
		days = "0"..days
	end
	if (months < 10) then
		months = "0"..months
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	outputChatBox ("Hora: "..hours..":"..minutes..":"..seconds..".", thePlayer, 0, 255, 0)
	outputChatBox ("Data: "..days.."/"..months + 1 .."/"..years + 1900 ..".", thePlayer, 0, 255, 0)
end)

 

Link to comment
  • 2 weeks later...
On 28/04/2019 at 19:04, Jonas^ said:

Coordenadas? explique-me mais.

Faça assim pra obter hora e data atualmente:


addCommandHandler ("agora", function (thePlayer, cmd)
	local now = getRealTime () -- Recebe os dados do momento atual.
	local hours = now.hour
	local minutes = now.minute
	local seconds = now.second
	local days = now.monthday
	local months = now.month
	local years = now.year
	if (hours < 10) then -- Adiciona um 0 na frente, caso seja menor que 10.
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (days < 10) then
		days = "0"..days
	end
	if (months < 10) then
		months = "0"..months
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	outputChatBox ("Hora: "..hours..":"..minutes..":"..seconds..".", thePlayer, 0, 255, 0)
	outputChatBox ("Data: "..days.."/"..months + 1 .."/"..years + 1900 ..".", thePlayer, 0, 255, 0)
end)

 

Opa, então eu tentei usar esses códigos que vocês me passou pra criar um dxDrawRectangle e pra colocar a hora e os minutos na hud não conseguir me ajuda?

Link to comment
2 minutes ago, Jonas^ said:

Quase isso, tente e mostre como você tentou se não conseguir.

	local now = getRealTime () -- Recebe os dados do momento atual.
	local hours = now.hour
	local minutes = now.minute
	local seconds = now.second
	local days = now.monthday
	local months = now.month
	local years = now.year
	if (hours < 10) then -- Adiciona um 0 na frente, caso seja menor que 10.
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	dxDrawText(" "..hours..":"..minutes.." ", x*1133, y*100, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, dxfont0_font, "left", "center", false, false, false, false, false)

não deu :"/

Link to comment

Sim, falta o onclientrender.

addEventHandler ("onClientRender", root, function ()
	local now = getRealTime () -- Recebe os dados do momento atual.
	local hours = now.hour
	local minutes = now.minute
	local seconds = now.second
	local days = now.monthday
	local months = now.month
	local years = now.year
	if (hours < 10) then -- Adiciona um 0 na frente, caso seja menor que 10.
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	dxDrawText(" "..hours..":"..minutes.." ", x*1133, y*100, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, dxfont0_font, "left", "center", false, false, false, false, false)
end)

 

Link to comment
	local now = getRealTime () -- Recebe os dados do momento atual.
	local hours = now.hour
	local minutes = now.minute
	local seconds = now.second
	local days = now.monthday
	local months = now.month
	local years = now.year
	if (hours < 10) then -- Adiciona um 0 na frente, caso seja menor que 10.
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end

function horas()
  
	dxDrawText(" "..hours..":"..minutes.." ", x*1133, y*100, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, dxfont0_font, "left", "center", false, false, false, false, false)
end
addEventHandler("onClientRender", root, horas)

EDIT:Nao testado

Edited by Eficiencia
Link to comment

 

1 minute ago, Jonas^ said:

Sim, falta o onclientrender.


addEventHandler ("onClientRender", root, function ()
	local now = getRealTime () -- Recebe os dados do momento atual.
	local hours = now.hour
	local minutes = now.minute
	local seconds = now.second
	local days = now.monthday
	local months = now.month
	local years = now.year
	if (hours < 10) then -- Adiciona um 0 na frente, caso seja menor que 10.
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	dxDrawText(" "..hours..":"..minutes.." ", x*1133, y*100, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, dxfont0_font, "left", "center", false, false, false, false, false)
end)

 

Deu um erro na linha do seconds

 

Link to comment
6 minutes ago, Luccas said:

Sim deu certo obrigado! A vocês dois. Só tá dando um erro na fonte mais vou mudar a fonte :) 

Você pode retribuir a ajuda de alguma forma clicando no botão de coração ao lado dos comentários :) 

  • Like 1
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...