• 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!

Script of teleporte

ka9

New Member
Joined
Jul 25, 2009
Messages
32
Reaction score
0
Well, I made a scrip that when the god speaks / end, teleports all players who have these areas of the temple.


local players = getPlayersOnline()

function onSay(cid, words, param, channel)

local arenas = {arena1,arena2,arena3,arena4,arena5}

local arena1 = {
frompos = {x=452, y=742, z=7},
topos = {x=524, y=811, z=7},
exit = {x=15027, y=15987, z=5}
}

local arena2 = {
frompos = {x=470, y=764, z=6},
topos = {x=506, y=791, z=6},
exit = {x=15027, y=15987, z=5}
}

local arena3 = {
frompos = {x=470, y=764, z=5},
topos = {x=506, y=791, z=5},
exit = {x=15027, y=15987, z=5}
}

local arena4 = {
frompos = {x=470, y=764, z=4},
topos = {x=506, y=791, z=4},
exit = {x=15027, y=15987, z=5}
}

local arena5 = {
frompos = {x=470, y=764, z=3},
topos = {x=506, y=791, z=3},
exit = {x=15027, y=15987, z=5}
}

for i=1,5 do
for j=1,#players do
local playerpos = getCreaturePosition(getPlayerByNameWildcard(players[j]))
if isInArea(playerspos, arenas.frompos, arenas.topos) then
if doTeleportThing(cid, arenas.exit) == TRUE then
doSendMagicEffect(arenas.exit, 10)
end
end
end
end

return TRUE
end



Help-me please
 
Code:
if isInArea(playerspos, arenas[i].frompos, arenas[i].topos) then
to
Code:
if isInRange(getThingPos(players[i]), arenas[i].frompos, arenas[i].topos) then
 
Fail.

Code:
function onSay(cid, words, param, channel)
	local players = getPlayersOnline()
	local arena1 = {
		frompos = {x=452, y=742, z=7},
		topos = {x=524, y=811, z=7},
		exit = {x=15027, y=15987, z=5}
	}

	local arena2 = {
		frompos = {x=470, y=764, z=6},
		topos = {x=506, y=791, z=6},
		exit = {x=15027, y=15987, z=5}
	}

	local arena3 = {
		frompos = {x=470, y=764, z=5},
		topos = {x=506, y=791, z=5},
		exit = {x=15027, y=15987, z=5}
	}

	local arena4 = {
		frompos = {x=470, y=764, z=4},
		topos = {x=506, y=791, z=4},
		exit = {x=15027, y=15987, z=5}
	}

	local arena5 = {
		frompos = {x=470, y=764, z=3},
		topos = {x=506, y=791, z=3},
		exit = {x=15027, y=15987, z=5}
	}
	local arenas = {arena1, arena2, arena3, arena4, arena5}
	for i = 1, #arenas do
		for v = 1, #players do
			return isInArea((getThingPos(players[v])), arenas[i].frompos, arenas[i].topos) and doTeleportThing(players[v], arenas[i].exit) and doSendMagicEffect(arenas[i].exit, CONST_ME_TELEPORT)
		end
	end
end
 
Last edited:
uh, thanks, most gave error when he speaks in tfs / end


[04/05/2010 09:47:10] [Error - TalkAction Interface]
[04/05/2010 09:47:10] data/talkactions/scripts/castletemp.lua:eek:nSay
[04/05/2010 09:47:10] Description:
[04/05/2010 09:47:10] (luaGetThingPosition) Thing not found

[04/05/2010 09:47:10] [Error - TalkAction Interface]
[04/05/2010 09:47:10] data/talkactions/scripts/castletemp.lua:eek:nSay
[04/05/2010 09:47:10] Description:
[04/05/2010 09:47:10] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[04/05/2010 09:47:10] stack traceback:
[04/05/2010 09:47:10] data/lib/032-position.lua:2: in function 'isInRange'
[04/05/2010 09:47:10] data/talkactions/scripts/castletemp.lua:35: in function <data/talkactions/scripts/castletemp.lua:1>
 
uh, thanks, most gave error when he speaks in tfs / end
isInRange suck, just loop like this and u dont have to loop all online players;
Code:
function plot(from, to)
	local foo = {}
	for x = from.x, to.x do
		for y = from.y, to.y do
			for z = from.z, to.z do [B]// you dont rlly need this unless your using multiple floors //[/B]
				local position, player = {x = x, y = y, z = z}, getTopCreature(position).uid
				if player > 1 then table.insert(foo, player) end
			end
		end
	end
	return foo
end
example;
Code:
function onSay(cid, words, param, channel)
	if #plot > 1 then
		doSomething()
	end
	// or loop all the table in the function 'plot' //
	for i, v in ipairs(plot) do
		doSomething(v)
	end
	return true
end
 
Last edited:
Erro
[04/05/2010 10:03:40] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/castletemp.lua:5: 'do' expected near 'local'
[04/05/2010 10:03:40] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/castletemp.lua)
[04/05/2010 10:03:40] data/talkactions/scripts/castletemp.lua:5: 'do' expected near 'local'
 
I removed, I reload and gave another error
[04/05/2010 10:06:59] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/castletemp.lua:3: unexpected symbol near 'for'
[04/05/2010 10:06:59] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/castletemp.lua)
[04/05/2010 10:06:59] data/talkactions/scripts/castletemp.lua:3: unexpected symbol near 'for'
 
This?

local players = getPlayersOnline()

function onSay(cid, words, param, channel)

local arena = {
frompos = {x=452, y=742, z=3},
topos = {x=524, y=811, z=7},
exit = {x=15027, y=15987, z=5}
}


for j=1,#players do
local playerpos = getCreaturePosition(getPlayerByNameWildcard(players[j]))
if isInArea(playerpos, arena.frompos, arena.topos) then
if doTeleportThing(cid, arena.exit) == TRUE then
doSendMagicEffect(arena.exit, 10)
end
end
end


return TRUE
end
 
maybe try this;
Code:
local function plot(from, to)
	local foo = {}
	for x = from.x, to.x do
		for y = from.y, to.y do
			for z = from.z, to.z do
				local myPos, player = {x = x, y = y, z = z}, getTopCreature(player).uid
				if player > 0 then table.insert(foo, player) end
			end
		end
	end
	return foo
end
function onSay(cid, words, param, channel)
local arena = {
	fromPos = {x = 452, y = 742, z = 3},
	toPos = {x = 524, y = 811, z = 7},
	exit = {x = 15027, y = 15987, z = 5}
}
	if #plot(arena.fromPos, arena.toPos) then
		doTeleportThing(#plot, arena.exit, true)
		doSendMagicEffect(getThingPos(#plot), 10)
	end
	return true
end
 
This Error, /end

[04/05/2010 10:19:32] [Error - TalkAction Interface]
[04/05/2010 10:19:32] data/talkactions/scripts/castletemp.lua:eek:nSay
[04/05/2010 10:19:32] Description:
[04/05/2010 10:19:32] attempt to index a nil value
[04/05/2010 10:19:32] stack traceback:
[04/05/2010 10:19:32] [C]: in function 'getTopCreature'
[04/05/2010 10:19:32] data/talkactions/scripts/castletemp.lua:6: in function 'plot'
[04/05/2010 10:19:32] data/talkactions/scripts/castletemp.lua:19: in function <data/talkactions/scripts/castletemp.lua:13>
 
ops, sorry
Code:
local function plot(from, to)
	local foo = {}
	for x = from.x, to.x do
		for y = from.y, to.y do
			for z = from.z, to.z do
				local myPos, player = {x = x, y = y, z = z}, getTopCreature(myPos).uid
				if player > 0 then table.insert(foo, player) end
			end
		end
	end
	return foo
end
function onSay(cid, words, param, channel)
local arena = {
	fromPos = {x = 452, y = 742, z = 3},
	toPos = {x = 524, y = 811, z = 7},
	exit = {x = 15027, y = 15987, z = 5}
}
	if #plot(arena.fromPos, arena.toPos) then
		doTeleportThing(plot, arena.exit, true)
		doSendMagicEffect(getThingPos(plot), 10)
	end
	return true
end
 
Code:
local function plot(from, to)
	local foo = {}
	for x = from.x, to.x do
		for y = from.y, to.y do
			for z = from.z, to.z do
				local myPos = {x = x, y = y, z = z}
				local player = getTopCreature(myPos).uid
				if player > 0 then table.insert(foo, player) end
			end
		end
	end
	return {foo = foo}
end
function onSay(cid, words, param, channel)
local arena = {
	fromPos = {x = 452, y = 742, z = 3},
	toPos = {x = 524, y = 811, z = 7},
	exit = {x = 15027, y = 15987, z = 5}
}
	if #plot(arena.fromPos, arena.toPos).foo then
		for i, v in ipairs(plot(arena.fromPos, arena.toPos).foo) do
			doTeleportThing(v, arena.exit, true)
			doSendMagicEffect(getThingPos(v), 10)
		end
	end
	return true
end
here
 
Back
Top