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

Acess Monthly floor

Mr Erimyth

Member
Joined
Apr 8, 2009
Messages
163
Reaction score
11
Location
Brazil
OTSERV VERSION: TFS - Modified by OTX 1.3

Monthly floor

Hello friends, I wonder if anyone could help me.
I'm creating 12 quests.

1 for each month of the year, where the player can only enter if he is in the correct month.
I need a Script with 12 uniqueid for each floor.

Example:

Uniqueid 13118 - January
Uniqueid 13218 - February
Uniqueid 13318 - March
Uniqueid 13418 - April
Uniqueid 13518 - May
Uniqueid 13618 - June
Uniqueid 13718 - July
Uniqueid 13818 - August
Uniqueid 13918 - September
Uniqueid 131018 - October
Uniqueid 131118 - November
Uniqueid 131218 - December

The player can only pass the floor if we are in the month that corresponds to the quest or if it is with item ID 28695 in the Backpack.

when it passes the item is removed.

Please this is very important for my project, thank you brothers
 
Last edited:
Solution
Lua:
local monthlyQuest =
{
    [13118] = 1,
    [13218] = 2,
    [13318] = 3, 
    [13418] = 4, 
    [13518] = 5,
    [13618] = 6,
    [13718] = 7,
    [13818] = 8,
    [13918] = 9,
    [131018] = 10,
    [131118] = 11,
    [131218] = 12,
}

function monthlyQuest:canBedone(uniqueId)
    local month = self[uniqueId]
    return month and month == os.date("*t").month
end

--test month 9, month 2 (now is month 2, so returns false, true)
print(monthlyQuest:canBedone(13918), monthlyQuest:canBedone(13218)
Lua:
local monthlyQuest =
{
    [13118] = 1,
    [13218] = 2,
    [13318] = 3, 
    [13418] = 4, 
    [13518] = 5,
    [13618] = 6,
    [13718] = 7,
    [13818] = 8,
    [13918] = 9,
    [131018] = 10,
    [131118] = 11,
    [131218] = 12,
}

function monthlyQuest:canBedone(uniqueId)
    local month = self[uniqueId]
    return month and month == os.date("*t").month
end

--test month 9, month 2 (now is month 2, so returns false, true)
print(monthlyQuest:canBedone(13918), monthlyQuest:canBedone(13218)
 
Solution
Lua:
local monthlyQuest =
{
    [13118] = 1,
    [13218] = 2,
    [13318] = 3,
    [13418] = 4,
    [13518] = 5,
    [13618] = 6,
    [13718] = 7,
    [13818] = 8,
    [13918] = 9,
    [131018] = 10,
    [131118] = 11,
    [131218] = 12,
}

function monthlyQuest:canBedone(uniqueId)
    local month = self[uniqueId]
    return month and month == os.date("*t").month
end

--test month 9, month 2 (now is month 2, so returns false, true)
print(monthlyQuest:canBedone(13918), monthlyQuest:canBedone(13218)

You can say me how i can install it ? is on Movement ? or Libs ? This script are full ?
 
Add it to your global.lua

Then when you create a quest you can use:

Lua:
if monthlyQuest:canBeDone(questUid) then
      --Let player in door or w/e
else
     --Tell player he cannot do quest this month.
end

Add the quest UID into the table and put the month you want it to be allowed 1-12

for example.

Lua:
monthlyQuests = {
     --January quests--
     [1000] = 1,
     [1001] = 1,
     [1002] = 1,
     --February quests--
     [1003] = 2,
     [1004] = 2
}

Then lets say you can only open a door in January

Lua:
local doorUid = 1000
local pos_in_door = {x = 1000, y = 1000, z = 7}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getUniqueId() == doorUid then
     if monthlyQuest:canBeDone(doorUid) then
          player:teleportTo(pos_in_door)
     else
          return player:sendCancelMessage("You can only open this door in January.")
     end
end
return true
end

You can do it with UID's, ActionIds, storage values, all of it.
 
Last edited:
dont work ... i Add it in global.lua

Code:
monthlyQuests = {
     --January quests--
     [1000] = 1,
     [1001] = 1,
     [1002] = 1,
     --February quests--
     [1003] = 2,
     [1004] = 2
}
function monthlyQuest:canBedone(uniqueId)
    local month = self[uniqueId]
    return month and month == os.date("*t").month
end

and using the actions

Code:
local doorUid = 1003
local pos_in_door = {x = 32365, y = 32234, z = 6}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getUniqueId() == doorUid then
     if monthlyQuest:canBeDone(doorUid) then
          player:teleportTo(pos_in_door)
     else
          return player:sendCancelMessage("You can only open this door in January.")
     end
end
return true
end

It don't work :(
 
Last edited:
Back
Top