The old, useful and simple waypoint command from tfs 0.3, which saves positions for GMs that get erased on server restart.
Update your talkaction position.lua:
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