Ir para conteúdo

Featured Replies

Postado
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?

  • Respostas 10
  • Visualizações 1.4k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • testei aqui ele não sumona, fica dando poff como se ja existisse um npc criado. Vou mandar um video 20211125_232815.mp4

  • luanluciano93
    luanluciano93

    function onUse(player, item, fromPosition, target, toPosition, isHotkey) local storage = "2252" if player:getStorageValue(storage) < os.time() then local playerPos = player:getPosition() lo

  • luanluciano93
    luanluciano93

    ótimo, editei aqui ...  function onUse(player, item, fromPosition, target, toPosition, isHotkey) local storage = "2252" local playerPos = player:getPosition() if player:getStorageValue(storag

Postado
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
  • 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 por Sh0z (veja o histórico de edições)

Postado
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
  • 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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo