- Joined
- Aug 19, 2007
- Messages
- 4,940
- Solutions
- 11
- Reaction score
- 353
Thanks to Colandus for lessons :wub:
data/talkactions/scripts/teleport.lua
data/includes/destinations.lua
You can add as many destinations as u want, the word in [""] is a param, here's the example:
@You need to paste this in global.lua, or teleport.lua
data/talkactions/scripts/teleport.lua
Code:
dofile("data/includes/destinations.lua")
function onSay(cid, words, param)
param = param:lower()
local place = destinations[param]
if place then
doTeleportThing(cid, place.pos, 0)
doPlayerSendTextMessage(cid, 24, "You have teleported to"..ucwords(param).." [x = "..place.pos.x..", y = "..place.pos.y..", z = "..place.pos.z.."].")
else
doPlayerSendTextMessage(cid, 24, "Wrong destination, proper names are:")
for dest in pairs(destinations) do
doPlayerSendTextMessage(cid, 24, ucwords(dest))
end
end
return TRUE
end
data/includes/destinations.lua
Code:
destinations = {
["town1"] = {
pos = { x = posx, y = posy, z = posz }
},
["demons"] = {
pos = { x = posx, y = posy, z = posz }
},
["depot"] = {
pos = { x = posx, y = posy, z = posz }
}
}
You can add as many destinations as u want, the word in [""] is a param, here's the example:
Code:
["depot"] = {
pos = { x = 156, y = 203, z = 3 }
}
@You need to paste this in global.lua, or teleport.lua
Code:
function ucwords(str)
-- Made by Colandus
local newStr = nil
for str in string.gmatch(str, "%a+") do
newWord = string.upper(string.sub(str, 0, 1)) .. string.sub(str, 2)
newStr = (newStr or "") .. " " .. newWord
end
return newStr
end
Last edited by a moderator: