Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

.Qual servidor ou website você utiliza como base? 

 

Qual o motivo deste tópico? 

 

Está surgindo algum erro? Se sim coloque-o aqui. 

Citar

 

 

Você tem o código disponível? Se tiver publique-o aqui: 

  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 storage = "2252"
	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
end

Bom vamos lá Fiz um action que ao usar um certo scroll tu sumona um npc por 1 minuto. O codigo em si está 100% funcional porém quanto mais eu clico no scroll mais npcs eu gero. Queria limitar apenas a 1 npc. Mas não estou conseguindo... Alguem pode me auxiliar?

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

Resolvido por luanluciano93

Ir para solução
  • Respostas 10
  • Visualizações 1.6k
  • 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

 

Editado por Marco Oliveira (veja o histórico de edições)

Postado
  • Autor
1 hora atrás, Marco Oliveira disse:

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

 

não deu certo, dessa forma nem sumona o npc fica dando o poff mesmo se eu nao tiver com o os.time

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	
	if not Npc(npcName) 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

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Postado
  • Autor
6 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	
	if not Npc(npcName) 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

 

 

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

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