• 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] Teleport Players

Legnak Bqm

New Member
Joined
Mar 25, 2010
Messages
120
Reaction score
1
Location
Venezuela
Hi guys, I need a talkaction for teleport many players to my pos and specific pos, like this /teleport Hansel, Gretel (teleport to my pos) and /teleport Hansel, Gretel; x y z (teleport for a specific pos)
i would appreciate any help
Regards
 
Last edited:
Code:
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return true
	end

	local t = string.explode(param, ";")
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No destination specified.")
		return true
	end

	local p, players, semicolon = string.explode(param, ","), {}, param:find(';')
	for i = 1, #p do
		local tmp = p[i]:find(';')
		if tmp then
			p[i] = p[i]:sub(1, tmp-1)
		end
		local _, place = param:find(p[i])
		if place < semicolon then
			local pid = getPlayerByNameWildcard(p[i])
			if(not pid or (isPlayerGhost(pid) and getPlayerAccess(pid) > getPlayerAccess(cid))) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. p[i] .. " not found.")
				return true
			end
			table.insert(players, pid)
		end
	end

	local creature = getCreatureByName(t[2])
	local player = getPlayerByNameWildcard(t[2])
	local waypoint = getWaypointPosition(t[2])
	local tile = string.explode(t[2], ",")
	local pos = {x = 0, y = 0, z = 0}

	if(player ~= nil and (not isPlayerGhost(player) or getPlayerAccess(player) <= getPlayerAccess(cid))) then
		pos = getCreaturePosition(player)
	elseif(creature ~= nil and (not isPlayer(creature) or (not isPlayerGhost(creature) or getPlayerAccess(creature) <= getPlayerAccess(cid)))) then
		pos = getCreaturePosition(creature)
	elseif(type(waypoint) == 'table' and waypoint.x ~= 0 and waypoint.y ~= 0) then
		pos = waypoint
	elseif(tile[2] and tile[3]) then
		pos = {x = tile[1], y = tile[2], z = tile[3]}
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid destination specified.")
		return true
	end

	if(not pos or isInArray({pos.x, pos.y}, 0)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
		return true
	end

	pos = getClosestFreeTile(cid, pos, true)
	if(not pos or isInArray({pos.x, pos.y}, 0)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot perform action.")
		return true
	end

	for i = 1, #players do
		local tmp = getCreaturePosition(players[i])
		if(doTeleportThing(players[i], pos, true) and not isPlayerGhost(players[i])) then
			doSendMagicEffect(tmp, CONST_ME_POFF)
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
		end
	end

	return true
end
btw, to teleport players to your pos you must say:
/teleport player, player2, player3; your name

(spaces after , and ; are not required)
 
Back
Top