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

New code problem

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi everyone I'm getting a weird problem in a new code.

The main idea of the script is, at Sunday/Friday at 8 p.m will set storage 291 for 2 minutes, and after this will remove

Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/lib/core/game.lua:105: table index is nil
stack traceback:
  [C]: in function '__newindex'
  data/lib/core/game.lua:105: in function 'setStorageValue'
  data/globalevents/scripts/hour.lua:7: in function <data/glob
alevents/scripts/hour.lua:6>

Code:
local config = {
   storage = 291,
   time = 2
}

function happyshit()
   Game.setStorageValue(storage, 1)
   addEvent(removex, config.time * 1000)
end

function removex()
   Game.setStorageValue(storage, 0)
end

function onTime(interval)
   if os.date('%A') == "Sunday" or os.date('%A') == "Friday" then
     if Game.getStorageValue(config.storage) < 1 then
       addEvent(happyshit, config.time * 1000)
     end
   end
  return true
end

Thanks.
 
Hi everyone I'm getting a weird problem in a new code.

The main idea of the script is, at Sunday/Friday at 8 p.m will set storage 291 for 2 minutes, and after this will remove

Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/lib/core/game.lua:105: table index is nil
stack traceback:
  [C]: in function '__newindex'
  data/lib/core/game.lua:105: in function 'setStorageValue'
  data/globalevents/scripts/hour.lua:7: in function <data/glob
alevents/scripts/hour.lua:6>

Code:
local config = {
   storage = 291,
   time = 2
}

function happyshit()
   Game.setStorageValue(storage, 1)
   addEvent(removex, config.time * 1000)
end

function removex()
   Game.setStorageValue(storage, 0)
end

function onTime(interval)
   if os.date('%A') == "Sunday" or os.date('%A') == "Friday" then
     if Game.getStorageValue(config.storage) < 1 then
       addEvent(happyshit, config.time * 1000)
     end
   end
  return true
end

Thanks.
Try this, not tested.
Code:
local config = {
   storage = 291,
   time = 2
}

function removex()
   Game.setStorageValue(config.storage, 0)
end

function happyshit()
   Game.setStorageValue(config.storage, 1)
   addEvent(removex, config.time * 1000)
end

function onTime(interval)
   if os.date('%A') == "Sunday" or os.date('%A') == "Friday" then
     if Game.getStorageValue(config.storage) < 1 then
       addEvent(happyshit, config.time * 1000)
     end
   end
  return true
end
 
Back
Top