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

TalkAction [TFS 1.0] Temporial waypoints

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
The old, useful and simple waypoint command from tfs 0.3, which saves positions for GMs that get erased on server restart.
Code:
<talkaction words="/wp" separator=" " script="waypoints.lua" />
Code:
if getGlobalStorageValue('waypoints') == -1 then
    setGlobalStorageValue('waypoints', {})
end

function getWaypoint(str)
    for name, pos in pairs(getGlobalStorageValue("waypoints")) do
        if str == name then
            return pos
        end
    end
    return false
end

function onSay(cid, words, param)
    local player = Player(cid)
    if player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
        return false
    end

    if param == "" then
        local t = {}
        for name in pairs(getGlobalStorageValue("waypoints")) do
            table.insert(t, name)
        end
        player:showTextDialog(1956, table.concat(t, "\n"))
    elseif param:find(",") then
        player:sendCancelMessage("Waypoints with commas are not allowed.")
    else
        local t = getGlobalStorageValue("waypoints")
        local result = t[param] and "updated" or "saved"
        t[param] = player:getPosition()
        setGlobalStorageValue("waypoints", t)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Temporial waypoint \"" .. param .. "\"  was successfully " .. result .. ".")
    end
    return false
end

Update your talkaction position.lua:
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    if player:getGroup():getAccess() and param ~= "" then
        if param:find(",") then
            local split = param:split(",")
            player:teleportTo(Position(split[1], split[2], split[3]))
        else
            local pos = getWaypoint(param)
            if pos then
                player:teleportTo(pos)
            else
                player:sendCancelMessage("Temporial waypoint \"" .. param .. "\" doesn't exist.")
            end
        end
    else
        local pos = player:getPosition()
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your current position is: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z .. ".")
    end
    return false
end

/wp test
/wp
/pos test
 
Back
Top