Postado Novembro 26, 2021 3 anos function onUse(player, item, fromPosition, target, toPosition, isHotkey) local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npcName = "Mad" local function removeNpc(name) local var = Npc(name) if var and var:isNpc() then var:remove() end end local creature = Creature(npcName) if not creature then local create = Game.createNpc(npcName, position) if create then create:setMasterPos(position) position:sendMagicEffect(CONST_ME_POFF) player:say("can you help me?", TALKTYPE_MONSTER_SAY) addEvent(removeNpc, 1*60*1000, npcName) return true end else position:sendMagicEffect(CONST_ME_POFF) end end só pode ter 1 npc no server inteiro... certo?
Postado Novembro 26, 2021 3 anos local function removeNpc(creature) local target = Npc(npc) target:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:setStorageValue(storage, 0) target:remove() end function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(storage) < os.time() then local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npcName = "Mad" local storage = 2252 local npc = Game.createNpc(npcName, position) if npc then npc:setMasterPos(position) position:sendMagicEffect(CONST_ME_POFF) player:say("can you help me?", TALKTYPE_MONSTER_SAY) player:setStorageValue(storage, os.time() + 1 * 60) addEvent(removeNpc, 1 * 60 * 1000, npcName) end else position:sendMagicEffect(CONST_ME_POFF) end return true end
Postado Novembro 26, 2021 3 anos Autor 4 horas atrás, Vodkart disse: function onUse(player, item, fromPosition, target, toPosition, isHotkey) local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npcName = "Mad" local function removeNpc(name) local var = Npc(name) if var and var:isNpc() then var:remove() end end local creature = Creature(npcName) if not creature then local create = Game.createNpc(npcName, position) if create then create:setMasterPos(position) position:sendMagicEffect(CONST_ME_POFF) player:say("can you help me?", TALKTYPE_MONSTER_SAY) addEvent(removeNpc, 1*60*1000, npcName) return true end else position:sendMagicEffect(CONST_ME_POFF) end end só pode ter 1 npc no server inteiro... certo? Não, este script vai servir pra sumonar npcs proprios do server que vai auxiliar nas caves, vendas de itens e tudo mais... vai ser um item pra vender no store no caso No caso cada pessoa que tiver o scroll pode sumonar apenas 1 npc até o outro que ele sumonou sumir, é como se fosse aqueles summons da vocação do global Editado Novembro 26, 2021 3 anos por Sh0z (veja o histórico de edições)
Postado Novembro 26, 2021 3 anos function onUse(player, item, fromPosition, target, toPosition, isHotkey) local storage = "2252" if player:getStorageValue(storage) < os.time() then local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npcName = "Mad" local npc = Game.createNpc(npcName, position) function removeNpc(creature) local target = Npc(npc) target:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:setStorageValue(storage, 0) target:remove() end if npc then npc:setMasterPos(position) position:sendMagicEffect(CONST_ME_POFF) player:say("can you help me?", TALKTYPE_MONSTER_SAY) player:setStorageValue(storage, os.time() + 1*60) addEvent(removeNpc, 1*60*1000, npcName) return true else position:sendMagicEffect(CONST_ME_POFF) end else player:sendCancelMessage("You need to wait a minute.") position:sendMagicEffect(CONST_ME_POFF) end end Se quiser testar esse tbem ... local storage = 2252 local function removeNpc(creature) local target = Npc(creature) target:getPosition():sendMagicEffect(CONST_ME_TELEPORT) target:remove() end function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(storage) < os.time() then local npcName = "Mad" local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npc = Game.createNpc(npcName, position) if npc then npc:setMasterPos(position) position:sendMagicEffect(CONST_ME_MAGIC_RED) position:say("Can you help me?", TALKTYPE_MONSTER_SAY) player:setStorageValue(storage, os.time() + 1 * 60) addEvent(removeNpc, 1 * 60 * 1000, npc:getGuid()) else player:sendCancelMessage("There is not enough room.") position:sendMagicEffect(CONST_ME_POFF) end else player:sendCancelMessage("You need to wait a minute.") position:sendMagicEffect(CONST_ME_POFF) end return true end
Postado Novembro 26, 2021 3 anos Autor 1 hora atrás, luanluciano93 disse: function onUse(player, item, fromPosition, target, toPosition, isHotkey) local storage = "2252" if player:getStorageValue(storage) < os.time() then local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npcName = "Mad" local npc = Game.createNpc(npcName, position) function removeNpc(creature) local target = Npc(npc) target:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:setStorageValue(storage, 0) target:remove() end if npc then npc:setMasterPos(position) position:sendMagicEffect(CONST_ME_POFF) player:say("can you help me?", TALKTYPE_MONSTER_SAY) player:setStorageValue(storage, os.time() + 1*60) addEvent(removeNpc, 1*60*1000, npcName) return true else position:sendMagicEffect(CONST_ME_POFF) end else player:sendCancelMessage("You need to wait a minute.") position:sendMagicEffect(CONST_ME_POFF) end end Se quiser testar esse tbem ... local storage = 2252 local function removeNpc(creature) local target = Npc(creature) target:getPosition():sendMagicEffect(CONST_ME_TELEPORT) target:remove() end function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(storage) < os.time() then local npcName = "Mad" local playerPos = player:getPosition() local position = Position(playerPos.x, playerPos.y + 1, playerPos.z) local npc = Game.createNpc(npcName, position) if npc then npc:setMasterPos(position) position:sendMagicEffect(CONST_ME_MAGIC_RED) position:say("Can you help me?", TALKTYPE_MONSTER_SAY) player:setStorageValue(storage, os.time() + 1 * 60) addEvent(removeNpc, 1 * 60 * 1000, npc:getGuid()) else player:sendCancelMessage("There is not enough room.") position:sendMagicEffect(CONST_ME_POFF) end else player:sendCancelMessage("You need to wait a minute.") position:sendMagicEffect(CONST_ME_POFF) end return true end O primeiro deu certo, só tive que colocar um novo local pos junto com o ultimo else, estava dando erro na hora de soltar o efeito, Mas agora está perfeito. Só tenho que testar com 2 ou mais pessoas sumonando o npc... Vou fazer uns testes e depois edito aqui
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.