Postado Julho 2, 2023 2 anos Estou usando esse script para invocar monstro e está funcionando, porém gostaria que o player ou outra pessoal só pudesse invocar quando o monstro atual estivesse morto, tendo 1 monstro por vez na sala, alguém? local items = { {pos = {x = 102, y = 184, z = 7}, itemid = 7382}, } local monsters = { {pos = {x = 102, y = 182, z = 7}, name = "Ancestral Guardian"}, } local config = { onSpawnMonster = CONST_ME_TELEPORT, -- efeito lançado quando monstro é criado onRemoveItem = CONST_ME_BLOCKHIT, -- efeito lançado quando item é removido missingItem = CONST_ME_POFF, -- efeito lançado quando não encontrou o item para remover } -- 255 faz com que não lance efeito algum function onUse(cid, item, frompos, item2, topos) local missing_items, remove_items = false, {} for _, itemcheck in pairs (items) do local i = getTileItemById(itemcheck.pos, itemcheck.itemid).uid if i < 1 then missing_items = true if tonumber(config.missingItem) and config.missingItem ~= 255 then doSendMagicEffect(itemcheck.pos, config.missingItem) end else table.insert(remove_items, i) end end if missing_items then return doPlayerSendCancel(cid, "Está faltando algum item.") else for _, iuid in pairs (remove_items) do if tonumber(config.onRemoveItem) and config.onRemoveItem ~= 255 then doSendMagicEffect(getThingPos(iuid), config.onRemoveItem) end doRemoveItem(iuid) end for _, monsterinfo in pairs (monsters) do local m = doCreateMonster(monsterinfo.name, monsterinfo.pos, false) if isCreature(m) and tonumber(config.onSpawnMonster) and config.onSpawnMonster ~= 255 then doSendMagicEffect(getThingPos(m), config.onSpawnMonster) end end end return true end Editado Julho 3, 2023 2 anos por moleza (veja o histórico de edições)
Postado Julho 5, 2023 2 anos local items = { {pos = {x = 102, y = 184, z = 7}, itemid = 7382}, } local monster = {pos = {x = 102, y = 182, z = 7}, name = "Ancestral Guardian"} local config = { onSpawnMonster = CONST_ME_TELEPORT, -- efeito lançado quando monstro é criado onRemoveItem = CONST_ME_BLOCKHIT, -- efeito lançado quando item é removido missingItem = CONST_ME_POFF, -- efeito lançado quando não encontrou o item para remover } -- 255 faz com que não lance efeito algum local currentMonster = nil function onUse(cid, item, frompos, item2, topos) if currentMonster then -- Já há um monstro presente na sala return doPlayerSendCancel(cid, "Já existe um monstro na sala.") end local missingItems, removeItems = false, {} for _, itemcheck in pairs(items) do local i = getTileItemById(itemcheck.pos, itemcheck.itemid).uid if i < 1 then missingItems = true if tonumber(config.missingItem) and config.missingItem ~= 255 then doSendMagicEffect(itemcheck.pos, config.missingItem) end else table.insert(removeItems, i) end end if missingItems then return doPlayerSendCancel(cid, "Está faltando algum item.") else for _, iuid in pairs(removeItems) do if tonumber(config.onRemoveItem) and config.onRemoveItem ~= 255 then doSendMagicEffect(getThingPos(iuid), config.onRemoveItem) end doRemoveItem(iuid) end local newMonster = doCreateMonster(monster.name, monster.pos, false) if isCreature(newMonster) then currentMonster = newMonster if tonumber(config.onSpawnMonster) and config.onSpawnMonster ~= 255 then doSendMagicEffect(getThingPos(newMonster), config.onSpawnMonster) end end end return true end function onCreatureDeath(cid, corpse, killer) if currentMonster and corpse == currentMonster then currentMonster = nil end return true end Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código. #OpenSource #Programação #Contribuição
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.