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

TFS 1.X+ NPC born on a certain date

Solution
Hi how are you?
I'm having trouble creating a script, the script is pretty basic I think. I need the npc to respawn in a certain month of the year.

Stan (Stan (https://tibia.fandom.com/wiki/Stan))
This is a globalevent. The example is set for '02' being February, if you want to change it make sure you always keep this compared value as two digits.
Lua:
function onStartup()
    if os.date('%m') == '02' then
        Game.createNpc("Stan", Position(1000, 1000, 7), true, true)
    end
    return true
end
If you want to be sure it will work try this code out in lua demo as an example:
Lua:
if os.date('%m') == '01' then
  print('yes')
else
  print('no')
end
Lua: demo (https://www.lua.org/cgi-bin/demo)
Hi how are you?
I'm having trouble creating a script, the script is pretty basic I think. I need the npc to respawn in a certain month of the year.

Stan (Stan (https://tibia.fandom.com/wiki/Stan))
This is a globalevent. The example is set for '02' being February, if you want to change it make sure you always keep this compared value as two digits.
Lua:
function onStartup()
    if os.date('%m') == '02' then
        Game.createNpc("Stan", Position(1000, 1000, 7), true, true)
    end
    return true
end
If you want to be sure it will work try this code out in lua demo as an example:
Lua:
if os.date('%m') == '01' then
  print('yes')
else
  print('no')
end
Lua: demo (https://www.lua.org/cgi-bin/demo)
 
Solution
This is a globalevent. The example is set for '02' being February, if you want to change it make sure you always keep this compared value as two digits.
Lua:
function onStartup()
    if os.date('%m') == '02' then
        Game.createNpc("Stan", Position(1000, 1000, 7), true, true)
    end
    return true
end
If you want to be sure it will work try this code out in lua demo as an example:
Lua:
if os.date('%m') == '01' then
  print('yes')
else
  print('no')
end
Lua: demo (https://www.lua.org/cgi-bin/demo)

WOW, it worked perfectly, thank you very much.
I did not know of the existence of this LUA tool.
 
Back
Top