• 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 Tfs 1.3 random TP position

alejandro762

Well-Known Member
Joined
Sep 6, 2021
Messages
225
Reaction score
63
Hiho

Im looking for a revscript (or script tfs1.3) i will convert it , to teleport a player after enter on a teleport to a random position, example,

I add a teleport on the map, and 5 differents locations, when player enter on teleport is teleported to one of the 5 locations randomly.


Thanks in advance
 
Solution
Set the positions you want and don't forget to set the actionID to your random teleport.

data/scripts/randomteleport.lua

Lua:
local randomTeleports = {
    Position(3189, 1817, 7),
    Position(3198, 1821, 7),
    Position(3190, 1823, 7),
    Position(3194, 1823, 7)
}

local actionID = 65100

local moveEvent = MoveEvent()

function moveEvent.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    local player = creature:getPlayer()
    local randomPosition = randomTeleports[math.random(#randomTeleports)]
    fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(randomPosition, false)
    randomPosition:sendMagicEffect(CONST_ME_TELEPORT)...
Set the positions you want and don't forget to set the actionID to your random teleport.

data/scripts/randomteleport.lua

Lua:
local randomTeleports = {
    Position(3189, 1817, 7),
    Position(3198, 1821, 7),
    Position(3190, 1823, 7),
    Position(3194, 1823, 7)
}

local actionID = 65100

local moveEvent = MoveEvent()

function moveEvent.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    local player = creature:getPlayer()
    local randomPosition = randomTeleports[math.random(#randomTeleports)]
    fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(randomPosition, false)
    randomPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You were teleported to a random position.")
    return true
end

moveEvent:aid(actionID)
moveEvent:register()

GIF random 🤭

randomteleports.gif
 
Solution
Set the potions you want and don't forget to set the actionID to your random teleport.

data/scripts/randomteleport.lua

Lua:
local randomTeleports = {
    Position(3189, 1817, 7),
    Position(3198, 1821, 7),
    Position(3190, 1823, 7),
    Position(3194, 1823, 7)
}

local actionID = 65100

local moveEvent = MoveEvent()

function moveEvent.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    local player = creature:getPlayer()
    local randomPosition = randomTeleports[math.random(#randomTeleports)]
    fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(randomPosition, false)
    randomPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You were teleported to a random position.")
    return true
end

moveEvent:aid(actionID)
moveEvent:register()

GIF random 🤭

View attachment 68867
Im going to try thanks for your help @Sarah Wesker
Post automatically merged:

local randomTeleports = { Position(3189


Is Working, perfectly, nice and very thanks.


Omg you do that to smooth on , visual studio code ?
How is that a "pre-recorded" functions for script ? Is a lua mod or somthing ? I Want to try learn a little bit, got to much ideas but from my ideas only i got 3 working, 2 of them i try taking some functions, here and some others posts , and the last one this Tp random place.

Thanks very much @Sarah Wesker
 
Last edited:
Back
Top