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

Random TP Spawn!

Wartio

Any game ideas?
Joined
Apr 2, 2010
Messages
457
Reaction score
29
Location
Sweden
My request is that i want script that creates Teleport at random time, and after 5 minute it removes again, and next day random spawn time again. I need this script so much so i hope someone could help me to get this script

i hope you guys understanded what my request was, if i did not explain it in a good way then tell me and i'll explain a bit more :)
 
Which server do you use?
How random should it be? How much different moments should it have in 1 day when it can spawn?
Also should there be something else, like a broadcast message?
 
Which server do you use?
How random should it be? How much different moments should it have in 1 day when it can spawn?
Also should there be something else, like a broadcast message?

First of all thanks for taking your time to help me out, and it should not broadcast, it should spawn like 1 time a day, and server will have restart at 10:00 am, this teleport spawns random time between 10.00-10.00 am , so in 12 hours it spawns 1 time and it tp will get removed after 5 minutes and spawn again in next server save

So, no broadcast
1 time spawn between 10.00 am to nextday 10.00 am (12 hours)
Teleport creates in 1 specific position (100.100.7) and removes after 5 minutes, and the day after it makes same thing
 
Code:
local config = {
     toPos = {x = 100, y = 100, z = 7},
     tpPos = {x = 101, y = 100, z = 7},
     storage = 37632,
     time = 300
}

local function removeTeleport(pos)
     doRemoveItem(getTileItemById(pos, 1387).uid)
     doSendMagicEffect(pos, CONST_ME_POFF)
     return true
end

function onThink(interval, lastExecution)
     local chance, hour = math.random(1, 20), tonumber(os.date("%H"))
     if hour >= 10 and hour < 22 then
         if getGlobalStorageValue(config.storage) ~= tonumber(os.date("%d")) then
             if chance == 1 or hour >= math.random(19, 21) then
                 doCreateTeleport(1387, config.toPos, config.tpPos)
                 setGlobalStorageValue(config.storage, tonumber(os.date("%d")))
                 addEvent(removeTeleport, config.time * 1000, config.tpPos)
             end
         end
     end
     return true
end
 
Last edited:
Code:
local config = {
     toPos = {x = 100, y = 100, z = 7},
     tpPos = {x = 101, y = 100, z = 7},
     storage = 37632,
     time = 300
}

local function removeTeleport(pos)
     doRemoveItem(getTileItemById(pos, 1387).uid)
     doSendMagicEffect(pos, CONST_ME_POFF)
     return true
end

function onThink(cid, interval, lastExecution)
     local chance, hour = math.random(1, 20), tonumber(os.date("%H"))
     if hour >= 10 and hour < 22 then
         if getGlobalStorageValue(config.storage) ~= tonumber(os.date("%d")) then
             if chance == 1 or hour >= math.random(19, 21) then
                 doCreateTeleport(1387, config.toPos, config.tpPos)
                 setGlobalStorageValue(config.storage, tonumber(os.date("%d")))
                 addEvent(removeTeleport, config.time * 1000, config.tpPos)
             end
         end
     end
     return true
end

@Limos Thanks it works perfectly, but could you add 1 more "tppos"? so the teleport creates on 2 places?, 100.100.7 , 101.100.7, and leads to 200.200.7?
 
Last edited:
You can add an extra line with the function doCreateTeleport under the other one, then just change the config.tpPos to the other position.
 
Code:
doCreateTeleport(1387, config.toPos, config.tpPos)
When you change the config.tpPos to the other position you want, it will look like this.
Code:
doCreateTeleport(1387, config.toPos, {x = 102, y = 100, z = 7})
You can add that under the other line with doCreateTeleport.
 
Back
Top