Jump to content

ERROR: attempt to compare number with nil


Maruchan

Recommended Posts

I have tried to fix this problem but have not succeeded. Please hope someone can help me with this erorr.

ERROR: attempt to compare number with nil

 

function Seleccion()	 	
		 
		 fadeCamera(false,0.0)
		 showChat(false)
		 for i = 1, 8 do
		 guiSetVisible(buttons[i],true)	 
		 end
		 
		 if hour >= 6 and hour <= 11 then	-- ERROR HERE 
		 guiSetVisible(Temprano,true)
		 
		 elseif hour >= 12 and hour <= 17 then
		 guiSetVisible(Tarde,true)		 
		 
		 elseif hour >= 18 and hour <= 23 then
		 guiSetVisible(Noche,true)
	
		 elseif hour >= 1 and hour <= 5 then
		 guiSetVisible(Madrugada,true)
		 end
		 showCursor(true)		 
end
addEvent("Seleccion",true)
addEventHandler("Seleccion",getRootElement(),Seleccion)

 

Link to comment
function Seleccion()	 
		 
		 fadeCamera(false,0.0)
		 showChat(false)
		 for i = 1, 8 do
		 guiSetVisible(buttons[i],true)	 
		 end
		 
		 local time = getRealTime()
		 local hours = time.hour
		 local minutes = time.minute
		 local seconds = time.second
		 
		 if hour >= 6 and hour <= 11 then	 
		 guiSetVisible(Temprano,true)
		 
		 elseif hour >= 12 and hour <= 17 then
		 guiSetVisible(Tarde,true)		 
		 
		 elseif hour >= 18 and hour <= 23 then
		 guiSetVisible(Noche,true)
	
		 elseif hour >= 1 and hour <= 5 then
		 guiSetVisible(Madrugada,true)
		 end
		 showCursor(true)		 
end
addEvent("Seleccion",true)
addEventHandler("Seleccion",getRootElement(),Seleccion)

this?

Link to comment

Now???

 

function Seleccion()	 
		 
		 fadeCamera(false,0.0)
		 showChat(false)
		 for i = 1, 8 do
		 guiSetVisible(buttons[i],true)	 
		 end
		 
		 local time = getRealTime()
		 local hour = time.hour

		 if hour >= 6 and hour <= 11 then	 
		 guiSetVisible(Temprano,true)
		 
		 elseif hour >= 12 and hour <= 17 then
		 guiSetVisible(Tarde,true)		 
		 
		 elseif hour >= 18 and hour <= 23 then
		 guiSetVisible(Noche,true)
	
		 elseif hour >= 1 and hour <= 5 then
		 guiSetVisible(Madrugada,true)
		 end
		 showCursor(true)		 
end
addEvent("Seleccion",true)
addEventHandler("Seleccion",getRootElement(),Seleccion)

 

Edited by Maruchan
Link to comment
6 hours ago, Maruchan said:

Now???

 


function Seleccion()	 
		 
		 fadeCamera(false,0.0)
		 showChat(false)
		 for i = 1, 8 do
		 guiSetVisible(buttons[i],true)	 
		 end
		 
		 local time = getRealTime()
		 local hour = time.hour

		 if hour >= 6 and hour <= 11 then	 
		 guiSetVisible(Temprano,true)
		 
		 elseif hour >= 12 and hour <= 17 then
		 guiSetVisible(Tarde,true)		 
		 
		 elseif hour >= 18 and hour <= 23 then
		 guiSetVisible(Noche,true)
	
		 elseif hour >= 1 and hour <= 5 then
		 guiSetVisible(Madrugada,true)
		 end
		 showCursor(true)		 
end
addEvent("Seleccion",true)
addEventHandler("Seleccion",getRootElement(),Seleccion)

 

Do u want a real time or IN-Game time? 

Link to comment

Well that should work, please note that if used on client side that returns the clients computer time witch might be different from server time! A work around will be to set the game time as the real time on server side and get the game time on the client. If not you can set it as an elementData on root element and update that data every hour on server 

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