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

Lua [action]Teleport monster

Crixpx

New Member
Joined
Jan 11, 2015
Messages
70
Reaction score
3
I have this script works this way: when clicking would have to teleport a few monsters that are in a coordinate to other coordinates, the problem is: the script does not teleport nothing

i'm using tfs 1.3

Someone could give me an idea of what is going on ;)

this is the script
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 1011 then
        creature1pos = {x=774, y=625, z=7, stackpos=253}
        creature1 = getThingfromPos(creature1pos)

        creature2pos = {x=770, y=625, z=7, stackpos=253}
        creature2 = getThingfromPos(creature2pos)

        creature3pos = {x=766, y=625, z=7, stackpos=253}
        creature3 = getThingfromPos(creature3pos)

            if creature1.itemid > 0 and creature2.itemid > 0 and creature3.itemid > 0 then

            ncreature1pos = {x=774, y=628, z=7}
            ncreature2pos = {x=770, y=628, z=7}
            ncreature3pos = {x=766, y=628, z=7}
               
                doSendMagicEffect(creature1pos,2)
                doSendMagicEffect(creature2pos,2)
                doSendMagicEffect(creature3pos,2)

                doTeleportThing(creature1.uid,ncreature1pos)
                doTeleportThing(creature2.uid,ncreature2pos)
                doTeleportThing(creature3.uid,ncreature3pos)

                doSendMagicEffect(ncreature1pos,10)
                doSendMagicEffect(ncreature2pos,10)
                doSendMagicEffect(ncreature3pos,10)
        doCreatureSay(cid, "Here you are!", TALKTYPE_ORANGE_1)

else

        doCreatureSay(cid, "No Monsters To Teleport!!", TALKTYPE_ORANGE_1)

end
end
end
 
Solution
Code:
local config = {
    creaturePositions = {
        Position(774, 625, 7),
        Position(770, 625, 7),
        Position(766, 625, 7),
    },
    newCreaturePositions = {
        Position(774, 628, 7),
        Position(770, 628, 7),
        Position(766, 628, 7),
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    for i = 1, #config.creaturePositions do
        local creatures = Tile(config.creaturePositions[i]):getTopCreature()
        if creatures and creatures:isMonster() then
            config.creaturePositions[i]:sendMagicEffect(CONST_ME_POFF)
            creatures:teleportTo(config.newCreaturePositions[i])
            config.newCreaturePositions[i]:sendMagicEffect(CONST_ME_TELEPORT)...
Code:
local config = {
    creaturePositions = {
        Position(774, 625, 7),
        Position(770, 625, 7),
        Position(766, 625, 7),
    },
    newCreaturePositions = {
        Position(774, 628, 7),
        Position(770, 628, 7),
        Position(766, 628, 7),
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    for i = 1, #config.creaturePositions do
        local creatures = Tile(config.creaturePositions[i]):getTopCreature()
        if creatures and creatures:isMonster() then
            config.creaturePositions[i]:sendMagicEffect(CONST_ME_POFF)
            creatures:teleportTo(config.newCreaturePositions[i])
            config.newCreaturePositions[i]:sendMagicEffect(CONST_ME_TELEPORT)
        end
    end
 
    player:say("Here you are!", TALKTYPE_MONSTER_SAY)
 
    return false
end

not tested
 
Solution
Code:
local config = {
    creaturePositions = {
        Position(774, 625, 7),
        Position(770, 625, 7),
        Position(766, 625, 7),
    },
    newCreaturePositions = {
        Position(774, 628, 7),
        Position(770, 628, 7),
        Position(766, 628, 7),
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    for i = 1, #config.creaturePositions do
        local creatures = Tile(config.creaturePositions[i]):getTopCreature()
        if creatures and creatures:isMonster() then
            config.creaturePositions[i]:sendMagicEffect(CONST_ME_POFF)
            creatures:teleportTo(config.newCreaturePositions[i])
            config.newCreaturePositions[i]:sendMagicEffect(CONST_ME_TELEPORT)
        end
    end
 
    player:say("Here you are!", TALKTYPE_MONSTER_SAY)
 
    return false
end

not tested

WORK YEAHH thanks you so much <3
 
Back
Top