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

Time in tile

marcos16

Falkhonn
Joined
May 4, 2012
Messages
224
Reaction score
1
I need a script that a tile can only be allowed to spend between x time.
Ex [01:00 - 02:00]
Send the following message when trying after hours:
You can only pass this place between 1:00 - 2:00 p.m.


Could anyone help? REP+
 
Lua:
local config = { -- hour 0-23 localtime
   time_start = 16,
   time_end = 17
}

function onStepIn(player, item, position, fromPos)
if isPlayer(player) then
local current_hour = os.date('*t', os.time()).hour
if current_hour >= config.time_start and current_hour <= config.time_end then
doPlayerSendTextMessage(player, MESSAGE_EVENT_DEFAULT, 'Welcomen.')
return true
end
doPlayerSendTextMessage(player, MESSAGE_EVENT_DEFAULT, 'Sorry, not posible.')
doTeleportThing(player, fromPos)
doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
end
return true
end
 
Lua:
local config = { -- hour 0-23 localtime
   time_start = 16,
   time_end = 17
}

function onStepIn(player, item, position, fromPos)
if isPlayer(player) then
local current_hour = os.date('*t', os.time()).hour
if current_hour >= config.time_start and current_hour <= config.time_end then
doPlayerSendTextMessage(player, MESSAGE_EVENT_DEFAULT, 'Welcomen.')
return true
end
doPlayerSendTextMessage(player, MESSAGE_EVENT_DEFAULT, 'Sorry, not posible.')
doTeleportThing(player, fromPos)
doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
end
return true
end
nice indendation
 
Lua:
local config = { -- hour 0-23 localtime
   time_start = 16,
   time_end = 17
}

function onStepIn(player, item, position, fromPos)
if isPlayer(player) then
local current_hour = os.date('*t', os.time()).hour
if current_hour >= config.time_start and current_hour <= config.time_end then
doPlayerSendTextMessage(player, MESSAGE_EVENT_DEFAULT, 'Welcomen.')
return true
end
doPlayerSendTextMessage(player, MESSAGE_EVENT_DEFAULT, 'Sorry, not posible.')
doTeleportThing(player, fromPos)
doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
end
return true
end

Which tag should I use? I am a "layman" in the scripts area
 
Which tag should I use? I am a "layman" in the scripts area
The code uses the local time of your computer, you do not have to put labels of regions to him or anything like that
The global ad right now, I'll give it to you

for example ->
maybe it for global event the broadcast message
Lua:
-- script global events
function onTime(interval)
    broadcastMessage("Teleport time zone is active.", MESSAGE_STATUS_WARNING)
    return true
end

globalevents.xml
Code:
<globalevent name="Broadcast_timezone" time="16:00:00" script="myscript.lua" />
 
Last edited by a moderator:
Back
Top