Postado Janeiro 2, 2015 10 anos Preciso de ajuda com esse script, ele funciona normalmente quando somente um player hita no monstro, mas quando 2 ou mais hitam o script buga e executa varias vezes bugando tudo.. local config = { generator ={ ["Castle Generator I"] = {brother = "Castle Generator II"}, ["Castle Generator II"] = {brother = "Castle Generator I"}, generatorArea ={ fromPos = {x = 1130, y = 1751, z = 7}, toPos = {x = 1134, y = 1813, z = 7} } } } function onKill(cid, target, lastHit) if(config.generator[getCreatureName(target)]) then local t = config.generator[getCreatureName(target)] local brother = getCreatureByName(t.brother) if(isMonster(brother) == true) then if (isInRange(getCreaturePosition(brother), config.generator.generatorArea.fromPos, config.generator.generatorArea.toPos) == true) then return TRUE end else doBroadcastMessage("Os geradores primários foram destruídos, acesso aos geradores reservas liberado!",MESSAGE_STATUS_WARNING) doRemoveItem(getTileItemById({x= 1050, y= 1813, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1812, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1811, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1810, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1809, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1049, y= 1809, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1048, y= 1809, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1047, y= 1809, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1050, y= 1752, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1753, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1754, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1050, y= 1755, z= 7}, 9533).uid) doRemoveItem(getTileItemById({x= 1047, y= 1755, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1048, y= 1755, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1049, y= 1755, z= 7}, 9485).uid) doRemoveItem(getTileItemById({x= 1050, y= 1755, z= 7}, 9485).uid) end end return TRUE end
Postado Janeiro 2, 2015 10 anos Tente: local generator = { ["Castle Generator I"] = {brother = "Castle Generator II"}, ["Castle Generator II"] = {brother = "Castle Generator I"} } local generatorArea = { fromPos = {x = 1130, y = 1751, z = 7}, toPos = {x = 1134, y = 1813, z = 7} } local pos = { {x= 1050, y= 1813, z= 7}, {x= 1050, y= 1812, z= 7}, {x= 1050, y= 1811, z= 7}, {x= 1050, y= 1810, z= 7}, {x= 1050, y= 1809, z= 7}, {x= 1047, y= 1809, z= 7}, {x= 1048, y= 1809, z= 7}, {x= 1047, y= 1809, z= 7}, {x= 1050, y= 1752, z= 7}, {x= 1050, y= 1753, z= 7}, {x= 1050, y= 1754, z= 7}, {x= 1050, y= 1755, z= 7}, {x= 1047, y= 1755, z= 7}, {x= 1048, y= 1755, z= 7}, {x= 1049, y= 1755, z= 7}, {x= 1050, y= 1755, z= 7} } function onKill(cid, target, lastHit) if generator[getCreatureName(target)] then firstm = generator[getCreatureName(target)] secondm = getCreatureByName(firstm.brother) if isMonster(secondm) then if isInRange(getCreaturePosition(secondm), generatorArea.fromPos, generatorArea.toPos) then return true end else items = {9533, 9485} -- items list to remove for p = 1, #pos do for i = 1, #items do item = getTileItemById(pos[p], items[i]) if item.uid > 0 then doRemoveItem(item.uid) end end end doBroadcastMessage('Os geradores primários foram destruídos, acesso aos geradores reservas liberado!') end end return true end Editado Janeiro 2, 2015 10 anos por Suicide (veja o histórico de edições) The corrupt fear us. The honest support us. The heroic join us.
Postado Janeiro 2, 2015 10 anos Autor Tente: local generator = { ["Castle Generator I"] = {brother = "Castle Generator II"}, ["Castle Generator II"] = {brother = "Castle Generator I"} } local generatorArea = { fromPos = {x = 1130, y = 1751, z = 7}, toPos = {x = 1134, y = 1813, z = 7} } local pos = { {x= 1050, y= 1813, z= 7}, {x= 1050, y= 1812, z= 7}, {x= 1050, y= 1811, z= 7}, {x= 1050, y= 1810, z= 7}, {x= 1050, y= 1809, z= 7}, {x= 1047, y= 1809, z= 7}, {x= 1048, y= 1809, z= 7}, {x= 1047, y= 1809, z= 7}, {x= 1050, y= 1752, z= 7}, {x= 1050, y= 1753, z= 7}, {x= 1050, y= 1754, z= 7}, {x= 1050, y= 1755, z= 7}, {x= 1047, y= 1755, z= 7}, {x= 1048, y= 1755, z= 7}, {x= 1049, y= 1755, z= 7}, {x= 1050, y= 1755, z= 7} } function onKill(cid, target, lastHit) if generator[getCreatureName(target)] then firstm = generator[getCreatureName(target)] secondm = getCreatureByName(firstm.brother) if isMonster(secondm) then if isInRange(getCreaturePosition(secondm), generatorArea.fromPos, generatorArea.toPos) then return true end else items = {9533, 9485} -- items list to remove for p = 1, #pos do for i = 1, #items do item = getTileItemById(pos[p], items[i]) if item.uid > 0 then doRemoveItem(item.uid) end end end doBroadcastMessage('Os geradores primários foram destruídos, acesso aos geradores reservas liberado!') end end return true end Testei aqui mas ocorre o seguinte erro: [2/1/2015 16:48:23] [Error - CreatureScript Interface] [2/1/2015 16:48:23] data/creaturescripts/scripts/Castle/CastleGeneratorI.lua:onKill [2/1/2015 16:48:23] Description: [2/1/2015 16:48:23] .../creaturescripts/scripts/Castle/CastleGeneratorI.lua:31: attempt to index global 't' (a nil value) [2/1/2015 16:48:23] stack traceback: [2/1/2015 16:48:23] .../creaturescripts/scripts/Castle/CastleGeneratorI.lua:31: in function <.../creaturescripts/scripts/Castle/CastleGeneratorI.lua:30>
Postado Janeiro 2, 2015 10 anos Testei aqui mas ocorre o seguinte erro: Erro de atenção, já corrigi, teste. The corrupt fear us. The honest support us. The heroic join us.
Postado Janeiro 2, 2015 10 anos Autor Erro de atenção, já corrigi, teste. Agora funcionou mas continua com o mesmo bug ele executa o script varias vezes quando 2 ou mais players atacam o monstro.. [2/1/2015 17:6:11] > Broadcasted message: "Os geradores primários foram destruídos, acesso aos geradores reservas liberado!". [2/1/2015 17:6:11] > Broadcasted message: "Os geradores primários foram destruídos, acesso aos geradores reservas liberado!".
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.