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

RevScripts A city for bosses to enter requires a specific item that you must use to enter

Madusa

Active Member
Joined
Sep 8, 2022
Messages
130
Reaction score
36
Location
Egypt
Hello guys, as stated above, I want the city that the bosses enter requires a specific item that you must use to enter, and this item is temporary for 24 hours and expires.
If you want any other details, let me know. Thank you, Otland team
Tfs 1.5/860
 
Solution
magic forcefield Tp

It doesn't matter that they are expelled from the city
Something like this (untested)
Lua:
local config = {
    itemId = 1234,                                --item id
    storage = 1234,                               --storage value to store the timestamp
    duration = 24,                                --duration(hours)
    teleportActionId = 1234,                      --teleport action id
    teleportPosition = Position(500, 500, 7)      --position to teleport to if successful (leave teleport co-ordinates blank in RME)
}

local entryItem = Action()
function entryItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local now = os.time()
    local expiryTime =...
Huh?

Can you be more specific please...
I have drawn a city dedicated to the boss, and I do not want anyone to enter it unless he uses a specific item, and this item gives him the ability to enter the city for only 24 hours.
id 9955 give access to new city for 24 hours
You can use it again after the period expires
This does not mean that the items 9955 is infinite
 
I have drawn a city dedicated to the boss, and I do not want anyone to enter it unless he uses a specific item, and this item gives him the ability to enter the city for only 24 hours.
id 9955 give access to new city for 24 hours
You can use it again after the period expires
This does not mean that the items 9955 is infinite
How exactly would they enter the city? Do they "use" the item and get teleported there? Do they click a door and it checks for the item?
If they are in the city when the 24 hours expires, should they be kicked out?

There are many questions, you really need to be more specific!
 
magic forcefield Tp

It doesn't matter that they are expelled from the city
Something like this (untested)
Lua:
local config = {
    itemId = 1234,                                --item id
    storage = 1234,                               --storage value to store the timestamp
    duration = 24,                                --duration(hours)
    teleportActionId = 1234,                      --teleport action id
    teleportPosition = Position(500, 500, 7)      --position to teleport to if successful (leave teleport co-ordinates blank in RME)
}

local entryItem = Action()
function entryItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local now = os.time()
    local expiryTime = player:getStorageValue(config.storage)
 
    if now < expiryTime then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You already have entry to the city.")
        return true
    end
 
    player:setStorageValue(config.storage, now + (config.duration * 60 * 60))
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You now have access to the city for the next 24 hours.")
    item:remove(1)
    return true
end
entryItem:id(config.itemId)
entryItem:register()

local entryTeleport = MoveEvent()
function entryTeleport.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
 
    local now = os.time()
    local expiryTime = player:getStorageValue(config.storage)
 
    if now > expiryTime then
        player:teleportTo(fromPosition)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You don't have access to the city.")
        return true
    end
 
    player:teleportTo(config.teleportPosition)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been teleported to the city.")
    return true
end
entryTeleport:aid(config.teleportActionId)
entryTeleport:register()
 
Last edited:
Solution
You want to remove the item after using it. Just look for this line.
Lua:
 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You now have access to the city for the next 24 hours.")
add the following below it.
Lua:
 item:remove(1)
It's just a matter of marking @Fjorda response as the solution.
 
You want to remove the item after using it. Just look for this line.
Lua:
 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You now have access to the city for the next 24 hours.")
add the following below it.
Lua:
 item:remove(1)
It's just a matter of marking @Fjorda response as the solution.
Thank you
Something like this (untested)
Lua:
local config = {
    itemId = 1234,                                --item id
    storage = 1234,                               --storage value to store the timestamp
    duration = 24,                                --duration(hours)
    teleportActionId = 1234,                      --teleport action id
    teleportPosition = Position(500, 500, 7)      --position to teleport to if successful (leave teleport co-ordinates blank in RME)
}

local entryItem = Action()
function entryItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local now = os.time()
    local expiryTime = player:getStorageValue(config.storage)
 
    if expiryTime > 0 and now < expiryTime then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You already have entry to the city.")
        return true
    end
 
    player:setStorageValue(config.storage, now + (config.duration * 60 * 60))
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You now have access to the city for the next 24 hours.")
    return true
end
entryItem:id(config.itemId)
entryItem:register()

local entryTeleport = MoveEvent()
function entryTeleport.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
 
    local now = os.time()
    local expiryTime = player:getStorageValue(config.storage)
 
    if now > expiryTime then
        player:teleportTo(fromPosition)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You don't have access to the city.")
        return true
    end
 
    player:teleportTo(config.teleportPosition)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been teleported to the city.")
    return true
end
entryTeleport:aid(config.teleportActionId)
entryTeleport:register()
Thank you, brother, I wish you success
 
Something like this (untested)
Lua:
local config = {
    itemId = 1234,                                --item id
    storage = 1234,                               --storage value to store the timestamp
    duration = 24,                                --duration(hours)
    teleportActionId = 1234,                      --teleport action id
    teleportPosition = Position(500, 500, 7)      --position to teleport to if successful (leave teleport co-ordinates blank in RME)
}

local entryItem = Action()
function entryItem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local now = os.time()
    local expiryTime = player:getStorageValue(config.storage)
 
    if now < expiryTime then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You already have entry to the city.")
        return true
    end
 
    player:setStorageValue(config.storage, now + (config.duration * 60 * 60))
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You now have access to the city for the next 24 hours.")
    item:remove(1)
    return true
end
entryItem:id(config.itemId)
entryItem:register()

local entryTeleport = MoveEvent()
function entryTeleport.onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return false
    end
 
    local now = os.time()
    local expiryTime = player:getStorageValue(config.storage)
 
    if now > expiryTime then
        player:teleportTo(fromPosition)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You don't have access to the city.")
        return true
    end
 
    player:teleportTo(config.teleportPosition)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been teleported to the city.")
    return true
end
entryTeleport:aid(config.teleportActionId)
entryTeleport:register()
Best answer
 
Back
Top