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

teleport player

Kjhgfd

New Member
Joined
Dec 25, 2016
Messages
63
Reaction score
1
hello guys
i have idea about when player stand for 10 sec in pz in room from = {x= 45421, y= 52254, z= 48746} to = { x= whatever here} get notice he will teleport in 10 sec if he don't go out pz and if he don't go out pz will get tp to x position but if he got out pz don't teleport

im use 0.4
 
Im not sure if this one will work, you need to check.
(globalevent)
Code:
<globalevent name="Checking" interval="1000" script="check_room.lua"/>
check_room.lua :
Code:
function onThink(interval, lastExecution, thinkInterval)
   local config = {
       storage = 11111,
       room_from = {x = 45421, y = 52254, z = 48746},
       room_to = {x = 45421, y = 52254, z = 48746},
       text = "You will be teleported within 10 seconds if you won't leave the protection zone!",
       text_after_tp = "You have been teleported out of protection zone",
       time_in_seconds = 10, -- notice that player will be teleported (he stays 10 seconds, receive info about it)
       time_in_seconds_2 = 10, -- additional time when player will be teleported (he stayed 10 seconds, he received message but he is still in PZ, another check for 10 seconds to tp him)
       position_where_player_will_be_teleported = {x = 45421, y = 52254, z = 48746}
   }
   local players = {}
   for x = config.room_from.x, config.room_to.x do
       for y = config.room_from.y, config.room_to.y do
           for z = config.room_from.z, config.room_to.z do
               local pos = {x=x, y=y, z=z,stackpos = 253}
               local thing = getThingfromPos(pos)
               if thing.itemid > 0 then
                   if isPlayer(thing.uid) == TRUE then
                       table.insert(players, thing.uid)
                   end
               end
           end
       end
   end
   for _, kid in ipairs(getPlayersOnline()) do
       if not isInArray(kid, players) then
           setPlayerStorageValue(kid, config.storage, 0)
       end
   end
   for _, pid in ipairs(players) do
       if getPlayerStorageValue(pid, config.storage) == -1 then
           setPlayerStorageValue(pid, config.storage, 0)
       end
       if getTilePzInfo(getPlayerPosition(pid)) == TRUE then
           setPlayerStorageValue(pid, config.storage, getPlayerStorageValue(pid, config.storage)+1)
           if getPlayerStorageValue(pid, config.storage) == config.time_in_seconds then
               doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE , config.text)
               addEvent(function(pid)
                   if getPlayerStorageValue(pid, config.storage) == (config.time_in_seconds + config.time_in_seconds_2) then
                       doTeleportThing(pid, config.position_where_player_will_be_teleported, false)
                       doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
                       doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE , config.text_after_tp)
                   end
                   setPlayerStorageValue(pid, config.storage, 0)
               end, config.time_in_seconds_2 * 1000)
           end
       end
   end
   return true
end
 
Last edited:
Im not sure if this one will work, you need to check.
(globalevent)
Code:
<globalevent name="Checking" interval="1000" script="check_room.lua"/>
check_room.lua :
Code:
function onThink(interval, lastExecution, thinkInterval)
   local config = {
       storage = 11111,
       room_from = {x = 45421, y = 52254, z = 48746},
       room_to = {x = 45421, y = 52254, z = 48746},
       text = "You will be teleported within 10 seconds if you won't leave the protection zone!",
       text_after_tp = "You have been teleported out of protection zone",
       time_in_seconds = 10, -- notice that player will be teleported (he stays 10 seconds, receive info about it)
       time_in_seconds_2 = 10, -- additional time when player will be teleported (he stayed 10 seconds, he received message but he is still in PZ, another check for 10 seconds to tp him)
       position_where_player_will_be_teleported = {x = 45421, y = 52254, z = 48746}
   }
   local players = {}
   for x = config.room_from.x, config.room_to.x do
       for y = config.room_from.y, config.room_to.y do
           for z = config.room_from.z, config.room_to.z do
               local pos = {x=x, y=y, z=z,stackpos = 253}
               local thing = getThingfromPos(pos)
               if thing.itemid > 0 then
                   if isPlayer(thing.uid) == TRUE then
                       table.insert(players, thing.uid)
                   end
               end
           end
       end
   end
   for _, kid in ipairs(getPlayersOnline()) do
       if not isInArray(kid, players) then
           setPlayerStorageValue(kid, config.storage, 0)
       end
   end
   for _, pid in ipairs(players) do
       if getPlayerStorageValue(pid, config.storage) == -1 then
           setPlayerStorageValue(pid, config.storage, 0)
       end
       if getTilePzInfo(getPlayerPosition(pid)) == TRUE then
           setPlayerStorageValue(pid, config.storage, getPlayerStorageValue(pid, config.storage)+1)
           if getPlayerStorageValue(pid, config.storage) == config.time_in_seconds then
               doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE , config.text)
               addEvent(function(pid)
                   if getPlayerStorageValue(pid, config.storage) == (config.time_in_seconds + config.time_in_seconds_2) then
                       doTeleportThing(pid, config.position_where_player_will_be_teleported), false)
                       doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
                       doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE , config.text_after_tp)
                   end
                   setPlayerStorageValue(pid, config.storage, 0)
               end, config.time_in_seconds_2 * 1000)
           end
       end
   end
   return true
end
2qmhog1.jpg
 
jpge84.jpg


and i have this

Code:
 function isInArray(array, value, caseSensitive)
if(caseSensitive == nil or caseSensitive == false) and type(value) == "string" then
local lowerValue = value:lower()
for _, _value in ipairs(array) do
    if type(_value) == "string" and lowerValue == _value:lower() then
        return true
        end
    end
else
    for _, _value in ipairs(array) do
    if (value == _value) then return true end
        end
end

return false
end
 
Try use this
Code:
-- Function by Colandus
function isInArray(t, v, c)
    v = (c ~= nil and string.lower(v)) or v
    if type(t) == "table" and v ~= nil then
        for key, value in pairs(t) do
            value = (c ~= nil and string.lower(value)) or value
            if v == value then
                return 1
            end
        end
    end
    return -1
end
 
Try use this
Code:
-- Function by Colandus
function isInArray(t, v, c)
    v = (c ~= nil and string.lower(v)) or v
    if type(t) == "table" and v ~= nil then
        for key, value in pairs(t) do
            value = (c ~= nil and string.lower(value)) or value
            if v == value then
                return 1
            end
        end
    end
    return -1
end
no thing happen too no tp no error :S
 
Back
Top