function onSay(cid, words, param)
-- Define possible teleport locations.
local teleport =
{
-- For regular players.
["depot"] = {x = 774, y = 648, z = 7, name = "Toren Depot", access = 1, level = 1, premium = true, cost = 0, soul = 0},
["mall"] = {x = 801, y = 652, z = 7, name = "Toren Mall", access = 1, level = 1, premium = true, cost = 0, soul = 0},
["iteos"] = {x = 1764, y = 2030, z = 7, name = "Aeneus", access = 1, level = 1, premium = true, cost = 0, soul = 0},
["trainers"] = {x = 464, y = 769, z = 7, name = "Trainers", access = 1, level = 1, premium = false, cost = 0, soul = 0},
-- For gamemasters.
["gm"] = {x = 1298, y = 897, z = 7, access = 4}
}
-- Check so the param is not nil.
if param ~= nil then
-- Check if param exists in table teleports.
if table.find(teleport, teleport[param]) then
-- Check what access is required for the new destination.
if teleport[param].access > 1 or getPlayerAccess(cid) >= teleport[param].access then
-- Check if the player has access above ordinary.
if getPlayerAccess(cid) >= teleport[param].access then
-- Check if the player has gone to the GM Island.
if param == "gm" then
-- Define character greeting.
if getPlayerSex(cid) == 0 then
greeting = "Miss"
else
greeting = "Mister"
end
-- Show a popup window.
doPlayerPopupFYI(cid, "Welcome to the Staff Island, " .. greeting .. " " .. getPlayerName(cid) .. ".")
end
-- Teleport player to the wanted location.
doTeleportThing(cid, {x = teleport[param].x, y = teleport[param].y, z = teleport[param].z})
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 10)
end
else
-- Check if the player has the required level.
if getPlayerLevel(cid) >= teleport[param].level then
-- Check if the player has Premium.
if ( teleport[param].isPremium(cid) == TRUE) ) or teleport[param].isPremium(cid) == FALSE
-- Check if the player has enough money on him.
if doPlayerRemoveMoney(cid, teleport[param].cost) == TRUE then
-- Check if the player has enough soulpoints.
if getPlayerSoul(cid) >= teleport[param].soul then
-- Remove soulpoints from the player.
doPlayerAddSoul(cid, - teleport[param].soul)
-- Check if the player is in a fight or not.
if getCreatureCondition(cid, CONDITION_INFIGHT) == 0 then
-- Teleport the player to the wanted location.
doTeleportThing(cid, {x = teleport[param].x, y = teleport[param].y, z = teleport[param].z})
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 10)
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "You may not be in a fight while trying to alter your destination to " .. teleport[param].name .. ".")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "You do not have enough soulpoints (" .. teleport[param].soul .. ") to alter your destination to " .. teleport[param].name .. ".")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "You do not have enough money (" .. teleport[param].cost .. "gp) to alter your destination to " .. teleport[param].name .. ".")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "You need to be premium to go to " .. teleport[param].name .. ".")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "You need to be atleast level " .. teleport[param].level .. " to alter your destination to " .. teleport[param].name .. ".")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
end
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "Please use a valid destination.")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
else
-- Send an error message.
doPlayerSendTextMessage(cid, 23, "Please use a valid destination.")
-- Send magic effect.
doSendMagicEffect(getCreaturePos(cid), 2)
end
end