Maruchan Posted April 30, 2021 Share Posted April 30, 2021 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
Administrators Tut Posted April 30, 2021 Administrators Share Posted April 30, 2021 @Maruchan your thread has been moved into Scripting section. Scripting Tutorials is for tutorials only. This is the third time I move your threads, please remember this next time you make a thread. 1 Link to comment
SpecT Posted April 30, 2021 Share Posted April 30, 2021 Hello, It looks like the variable "hour" is not declared or has no value set (at least in the code you shared). This is why it throws you an error that it can't compare "nothing" with a number. You will have to use getTime (game current time) or getRealTime (server/client current time). Link to comment
Maruchan Posted April 30, 2021 Author Share Posted April 30, 2021 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
SpecT Posted May 1, 2021 Share Posted May 1, 2021 Kind of. You won't need the minutes and seconds variables. And you will have to rename the "hours" var to "hour". As you can see in the if operators it compares the "hour" var with numbers. Link to comment
Maruchan Posted May 2, 2021 Author Share Posted May 2, 2021 (edited) 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 May 2, 2021 by Maruchan Link to comment
Bean666 Posted May 2, 2021 Share Posted May 2, 2021 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
Maruchan Posted May 2, 2021 Author Share Posted May 2, 2021 What I am looking for is a real time with images. That one image appears in the morning, another in the afternoon, etc. Link to comment
Tekken Posted May 2, 2021 Share Posted May 2, 2021 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 1 Link to comment
Maruchan Posted May 2, 2021 Author Share Posted May 2, 2021 What I would like is for the weather to be logical according to the schedule. But since I am a newbie, I am not sure which IDs to use to achieve this. Link to comment
Maruchan Posted May 3, 2021 Author Share Posted May 3, 2021 13 hours ago, Tekken said: What schedule ? Ya logré hacerlo, de todos modos muchas gracias por tu preocupación. 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