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

Solved Small Position problem. [TFS 1.2]

Joined
Mar 24, 2013
Messages
59
Reaction score
9
Okay so the idea was a grappling hook but then for TFS 1.x so i took this script https://otland.net/threads/mod-grappler.46357/ and i twisted it into this ( a grappling hook that only goes to itemEx with actionid 1337)

Now this script works fine without. these parts
Code:
    local pos = player:getPosition({x=x,y=y,z=z})
    local function doTeleporty()
        doTeleportThing(player:getPosition(player), fromPosition, toPosition {pos.x, pos.y, pos.z -1})
    end

    addEvent(doTeleporty, 5000)

BUT even though it works good enough for me i wanted a little extra i wanted it to move the player from its position to a floor below and 1 step aside and if possible he/she dies as well so imagine this you grapple to a pillar and you slip off and fall and die... this is the part that i cant make simply cause im still a beginner scripter. i tryd the things i could think of and tryd to search otland that maybe had the code but for a different reason but i couldnt find it. here is the script including my faild attempt.

And i know this script could be allot cleaner? but it workd so thats good enough for me.
But not the poistion...

Code:
local point = {
    [1337] = {}
}

function onUse(player, item, fromPosition, itemEx, toPosition)


    local go = point[itemEx:getActionId()]
    if not go then
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You cant Grapple here.")
    return false
    end
 
    local function doDistance()
        doSendDistanceShoot(player:getPosition(player), toPosition, CONST_ANI_SNIPERARROW)
        doSendMagicEffect(player:getPosition(player), CONST_ME_STUN)
        doSendDistanceShoot(player:getPosition(player), toPosition, CONST_ANI_HUNTINGSPEAR)
    end
     
    local function doTeleport()
        doSendMagicEffect(player:getPosition(player), CONST_ME_GROUNDSHAKER)
        doTeleportThing(player, toPosition, false)
    end
 
    local pos = player:getPosition({x=x,y=y,z=z})
    local function doTeleporty()
        doTeleportThing(player:getPosition(player), fromPosition, toPosition {pos.x, pos.y -1, pos.z -1})
    end
     
    addEvent(doDistance, 0)
    addEvent(doDistance, 500)
    addEvent(doDistance, 800)
    addEvent(doDistance, 1100)
    addEvent(doDistance, 1400)
    addEvent(doDistance, 1600)
    addEvent(doDistance, 1800)
    addEvent(doDistance, 1900)
    addEvent(doTeleport, 2000) 
    addEvent(doTeleporty, 5000)
    return true
end

Im using TFS 1.2 x64 from http://nightlies.otland.net/
 
Last edited:
Code:
player:getPosition({x=x,y=y,z=z})
or
Code:
player:getPosition(player)
should be
Code:
player:getPosition()
getPosition() doesn't accept arguments, it only returns a value which is a table of the position of the creature, item etc...

You aren't using the functions correctly...

Please either refer to the compat.lua file for the proper use
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua

Or the wiki
https://github.com/otland/forgottenserver/wiki/Script-Interface

For the proper use of these functions/metamethods.
 
Back
Top