• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lights turns on automatic at X-time!

Wartio

Any game ideas?
Joined
Apr 2, 2010
Messages
457
Reaction score
29
Location
Sweden
I got a script from this thread:
http://otland.net/threads/light-up-the-streets-at-night.197060/

But the lights does not turn on ingame for some reason ;/

Can someone script this and make it so the All lights with id 1479 around the whole map

Code:
local t = {
{x = 1826, y = 1565, z = 7, stackpos = 2}, -- Street Lights on the Map
{x = 1837, y = 1569, z = 7, stackpos = 2},
{x = 1820, y = 1551, z = 7, stackpos = 2},
{x = 1874, y = 1591, z = 7, stackpos = 2},
{x = 1864, y = 1598, z = 7, stackpos = 2},
{x = 1851, y = 1603, z = 7, stackpos = 2},
{x = 1845, y = 1597, z = 7, stackpos = 2},
{x = 1852, y = 1592, z = 7, stackpos = 2},
{x = 1841, y = 1588, z = 7, stackpos = 2},
{x = 1810, y = 1592, z = 7, stackpos = 2},
{x = 1827, y = 1575, z = 7, stackpos = 2},
{x = 1860, y = 1574, z = 7, stackpos = 2},
{x = 1856, y = 1565, z = 7, stackpos = 2},
{x = 1842, y = 1571, z = 6, stackpos = 2},
{x = 1815, y = 1566, z = 7, stackpos = 2},
{x = 1808, y = 1546, z = 7, stackpos = 2},
{x = 1811, y = 1602, z = 7, stackpos = 2},
{x = 1808, y = 1620, z = 7, stackpos = 2},
{x = 1791, y = 1593, z = 7, stackpos = 2} -- No Comma Needed on the Last Light
}

local ret = "The city's streets are lit up. Have a safe evening."
function onTime()
for i = 1, #t do
local light = getTileItemById(t, 1479).uid
if(light > 0) then
doTransformItem(light, 1480)
ret = "The city's streets are lit up. Have a safe evening."
end
end

addEvent(broadcastMessage, 150, ret, MESSAGE_STATUS_DEFAULT)
return true
end
 
Im getting error "Unexpected symbol near line 28, near "5"

And it all works the lights turns on but not off maybe some wrong symobls in script?
 
oops
replace this
local time_ 5 -- time in seconds
with this
local time_ = 5 -- time in seconds
I updated it in case you run into problems

I was going to use recursion but I didn't test it at all so I that is why i didn't :)
 
12 hours =
43 200 seconds

But if i put 43200 seconds it will be like 43 secs in my server, so shall i put "4320000"? and it will be 12 hours?
 
if you look at this line here it is an addevent function means it will execute in whatever the second value is set to
Code:
addEvent(turnOnLights, time_ * 1000)

See it says time_ * 1000 which means, since time_ is set to 5 and the asterisk is the multiplication symbol and then you have a thousand, so 5 * 1000 = 5 seconds
 
if you look at this line here it is an addevent function means it will execute in whatever the second value is set to
Code:
addEvent(turnOnLights, time_ * 1000)

See it says time_ * 1000 which means, since time_ is set to 5 and the asterisk is the multiplication symbol and then you have a thousand, so 5 * 1000 = 5 seconds


local time = 57600 -- time in seconds

Means 16 hours before it turns off?
 
use small numbers, 60 = 1 minute * 60 = 1 hour * 16 = 16 hours, let the server do the math, instead you doing it on a calculator or in your head
so time_ like this
local time_ = 60*60*16 -- 16 hours from now it will turn off the lights
or just make another onTime script and shut it off then

Should i change this
addEvent(turnOnLights, time_ * 1000)
to this
addEvent(turnOnLights, time_ * 60)

and this
local time = 5 -- time in seconds
to this
local time = 60*60*16 -- time in seconds

or what shall i put there??
 
Back
Top