Jump to content
  • 0

Summon que some depois de um perido! Erro Distro!


ZeusMnc

Question

Salve Xtibia tenho um Script de Summon!

e utilizo o Addevent para fazer ele sumir depois de 2 minutos! 

addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))

Porem caso ele morra, antes do evento sobe um retorno de erro na Distro!

Erro:

Spoiler

[17:34:36.353] [Error - Action Interface]
[17:34:36.354] In a timer event called from:
[17:34:36.355] data/actions/scripts/Petsystemm.lua:onUse
[17:34:36.355] Description:
[17:34:36.356] (luaDoRemoveCreature) Creature not found



Qual seria a forma de passar por isso ? sem tomar esse retorno de erro ?

Script.
 

Spoiler

function onUse(cid, item, fromPosition, itemEx, toPosition)    

local dolls = {

[13708] = {pet = "Fly Summon"},
[13711] = {pet = "Dragon Summon"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
[13712] = {pet = "Dog Summon"},
[13714] = {pet = "Cat Summon"},
[13713] = {pet = "Gregory Summon"},
[13781] = {pet = "Power Oozaru Summon"},
[13715] = {pet = "Ghost Summon"},
[13717] = {pet = "Golden Power Summon"},
[13718] = {pet = "Mini Summon"},
[13716] = {pet = "Mini Golden Summon"},
[13782] = {pet = "Red Ghost Summon"},
[13707] = {pet = "Black Power Summon"},
[13709] = {pet = "Orc Summon"},
[13783] = {pet = "Karin Summon"},
[13706] = {pet = "Anjo Summon"},
[13710] = {pet = "Wolf God Helper"},
[13784] = {pet = "Patinho Summon"},
}

local go = dolls[item.itemid]
local summon = getCreatureSummons(cid)
local waittime = 600 -- Tempo de exhaustion em segundos
local strtime = 250663 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...

if exhaustion.check(cid, strtime) then
doPlayerSendTextMessage(cid, 19, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar pet novamente .")
return true
end 

if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid then  
doPlayerSendCancel(cid, "Voce deve colocar Contrato no lugar do escudo.") 
return true
end 

---------------------------------------------------
if not (getTilePzInfo(getCreaturePosition(cid))) then
if #summon >= 1 then
for _, pid in ipairs(summon) do
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já tem criatura summonada")
exhaustion.set(cid, strtime, waittime)      -- checar time
end
return true
end

if item.itemid == 13708 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13711 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13712 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13714 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 


if item.itemid == 13713 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 


if item.itemid == 13781 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13782 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13716 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13717 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13718 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13715 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13707 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13706 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13709 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13783 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13710 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

if item.itemid == 13784 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
addEvent(doRemoveCreature, 120000, (getCreatureSummons(cid)[1]))
exhaustion.set(cid, strtime, waittime)  
end 

else
doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
return true
end
end

E teria como implementar um sandCancel ? para ele checar o storage e ficar posicionando quanto tempo falta para o summon sumir ? ( e qual seria a forma se possivel detalhar para meu melhor aprendizado)

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1
Em 05/09/2022 em 20:28, ZeusMnc disse:

@lSainty

Realizei o teste do segundo script e realmente foi bem otimizado/Resumido, porem acaba com o mesmo erro!
[20:25:54.116] [Error - Action Interface]
[20:25:54.117] In a timer event called from:
[20:25:54.117] data/actions/scripts/Petsystemm.lua:onUse
[20:25:54.118] Description:
[20:25:54.118] (luaDoRemoveCreature) Creature not found

 

Não lembro ao certo o funcionamento da função addEvent, mas tenta trocar isso:
 

addEvent(function(playerSummons)
				if (#playerSummons >= 1) then
					doRemoveCreature(playerSummons[1])
				end
			end, 120000, getCreatureSummons(cid))

Por isso:

addEvent(function()
				if (#getCreatureSummons(cid) >= 1) then
					doRemoveCreature(playerSummons[1])
				end
			end, 120000)

 

Link to comment
Share on other sites

  • 0

Não testei, mas creio que assim deva dar certo:

Spoiler
function onUse(cid, item, fromPosition, itemEx, toPosition)    
	
	local dolls = {
		
		[13708] = {pet = "Fly Summon"},
		[13711] = {pet = "Dragon Summon"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
		[13712] = {pet = "Dog Summon"},
		[13714] = {pet = "Cat Summon"},
		[13713] = {pet = "Gregory Summon"},
		[13781] = {pet = "Power Oozaru Summon"},
		[13715] = {pet = "Ghost Summon"},
		[13717] = {pet = "Golden Power Summon"},
		[13718] = {pet = "Mini Summon"},
		[13716] = {pet = "Mini Golden Summon"},
		[13782] = {pet = "Red Ghost Summon"},
		[13707] = {pet = "Black Power Summon"},
		[13709] = {pet = "Orc Summon"},
		[13783] = {pet = "Karin Summon"},
		[13706] = {pet = "Anjo Summon"},
		[13710] = {pet = "Wolf God Helper"},
		[13784] = {pet = "Patinho Summon"},
	}
	
	local go = dolls[item.itemid]
	local summon = getCreatureSummons(cid)
	local waittime = 600 -- Tempo de exhaustion em segundos
	local strtime = 250663 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
	
	if exhaustion.check(cid, strtime) then
		doPlayerSendTextMessage(cid, 19, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar pet novamente .")
		return true
	end 
	
	if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid then  
		doPlayerSendCancel(cid, "Voce deve colocar Contrato no lugar do escudo.") 
		return true
	end 
	
	---------------------------------------------------
	if not (getTilePzInfo(getCreaturePosition(cid))) then
		if #summon >= 1 then
			for _, pid in ipairs(summon) do
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já tem criatura summonada")
				exhaustion.set(cid, strtime, waittime)      -- checar time
			end
			return true
		end
		
		if item.itemid == 13708 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13711 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13712 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13714 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		
		if item.itemid == 13713 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		
		if item.itemid == 13781 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13782 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13716 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13717 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13718 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13715 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13707 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13706 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13709 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13783 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13710 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13784 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		else
		doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
		return true
	end
end

 

Acredito que dê para melhorar o código tirando todos esses 'ifs' também, pois se você já sabe o monstro que vai ser summonado e seu respectivo item dentro da tabela 'dolls', e posteriormente na variável 'go', não é necessário ficar checando pelo itemid infinitas vezes, dessa forma:

Spoiler
function onUse(cid, item, fromPosition, itemEx, toPosition)    
	
	local dolls = {
		
		[13708] = {pet = "Fly Summon"},
		[13711] = {pet = "Dragon Summon"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
		[13712] = {pet = "Dog Summon"},
		[13714] = {pet = "Cat Summon"},
		[13713] = {pet = "Gregory Summon"},
		[13781] = {pet = "Power Oozaru Summon"},
		[13715] = {pet = "Ghost Summon"},
		[13717] = {pet = "Golden Power Summon"},
		[13718] = {pet = "Mini Summon"},
		[13716] = {pet = "Mini Golden Summon"},
		[13782] = {pet = "Red Ghost Summon"},
		[13707] = {pet = "Black Power Summon"},
		[13709] = {pet = "Orc Summon"},
		[13783] = {pet = "Karin Summon"},
		[13706] = {pet = "Anjo Summon"},
		[13710] = {pet = "Wolf God Helper"},
		[13784] = {pet = "Patinho Summon"},
	}
	
	local go = dolls[item.itemid]
	local summon = getCreatureSummons(cid)
	local waittime = 600 -- Tempo de exhaustion em segundos
	local strtime = 250663 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
	
	if exhaustion.check(cid, strtime) then
		doPlayerSendTextMessage(cid, 19, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar pet novamente .")
		return true
	end 
	
	if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid then  
		doPlayerSendCancel(cid, "Voce deve colocar Contrato no lugar do escudo.") 
		return true
	end 
	
	---------------------------------------------------
	if not (getTilePzInfo(getCreaturePosition(cid))) then
		if #summon >= 1 then
			for _, pid in ipairs(summon) do
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já tem criatura summonada")
				exhaustion.set(cid, strtime, waittime)      -- checar time
			end
			return true
		end
		
		doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
		doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
		doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
		addEvent(function(playerSummons)
				if (#playerSummons >= 1) then
					doRemoveCreature(playerSummons[1])
				end
			end, 120000, getCreatureSummons(cid))
		exhaustion.set(cid, strtime, waittime)  
	else
		doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
		return true
	end
end

 

 

Edited by lSainty
Link to comment
Share on other sites

  • 0
11 horas atrás, lSainty disse:

Não testei, mas creio que assim deva dar certo:

  Ocultar conteúdo
function onUse(cid, item, fromPosition, itemEx, toPosition)    
	
	local dolls = {
		
		[13708] = {pet = "Fly Summon"},
		[13711] = {pet = "Dragon Summon"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
		[13712] = {pet = "Dog Summon"},
		[13714] = {pet = "Cat Summon"},
		[13713] = {pet = "Gregory Summon"},
		[13781] = {pet = "Power Oozaru Summon"},
		[13715] = {pet = "Ghost Summon"},
		[13717] = {pet = "Golden Power Summon"},
		[13718] = {pet = "Mini Summon"},
		[13716] = {pet = "Mini Golden Summon"},
		[13782] = {pet = "Red Ghost Summon"},
		[13707] = {pet = "Black Power Summon"},
		[13709] = {pet = "Orc Summon"},
		[13783] = {pet = "Karin Summon"},
		[13706] = {pet = "Anjo Summon"},
		[13710] = {pet = "Wolf God Helper"},
		[13784] = {pet = "Patinho Summon"},
	}
	
	local go = dolls[item.itemid]
	local summon = getCreatureSummons(cid)
	local waittime = 600 -- Tempo de exhaustion em segundos
	local strtime = 250663 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
	
	if exhaustion.check(cid, strtime) then
		doPlayerSendTextMessage(cid, 19, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar pet novamente .")
		return true
	end 
	
	if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid then  
		doPlayerSendCancel(cid, "Voce deve colocar Contrato no lugar do escudo.") 
		return true
	end 
	
	---------------------------------------------------
	if not (getTilePzInfo(getCreaturePosition(cid))) then
		if #summon >= 1 then
			for _, pid in ipairs(summon) do
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já tem criatura summonada")
				exhaustion.set(cid, strtime, waittime)      -- checar time
			end
			return true
		end
		
		if item.itemid == 13708 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13711 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13712 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13714 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		
		if item.itemid == 13713 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		
		if item.itemid == 13781 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13782 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13716 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13717 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13718 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13715 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13707 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13706 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13709 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13783 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13710 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		if item.itemid == 13784 then              -- ID DO ITEM 
			doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
			doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
			doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
			addEvent(function(playerSummons)
					if (#playerSummons >= 1) then
						doRemoveCreature(playerSummons[1])
					end
				end, 120000, getCreatureSummons(cid))
			exhaustion.set(cid, strtime, waittime)  
		end 
		
		else
		doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
		return true
	end
end

 

Acredito que dê para melhorar o código tirando todos esses 'ifs' também, pois se você já sabe o monstro que vai ser summonado e seu respectivo item dentro da tabela 'dolls', e posteriormente na variável 'go', não é necessário ficar checando pelo itemid infinitas vezes, dessa forma:

  Ocultar conteúdo
function onUse(cid, item, fromPosition, itemEx, toPosition)    
	
	local dolls = {
		
		[13708] = {pet = "Fly Summon"},
		[13711] = {pet = "Dragon Summon"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
		[13712] = {pet = "Dog Summon"},
		[13714] = {pet = "Cat Summon"},
		[13713] = {pet = "Gregory Summon"},
		[13781] = {pet = "Power Oozaru Summon"},
		[13715] = {pet = "Ghost Summon"},
		[13717] = {pet = "Golden Power Summon"},
		[13718] = {pet = "Mini Summon"},
		[13716] = {pet = "Mini Golden Summon"},
		[13782] = {pet = "Red Ghost Summon"},
		[13707] = {pet = "Black Power Summon"},
		[13709] = {pet = "Orc Summon"},
		[13783] = {pet = "Karin Summon"},
		[13706] = {pet = "Anjo Summon"},
		[13710] = {pet = "Wolf God Helper"},
		[13784] = {pet = "Patinho Summon"},
	}
	
	local go = dolls[item.itemid]
	local summon = getCreatureSummons(cid)
	local waittime = 600 -- Tempo de exhaustion em segundos
	local strtime = 250663 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
	
	if exhaustion.check(cid, strtime) then
		doPlayerSendTextMessage(cid, 19, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar pet novamente .")
		return true
	end 
	
	if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid then  
		doPlayerSendCancel(cid, "Voce deve colocar Contrato no lugar do escudo.") 
		return true
	end 
	
	---------------------------------------------------
	if not (getTilePzInfo(getCreaturePosition(cid))) then
		if #summon >= 1 then
			for _, pid in ipairs(summon) do
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você já tem criatura summonada")
				exhaustion.set(cid, strtime, waittime)      -- checar time
			end
			return true
		end
		
		doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
		doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
		doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 350)
		addEvent(function(playerSummons)
				if (#playerSummons >= 1) then
					doRemoveCreature(playerSummons[1])
				end
			end, 120000, getCreatureSummons(cid))
		exhaustion.set(cid, strtime, waittime)  
	else
		doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
		return true
	end
end

 

 

@lSainty

Realizei o teste do segundo script e realmente foi bem otimizado/Resumido, porem acaba com o mesmo erro!
[20:25:54.116] [Error - Action Interface]
[20:25:54.117] In a timer event called from:
[20:25:54.117] data/actions/scripts/Petsystemm.lua:onUse
[20:25:54.118] Description:
[20:25:54.118] (luaDoRemoveCreature) Creature not found

 

Link to comment
Share on other sites

  • 0
3 horas atrás, lSainty disse:

Não lembro ao certo o funcionamento da função addEvent, mas tenta trocar isso:
 

addEvent(function(playerSummons)
				if (#playerSummons >= 1) then
					doRemoveCreature(playerSummons[1])
				end
			end, 120000, getCreatureSummons(cid))

Por isso:

addEvent(function()
				if (#getCreatureSummons(cid) >= 1) then
					doRemoveCreature(playerSummons[1])
				end
			end, 120000)

 

Resolvido. Obrigado!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...