MA
pedido

Script de Teleport quando o monstro na area "x" a "y" estiver mortos.

Por markim1986, 08 de jan. de 2013 em Scripts

resolvido
script
21
2.3k
brun123B
08 de janeiro de 2013 às 23:49
local areas = {
   [1] = {
    fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm
    toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm
    creatureName = {"Rat", "Cave Rat"}
   }
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
   local pass = true
   for _, area in ipairs(areas) do
    local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)}
    local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)}

    local width = ((x.max - x.min) / 2) + 1
    local lenght = ((y.max - y.min) / 2) + 1

    local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z}
    local specs = getSpectators(center, width, lenght, false)
    if specs then
	    for _, cn in ipairs(specs) do
		    if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then
			    pass = false
			    break
		    elseif getCreatureName(cn):lower() == area.creatureName:lower() then
			    pass = false
			    break
		    end
	    end
    end
   end

   if pass == false then
    doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.")
    doTeleportThing(cid, fromPosition, true)
    return false
   end
   return true
end

markim1986M
09 de janeiro de 2013 às 00:23

local areas = {
[1] = {
	fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm
	toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm
	creatureName = {"Rat", "Cave Rat"}
}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local pass = true
for _, area in ipairs(areas) do
	local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)}
	local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)}

	local width = ((x.max - x.min) / 2) + 1
	local lenght = ((y.max - y.min) / 2) + 1

	local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z}
	local specs = getSpectators(center, width, lenght, false)
	if specs then
		for _, cn in ipairs(specs) do
			if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then
				pass = false
				break
			elseif getCreatureName(cn):lower() == area.creatureName:lower() then
				pass = false
				break
			end
		end
	end
end

if pass == false then
	doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.")
	doTeleportThing(cid, fromPosition, true)
	return false
end
return true
end

 

 

Agora da esse erro e nao trava o teleporte mesmo estando o bixo na area!

 

[18/01/2013 00:27:11] [Error - MoveEvents Interface]
[18/01/2013 00:27:11] data/movements/scripts/travarespow.lua:onStepIn
[18/01/2013 00:27:11] Description:
[18/01/2013 00:27:11] data/movements/scripts/travarespow.lua:25: attempt to call method 'lower' (a nil value)
[18/01/2013 00:27:11] stack traceback:
[18/01/2013 00:27:11]	 data/movements/scripts/travarespow.lua:25: in function <data/movements/scripts/travarespow.lua:9>

 

Mesmo substituindo essa linha que vc disse nos posts acima

addEvent(doTeleportThing, 5, cid, fromPosition, true

Editado Janeiro 9 por markim1986

brun123B
09 de janeiro de 2013 às 13:29

ops, erro idiota meu, aqui:

 

local areas = {
[1] = {
	fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm
	toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm
	creatureName = {"Rat", "Cave Rat"}
}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local pass = true
for _, area in ipairs(areas) do
	local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)}
	local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)}

	local width = ((x.max - x.min) / 2) + 1
	local lenght = ((y.max - y.min) / 2) + 1

	local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z}
	local specs = getSpectators(center, width, lenght, false)
	if specs then
		for _, cn in ipairs(specs) do
			if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then
				pass = false
				break
			elseif type(area.creatureName) == "string" and getCreatureName(cn):lower() == area.creatureName:lower() then
				pass = false
				break
			end
		end
	end
end

if pass == false then
	doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.")
	doTeleportThing(cid, fromPosition, true)
	return false
end
return true
end

Editado Janeiro 9 por brun123

juliok80J
09 de janeiro de 2013 às 15:13

ops, erro idiota meu, aqui:

 

local areas = {
[1] = {
	fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm
	toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm
	creatureName = {"Rat", "Cave Rat"}
}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local pass = true
for _, area in ipairs(areas) do
	local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)}
	local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)}

	local width = ((x.max - x.min) / 2) + 1
	local lenght = ((y.max - y.min) / 2) + 1

	local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z}
	local specs = getSpectators(center, width, lenght, false)
	if specs then
		for _, cn in ipairs(specs) do
			if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then
				pass = false
				break
			elseif type(area.creatureName) == "string" and getCreatureName(cn):lower() == area.creatureName:lower() then
				pass = false
				break
			end
		end
	end
end

if pass == false then
	doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.")
	doTeleportThing(cid, fromPosition, true)
	return false
end
return true
end

 

Oiiiiiiiiiiihh brunnnnnnnnnnn123 heart.png (fazendo voz de menininha) kkkkkk

 

Rapaz, teria como eu editar esse script ai pra fazer uma especie de arena!?

 

Tipo o player passa o portal da arena, dai enquanto este player estiver dentro da arena o portal ficará bloqueado para que outros players não entrem... e o player que entrou não poderá fazer logoff lá dentro, ai assim que o player que entrou, sair desta area o portal ser liberado novamente.

 

Outra condição, seria que o player só pudesse ficar nesta area no máximo 15 minutos.

 

Beijos man! love.gif

 

AEHAUEHAUEHA... essa parte do beijo é brincadeira viu! mad2.png

Editado Janeiro 9 por juliok80

markim1986M
09 de janeiro de 2013 às 18:15

ops, erro idiota meu, aqui:

 

local areas = {
[1] = {
	fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm
	toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm
	creatureName = {"Rat", "Cave Rat"}
}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local pass = true
for _, area in ipairs(areas) do
	local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)}
	local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)}

	local width = ((x.max - x.min) / 2) + 1
	local lenght = ((y.max - y.min) / 2) + 1

	local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z}
	local specs = getSpectators(center, width, lenght, false)
	if specs then
		for _, cn in ipairs(specs) do
			if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then
				pass = false
				break
			elseif type(area.creatureName) == "string" and getCreatureName(cn):lower() == area.creatureName:lower() then
				pass = false
				break
			end
		end
	end
end

if pass == false then
	doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.")
	doTeleportThing(cid, fromPosition, true)
	return false
end
return true
end

 

Perfeito meu amigo, Rep+

 

Muito Obrigado e se possivel voce puder me ajudar neste script

http://www.xtibia.co...__fromsearch__1

Podem mover o topic

LuckOakeL
09 de janeiro de 2013 às 20:15

Tópico movido para a seção de dúvidas e pedidos resolvidos.