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

[TFS 0.4 - LUA (movement and talkaction)] Waypoints save and teleport

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
579
Solutions
2
Reaction score
58
Location
México
Hello otlanders, im trying to make a waypoint system which work like this:

1-. Player stand on a certain SQM with aid (Ex aid: 6655)
2-. Player save the new waypoint with the place name (Ex: cyclops mountain) if not saved and show current saved waypoints as a textmessage
3-.Only discovered waypoints can be shown on the textmessage
(Ex: Current Waypoints:\n 1-.cyclops mountain\n 2-. rotworm cave\n 3-.etc
4-. Player can use !wp "cyclops mountain to teleport there (only if player has reached the save tile and its over a waypoint tile)
4.1- (optional) Player can use !wp "1 to teleport to cyclops mountain (the first discovered waypoint)
4-. All aid tiles can be used to teleport

This is an interesting feature we can add to TFS 0.4 (rev 3774 currently) since all waypoints script are for TFS 1.X+. I hope you could help =)

Have a nice day!
 
Solution
Usage - put AID from movements.xml (default is 4700) on teleport_tiles in map editor for unlock.

When using talkaction, must be on a teleport_tile or you can't teleport.

!waypoint -> gives list of unlocked waypoints
!waypoint number -> attempts to teleport you to an unlocked waypoint.

movement
XML:
<movevent type="StepIn" actionid="4700" event="script" value="waypoint.lua"/>
Lua:
local positions = {
    {1000, 1000, 7, 4701, "waypoint_name1"}, --{x, y, z, storage, waypoint_name}
    {2000, 2000, 7, 4702, "waypoint_name2"},
    {3000, 3000, 7, 4703, "waypoint_name3"}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    for i = 1, #positions do
        if position.x == positions[i][1] and...
Usage - put AID from movements.xml (default is 4700) on teleport_tiles in map editor for unlock.

When using talkaction, must be on a teleport_tile or you can't teleport.

!waypoint -> gives list of unlocked waypoints
!waypoint number -> attempts to teleport you to an unlocked waypoint.

movement
XML:
<movevent type="StepIn" actionid="4700" event="script" value="waypoint.lua"/>
Lua:
local positions = {
    {1000, 1000, 7, 4701, "waypoint_name1"}, --{x, y, z, storage, waypoint_name}
    {2000, 2000, 7, 4702, "waypoint_name2"},
    {3000, 3000, 7, 4703, "waypoint_name3"}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    for i = 1, #positions do
        if position.x == positions[i][1] and position.y == positions[i][2] and position.z == positions[i][3] then
            if getPlayerStorageValue(cid, positions[i][4]) < 1 then
                setPlayerStorageValue(cid, positions[i][4], 1)
                doCreatureSay(cid, "You have unlocked the " .. positions[i][5] .. " waypoint!", TALKTYPE_ORANGE_1, false, cid)
                return true
            end
        end
    end
    print("LUA ERROR: POSITION DOES NOT EXIST.")
    return true
end
talkaction
XML:
<talkaction words="!waypoint" event="script" value="waypoint.lua"/>
Lua:
local positions = {
    {1000, 1000, 7, 4701, "waypoint_name1"}, --{x, y, z, storage, waypoint_name}
    {2000, 2000, 7, 4702, "waypoint_name2"},
    {3000, 3000, 7, 4703, "waypoint_name3"}
}

function onSay(cid, words, param, channel)
    if param == "" or param == nil then
        local text = "Available Waypoints:/n"
        for i = 1, #positions do
            if getPlayerStorageValue(cid, positions[i][4]) == 1 then
                text = text .. "/n[" .. i .. "]" .. positions[i][5]
            end
        end
        if text == "Available Waypoints:/n" then
            doShowTextDialog(cid, 1948, text .. "/nNo waypoints currently unlocked.")
        else
            doShowTextDialog(cid, 1948, text)
        end
        return true
    else
        if tonumber(param) ~= nil then
            local i = tonumber(param)
            if getPlayerStorageValue(cid, positions[i][4]) < 1 then
                doCreatureSay(cid, "You do not have this waypoint unlocked!", TALKTYPE_ORANGE_1, false, cid)
                return true
            end
            local position = getCreaturePosition(cid)
            for n = 1, #positions do
                if position.x == positions[n][1] and position.y == positions[n][2] and position.z == positions[n][3] then
                    doTeleportThing(cid, {x = positions[i][1], y = positions[i][2], z = positions[i][3]})
                    return true
                end
            end
            doCreatureSay(cid, "You need to be on a teleport tile to teleport somewhere!", TALKTYPE_ORANGE_1, false, cid)
            return true
        end
        doCreatureSay(cid, param .. " is not a valid destination. Check your spelling and try again.", TALKTYPE_ORANGE_1, false, cid)
    end
    return true
end
 
Solution
would be way better if player can walk manually there if there is nothing blocking the way.
I would use it definitely
 
Back
Top