• 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 help me convert to tfs 1.x

Jeyci

Banned User
Joined
May 6, 2023
Messages
289
Solutions
3
Reaction score
36
this is the main script
Lua:
function onStepIn(cid, item, pos)

local poh = {x=32836, y=32294, z=7}

    if item.actionid == 7449 then
        doTeleportThing(cid,poh)
        end
    return 1
end

this is how it looks with my changes,
Code:
function onStepIn(creature, item, position, fromPosition)

local config = {
    [7449] = Position(32836, 32294, 7),

}


    if item.actionid == 7449 then
        if player:isDruid() then
        --doTeleportThing(cid,poh)
                player:teleportTo(targetPosition)

    end
    return true
end
i need it to only teleport druid players, the script is not working
Code:
<movevent type="StepIn" actionid="7449" script="poh.lua" />
 
this is the main script
Lua:
function onStepIn(cid, item, pos)

local poh = {x=32836, y=32294, z=7}

    if item.actionid == 7449 then
        doTeleportThing(cid,poh)
        end
    return 1
end

this is how it looks with my changes,
Code:
function onStepIn(creature, item, position, fromPosition)

local config = {
    [7449] = Position(32836, 32294, 7),

}


    if item.actionid == 7449 then
        if player:isDruid() then
        --doTeleportThing(cid,poh)
                player:teleportTo(targetPosition)

    end
    return true
end
i need it to only teleport druid players, the script is not working
Code:
<movevent type="StepIn" actionid="7449" script="poh.lua" />

Lua:
function onStepIn(creature, item, position, fromPosition)
    local config = {
        [7449] = Position(32836, 32294, 7),
    }

    if item.actionid == 7449 then
        if creature:isPlayer() and creature:getVocation():getId() == 4 then
            creature:teleportTo(config[7449])
        end
    end
    return true
end

XML:
<movevent event="StepIn" actionid="7449" script="poh.lua" />
Post automatically merged:

I fixed it here and it's working fine. The script I mentioned first is not working :)

Lua:
function onStepIn(cid, item, position, fromPosition)
    local tiles = {
        [7449] = {x = 32836, y = 32294, z = 7},
    }
    
    local player = Player(cid)
    
    if player and player:getVocation():getId() == 2 then
        doTeleportThing(cid, tiles[item.actionid])
    else
        doPlayerSendCancel(cid, "Only Druids can use this teleporter..")
    end
    
    return true
end
 
Last edited:
Lua:
function onStepIn(creature, item, position, fromPosition)
    local config = {
        [7449] = Position(32836, 32294, 7),
    }

    if item.actionid == 7449 then
        if creature:isPlayer() and creature:getVocation():getId() == 4 then
            creature:teleportTo(config[7449])
        end
    end
    return true
end

XML:
<movevent event="StepIn" actionid="7449" script="poh.lua" />
hello. works. how do i make push player back if player has another vocation?
or odes not allow to enter. i tested with a druid and is not working :/
 
edit the seccond script works, but it allows other players step into the teleport, how do i push them back if they are not druid or elder druid?
Post automatically merged:

I got another second script. Are you working for you? Want to push for other vocations, right?
yes i want to push them a side because it allows player step into the teleport
 
edit the seccond script works, but it allows other players step into the teleport, how do i push them back if they are not druid or elder druid?
Post automatically merged:


yes i want to push them a side because it allows player step into the teleport

Lua:
function onStepIn(cid, item, position, fromPosition)
    local tiles = {
        [7449] = {x = 32836, y = 32294, z = 7},
    }
   
    local player = Player(cid)
   
    if player then
        if player:getVocation():getId() == 2 then
            doTeleportThing(cid, tiles[item.actionid])
        else
            local newPos = {x = fromPosition.x, y = fromPosition.y, z = fromPosition.z}
            doTeleportThing(cid, newPos)
            doPlayerSendCancel(cid, "Only Druids can use this teleporter.")
        end
    end
   
    return true
end
Post automatically merged:

Which do you prefer more, movements through XML or RevScripts? Both are working 😏



Lua:
local moveEvent = MoveEvent()

function moveEvent.onStepIn(creature, item, position, fromPosition)
    local tiles = {
        [7449] = {x = 32836, y = 32294, z = 7},
    }

    local player = Player(creature)

    if player then
        if player:getVocation():getId() == 2 then
            player:teleportTo(tiles[item:getActionId()])
        else
            local newPos = fromPosition
            player:teleportTo(newPos)
            player:say("Only Druids can use this teleporter.", TALKTYPE_ORANGE_1)
        end
    end

    return true
end

moveEvent:type("stepin")
moveEvent:aid(7449)
moveEvent:register()
 
Last edited:
Lua:
function onStepIn(cid, item, position, fromPosition)
    local tiles = {
        [7449] = {x = 32836, y = 32294, z = 7},
    }
  
    local player = Player(cid)
  
    if player then
        if player:getVocation():getId() == 2 then
            doTeleportThing(cid, tiles[item.actionid])
        else
            local newPos = {x = fromPosition.x, y = fromPosition.y, z = fromPosition.z}
            doTeleportThing(cid, newPos)
            doPlayerSendCancel(cid, "Only Druids can use this teleporter.")
        end
    end
  
    return true
end
Post automatically merged:

Which do you prefer more, movements through XML or RevScripts? Both are working 😏



Lua:
local moveEvent = MoveEvent()

function moveEvent.onStepIn(creature, item, position, fromPosition)
    local tiles = {
        [7449] = {x = 32836, y = 32294, z = 7},
    }

    local player = Player(creature)

    if player then
        if player:getVocation():getId() == 2 then
            player:teleportTo(tiles[item:getActionId()])
        else
            local newPos = fromPosition
            player:teleportTo(newPos)
            player:say("Only Druids can use this teleporter.", TALKTYPE_ORANGE_1)
        end
    end

    return true
end

moveEvent:register()

Hi! Keep in mind u can move tiles above the function
and make it look cleaner like this as example:

Lua:
local moveEvent = MoveEvent()

local tiles = {
    [7449] = {x = 32836, y = 32294, z = 7},
}

function moveEvent.onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not player then
        return true
    end

    if player:getVocation():getId() == 2 then
        player:teleportTo(tiles[item:getActionId()])  
    else
        player:teleportTo(fromPosition)
        player:say("Only Druids can use this teleporter.", TALKTYPE_ORANGE_1)
    end
    return true
end

moveEvent:register()
 
Hi! Keep in mind u can move tiles above the function
and make it look cleaner like this as example:

Lua:
local moveEvent = MoveEvent()

local tiles = {
    [7449] = {x = 32836, y = 32294, z = 7},
}

function moveEvent.onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not player then
        return true
    end

    if player:getVocation():getId() == 2 then
        player:teleportTo(tiles[item:getActionId()]) 
    else
        player:teleportTo(fromPosition)
        player:say("Only Druids can use this teleporter.", TALKTYPE_ORANGE_1)
    end
    return true
end

moveEvent:register()
Oh very nice! I'm learning every day, and it's more practical. Thank you for the advice. I will continue to learn and organize the script more cleanly, as you said..
 
Lua:
local moveEvent = MoveEvent()

local tiles = {
    [7449] = {x = 32836, y = 32294, z = 7},
}

function moveEvent.onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not player then
        return true
    end

    if player:getVocation():getId() == 2 then
        player:teleportTo(tiles[item:getActionId()])  
    else
        player:teleportTo(fromPosition)
        player:say("Only Druids can use this teleporter.", TALKTYPE_ORANGE_1)
    end
    return true
end

moveEvent:register()

I believe it would be interesting to add getBase() when checking the vocation, so the script will work for druids and their promotion.
You also forgot to add the aid or other form of trigger to the script.
 
Back
Top