Ir para conteúdo

Pergunta

Bom galera, direto ao assunto, segui um tópico no OTLand(aqui) para adicionar o evento Zombie Event no meu server.

 

Tudo certo até os players entrarem no mapa do zombie, mas ai começa uns bugs no console:

 

  Citar

 

[22:11:19.907] [Error - GlobalEvent Interface]

[22:11:19.910] data/globalevents/scripts/zombie/onthink.lua:onThink
[22:11:19.911] Description:
[22:11:19.912] data/lib/zombie_event.lua:123: attempt to index local 'pir' (a number value)
[22:11:19.913] stack traceback:
[22:11:19.913] data/lib/zombie_event.lua:123: in function 'spawnNewZombie'
[22:11:19.914] data/globalevents/scripts/zombie/onthink.lua:6: in function <data/globalevents/scripts/zombie/onthink.lua:1>
[22:11:19.915] [Error - GlobalEvents::think] Couldn't execute event: ZombieGlobalThink

 

Ai vai o meu lib/zombie_event.lua

 

  Mostrar conteúdo oculto

globalevents/scripts/zombie/onthink.lua
  Mostrar conteúdo oculto
function onThink(interval, lastExecution, thinkInterval)
if(getStorage(ZE_STATUS) == 2) then
setZombiesToSpawnCount(getZombiesToSpawnCount()+1)
local players = getZombiesEventPlayers()
for i=1, getZombiesToSpawnCount() * 2 do
if(getZombiesToSpawnCount() > 0 and spawnNewZombie()) then
setZombiesToSpawnCount(getZombiesToSpawnCount()-1)
end
end
end
return true
end

POR FAVOR, ME AJUDEM!! Quero muito esse evento, e nenhum outro na internet funcionou comigo... NENHUM!

 

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/
Compartilhar em outros sites

13 respostass a esta questão

Posts Recomendados

  • 0
  • Diretor

Tente esse:

function loseOnZombieArena(cid)
	kickPlayerFromZombiesArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce perdeu.")
	local players = getZombiesEventPlayers()
	if(#players <= 1) then
		local winner = players[1]
		if(winner) then
			doPlayerAddItem(winner, 2157, 5, true)
            doPlayerAddItem(winner, 6119, 1, true)
			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Voce ganhou o Zombie Event.")
			doBroadcastMessage("Depois de " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos, o jogador " .. getCreatureName(winner) .. " ganhou o Zombie Arena Event com " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zumbis!")
			kickPlayerFromZombiesArea(winner)
		else
			doBroadcastMessage("O evento acabou, infelizmente ninguém ganhou!")
		end
		doSetStorage(ZE_STATUS, 0)
		doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
		doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
		doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
		local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
		local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
		local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
			centerPos.z = z
			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
				if(isMonster(uid)) then
					doRemoveCreature(uid)
				end
			end
		end
	end
end
function onStatsChange(target, cid, changetype, combat, value)
	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		loseOnZombieArena(target)
		return false
	end
	return true
end
Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677820
Compartilhar em outros sites

  • 0
  • Diretor

@

 

Não vi erro na script. Tente criar um outro arquivo.lua e coloca os codigos neles. Talvez seja um probleminha no arquivo, as vezes acontece.

 

O evento funciona normal?

 

Talvez esteja faltando arquivos do evento em outras pastas.

 

creaturescripts
globalevents
lib
movements
talkactions.
Editado por nedroesdoksdja
Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677731
Compartilhar em outros sites

  • 0

Mude a última função (spawnNewZombie) sua da linha 98 para baixo.

 

Coloque isto:

function spawnNewZombie()
    local posx = {}
    local posy = {}
    local posz = {}
    local pir = {}
    for i=1, 5 do
        local posx_tmp = math.random(ZE_spawnFromPosition.x ,ZE_spawnToPosition.x)
        local posy_tmp = math.random(ZE_spawnFromPosition.y ,ZE_spawnToPosition.y)
        local posz_tmp = math.random(ZE_spawnFromPosition.z ,ZE_spawnToPosition.z)
        local pir_tmp = 0
        local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, false)
        if(spec and #spec > 0) then
            for z, pid in pairs(spec) do
                if(isPlayer(pid)) then
                    pir_tmp = pir_tmp + 1
                end
            end
        end
        posx[i] = posx_tmp
        posy[i] = posy_tmp
        posz[i] = posz_tmp
        pir[i] = pir_tmp
    end
    local lowest_i = 1
    for i=2, 5 do
        if(pir[i] < pir[lowest_i]) then
            lowest_i = i
        end
    end
    local ret = (type(doCreateMonster("Zombie Event", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, false, false, false)) == 'number')
    if(ret) then
        addZombiesCount()
    end
    return ret
end

 

 

  Em 08/12/2015 em 03:42, Yan Liima disse:
Não vi erro na script. Tente criar um outro arquivo.lua e coloca os codigos neles. Talvez seja um probleminha no arquivo, as vezes acontece.

 

Já tenho uns 7 anos de tibia, e nunca deu isso em um otserver meu.

verifique se você tá colocando o nome certo.

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677733
Compartilhar em outros sites

  • 0

Tava com um problema parecido com esse fiz o que o Yan Lima disse e funcionou :)

 

  Em 08/12/2015 em 05:01, Caronte disse:

Já tenho uns 7 anos de tibia, e nunca deu isso em um otserver meu.

verifique se você tá colocando o nome certo.

 

para um pessoa que tem 7 anos de tibia. ta faltando aprender mais coisas.

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677777
Compartilhar em outros sites

  • 0
  Em 08/12/2015 em 20:07, Spring Trap disse:

Tava com um problema parecido com esse fiz o que o Yan Lima disse e funcionou :)

 

para um pessoa que tem 7 anos de tibia. ta faltando aprender mais coisas.

É né que coisa.

O problema nem tem haver com o TFS 0.4, que dá erro na função...

 

Que os gringos até postaram na página seguinte.

Editado por Caronte
Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677802
Compartilhar em outros sites

  • 0
  Em 09/12/2015 em 00:30, Sekk disse:

Postaram resolução? por que eu fui pegando os scripts UPDATED que postavam la!

Veja a segunda página lá, e siga o meu post, é só alterar a última função...

 

O gringo postou a correção para TFS_0.4

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677808
Compartilhar em outros sites

  • 0

Substitui a sua parte ali, mas olha:

 

O zombie spawnou, mas quando ele chegou em uma distancia de uns 2 sqm do player, o player morreu, acabou o evento, o outro venceu e apareceram esses erros no distrô:

 

 

  Mostrar conteúdo oculto

onattack.lua
  Mostrar conteúdo oculto
function loseOnZombieArena(cid)
kickPlayerFromZombiesArea(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! You are dead.")
local players = getZombiesEventPlayers()
if(#players <= 1) then
local winner = players[1]
if(winner) then
doPlayerAddItem(winner, 2157, 5, true)
doPlayerAddItem(winner, 6119, 1, true)
doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won zombies arena event.")
doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Zombie Arena Event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
kickPlayerFromZombiesArea(winner)
else
doBroadcastMessage("Zombie arena event finished! No one win?!?!?! WTF!")
end
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
centerPos.z = z
for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
if(isMonster(uid)) then
doRemoveCreature(uid)
end
end
end
end
end
function onStatsChange(target, cid, changetype, combat, value)
if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
doCreatureAddHealth(target, getCreatureMaxHealth(target))
loseOnZombieArena(target)
return false
end
return true
end

032-position.lua
  Mostrar conteúdo oculto
function isInRange(pos, fromPosition, toPosition)
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
function getDistanceBetween(firstPosition, secondPosition)
local x, y = math.abs(firstPosition.x - secondPosition.x), math.abs(firstPosition.y - secondPosition.y)
local diff = math.max(x, y)
if(firstPosition.z ~= secondPosition.z) then
diff = diff + 9 + 6
end
return diff
end
function getDirectionTo(pos1, pos2)
local dir = NORTH
if(pos1.x > pos2.x) then
dir = WEST
if(pos1.y > pos2.y) then
dir = NORTHWEST
elseif(pos1.y < pos2.y) then
dir = SOUTHWEST
end
elseif(pos1.x < pos2.x) then
dir = EAST
if(pos1.y > pos2.y) then
dir = NORTHEAST
elseif(pos1.y < pos2.y) then
dir = SOUTHEAST
end
else
if(pos1.y > pos2.y) then
dir = NORTH
elseif(pos1.y < pos2.y) then
dir = SOUTH
end
end
return dir
end
function getCreatureLookPosition(cid)
return getPosByDir(getThingPos(cid), getCreatureLookDirection(cid))
end
function getPosByDir(fromPosition, direction, size)
local n = size or 1
local pos = fromPosition
if(direction == NORTH) then
pos.y = pos.y - n
elseif(direction == SOUTH) then
pos.y = pos.y + n
elseif(direction == WEST) then
pos.x = pos.x - n
elseif(direction == EAST) then
pos.x = pos.x + n
elseif(direction == NORTHWEST) then
pos.y = pos.y - n
pos.x = pos.x - n
elseif(direction == NORTHEAST) then
pos.y = pos.y - n
pos.x = pos.x + n
elseif(direction == SOUTHWEST) then
pos.y = pos.y + n
pos.x = pos.x - n
elseif(direction == SOUTHEAST) then
pos.y = pos.y + n
pos.x = pos.x + n
end
return pos
end
function doComparePositions(pos, posEx)
return pos.x == posEx.x and pos.y == posEx.y and pos.z == posEx.z
end
function getArea(pos, rangeX, rangeY)
local t = {}
for i = (pos.x - rangeX), (pos.x + rangeX) do
for j = (pos.y - rangeY), (pos.y + rangeY) do
table.insert(t, {x = i, y = j, z = pos.z})
end
end
return t
end

Ajuda eu? kkkkk
Obs.: O post la dos gringos, é referente à:
  Citar

 

 

doCreateMonster(name, pos, false, false, false)

 

 

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677811
Compartilhar em outros sites

  • 0
  • Diretor

vai em creaturescripts\scripts\zombie\onattack e substitua tudo por isso:

function loseOnZombieArena(cid)
	kickPlayerFromZombiesArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce perdeu.")
	local players = getZombiesEventPlayers()
	if(#players <= 1) then
		local winner = players[1]
		if(winner) then
			doPlayerAddItem(winner, 2157, 5, true)
            doPlayerAddItem(winner, 6119, 1, true)
			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Voce ganhou o Zombie Event.")
			doBroadcastMessage("Depois de " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos, o jogador " .. getCreatureName(winner) .. " ganhou o Zombie Arena Event com " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zumbis!")
			kickPlayerFromZombiesArea(winner)
		else
			doBroadcastMessage("O evento acabou, infelizmente ninguém ganhou!")
		end
		doSetStorage(ZE_STATUS, 0)
		doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
		doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
		doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
		local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
		local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
		local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
			centerPos.z = z
			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
				if(isMonster(uid)) then
					doRemoveCreature(uid)
				end
			end
		end
	end
end
function onStatsChange(target, cid, changetype, combat, value)
	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		loseOnZombieArena(target)
		return false
	end
	return true
end 

Depois vai em lib\032-position.lua e substitue por:

function isInRange(position, fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end

function getDistanceBetween(fromPosition, toPosition)
	local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
	local diff = math.max(x, y)
	if(fromPosition.z ~= toPosition.z) then
		diff = diff + 9 + 6
	end

	return diff
end

function getDirectionTo(pos1, pos2)
	local dir = NORTH
	if(pos1.x > pos2.x) then
		dir = WEST
		if(pos1.y > pos2.y) then
			dir = NORTHWEST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHWEST
		end
	elseif(pos1.x < pos2.x) then
		dir = EAST
		if(pos1.y > pos2.y) then
			dir = NORTHEAST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHEAST
		end
	else
		if(pos1.y > pos2.y) then
			dir = NORTH
		elseif(pos1.y < pos2.y) then
			dir = SOUTH
		end
	end

	return dir
end

function getCreatureLookPosition(cid)
	return getPosByDir(getThingPos(cid), getCreatureLookDirection(cid))
end

function getPositionByDirection(position, direction, size)
	local n = size or 1
	if(direction == NORTH) then
		position.y = position.y - n
	elseif(direction == SOUTH) then
		position.y = position.y + n
	elseif(direction == WEST) then
		position.x = position.x - n
	elseif(direction == EAST) then
		position.x = position.x + n
	elseif(direction == NORTHWEST) then
		position.y = position.y - n
		position.x = position.x - n
	elseif(direction == NORTHEAST) then
		position.y = position.y - n
		position.x = position.x + n
	elseif(direction == SOUTHWEST) then
		position.y = position.y + n
		position.x = position.x - n
	elseif(direction == SOUTHEAST) then
		position.y = position.y + n
		position.x = position.x + n
	end

	return position
end

function doComparePositions(position, positionEx)
	return position.x == positionEx.x and position.y == positionEx.y and position.z == positionEx.z
end

function getArea(position, x, y)
	local t = {}
	for i = (position.x - x), (position.x + x) do
		for j = (position.y - y), (position.y + y) do
			table.insert(t, {x = i, y = j, z = position.z})
		end
	end

	return t
end
Editado por nedroesdoksdja
Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677818
Compartilhar em outros sites

  • 0

O erro de position sumiu, mas agora, "funciona", mas assim, o player morre, e o outro vence, blz, ai aparece esse erro no distro:

 

 

  Mostrar conteúdo oculto

VERMELHO -- ocorreu apenas quando o player morreu e o outro venceu.
Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1677819
Compartilhar em outros sites

  • 0

Tópico Movido
Este tópico foi movido de "OTServSuporte OTServSuporte Scripting"
para "OTServSuporte OTServSuporte ScriptingPedidos e dúvidas resolvidos - Scripting".

 

 

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1678626
Compartilhar em outros sites

  • 0
  Em 09/12/2015 em 02:20, Yan Liima disse:

vai em creaturescripts\scripts\zombie\onattack e substitua tudo por isso:

function loseOnZombieArena(cid)	kickPlayerFromZombiesArea(cid)	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce perdeu.")	local players = getZombiesEventPlayers()	if(#players <= 1) then		local winner = players[1]		if(winner) then			doPlayerAddItem(winner, 2157, 5, true)            doPlayerAddItem(winner, 6119, 1, true)			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "Voce ganhou o Zombie Event.")			doBroadcastMessage("Depois de " .. os.time() - getPlayerZombiesEventStatus(winner) .. " segundos, o jogador " .. getCreatureName(winner) .. " ganhou o Zombie Arena Event com " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zumbis!")			kickPlayerFromZombiesArea(winner)		else			doBroadcastMessage("O evento acabou, infelizmente ninguém ganhou!")		end		doSetStorage(ZE_STATUS, 0)		doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)		doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)		doSetStorage(ZE_ZOMBIES_SPAWNED, 0)		local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1		local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1		local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do			centerPos.z = z			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do				if(isMonster(uid)) then					doRemoveCreature(uid)				end			end		end	endendfunction onStatsChange(target, cid, changetype, combat, value)	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then		doCreatureAddHealth(target, getCreatureMaxHealth(target))		loseOnZombieArena(target)		return false	end	return trueend 
Expand  

Vlwwww!!!!! Ajudo De ++++++++ Rep++

Link para o comentário
https://xtibia.com/forum/topic/238232-problema-com-zombie-event/#findComment-1698480
Compartilhar em outros sites

×
×
  • Criar Novo...