• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Some teleport.

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,940
Solutions
11
Reaction score
353
Thanks to Colandus for lessons :wub:

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:
Nice but:
PHP:
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 }
	}
}

Could have been:
PHP:
destinations = {
	["town1"] = { x = posx, y = posy, z = posz },
	["demons"] = { x = posx, y = posy, z = posz },
	["depot"] = { x = posx, y = posy, z = posz },
}

It's unnecessary to have multiple tables if they will only contain one value each :p

And if I did not already tell you, I stopped giving you lessons since I went on vacation, and I'm still there :p
 
I like it but I think that it is better to add the destinations on top of your script insteed of the global.lua.

But thats just my oppinion, maybe others like it this way more.
 
Marcinek Paladinek

No work fine.

I have add 3 position, depot, trainers and temple


if i use /tp"depot i will be teleporte do depot, but if i use wrong position example

/tp"dedot i will receive msg Temple in green ><
 
Back
Top