Ir para conteúdo

Featured Replies

Postado

Ola, eu estive pedindo ajuda no Discord do TK, pra q o NPC somente remova o item se o item for o verdadeiro, ou seja, se voce tiver dois itens do mesmo ID na bag e, um for o veradeiro e o outro falso, ele so remove se o item verdadeiro estiver no slot 1 da bag.
Entao eu desejo q ele remova o item verdadeiro independete se tem dois ou mais itens do mesmo ID, mas que remova o que estiver com a descriçao X.
Este é NPC quem eu estive tentando fazer pra q remova somente se o item tiver X decriçao.

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureSay(cid,type,msg) npcHandler:onCreatureSay(cid, type, msg)
	if isInArray({"poem", "ps"}, msg) then
		npcHandler:say("Do you want to exchange this Poem for a {beach backpack}?", cid)
		talkState = 1
	local item = getPlayerItemCount(cid,6119) >= 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
		if item then
				doPlayerRemoveItem(cid,6119,1, getItemAttribute(item.uid, "description") == "test")
				doPlayerAddItem(cid,5949,1)
				npcHandler:say("here's your item", cid)
			else
				npcHandler:say("You don't have the item", cid)
		end
	end
end
npcHandler:addModule(FocusModule:new())

 

 

@Breno Alves

 

Postado

Tenta assim

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureSay(cid,type,msg) npcHandler:onCreatureSay(cid, type, msg)
	if isInArray({"poem", "ps"}, msg) then
		npcHandler:say("Do you want to exchange this Poem for a {beach backpack}?", cid)
		talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
        item = getPlayerItemCount(cid,6119) >= 1
		if item then
            if getItemAttribute(item.uid, "description") == "teste" then
				doPlayerRemoveItem(cid,6119,1)
				doPlayerAddItem(cid,5949,1)
				npcHandler:say("here's your item", cid)
            end
		else
			npcHandler:say("You don't have the item", cid)
		end
	end
end
npcHandler:addModule(FocusModule:new())

 

Postado
  • Autor
19 minutos atrás, Breno Alves disse:

Tenta assim



local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureSay(cid,type,msg) npcHandler:onCreatureSay(cid, type, msg)
	if isInArray({"poem", "ps"}, msg) then
		npcHandler:say("Do you want to exchange this Poem for a {beach backpack}?", cid)
		talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
        item = getPlayerItemCount(cid,6119) >= 1
		if item then
            if getItemAttribute(item.uid, "description") == "teste" then
				doPlayerRemoveItem(cid,6119,1)
				doPlayerAddItem(cid,5949,1)
				npcHandler:say("here's your item", cid)
            end
		else
			npcHandler:say("You don't have the item", cid)
		end
	end
end
npcHandler:addModule(FocusModule:new())

 


image.thumb.png.b6a2d7d65696ad2b44326f0dfd24cad0.png

Alterei getPlayerItemCount(cid,6119) >= 1
por getPlayerItemById(cid, true, 6119)
nao gerou erro mas tbm nao removeu o item

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

Postado
14 horas atrás, Backa disse:

Ola, eu estive pedindo ajuda no Discord do TK, pra q o NPC somente remova o item se o item for o verdadeiro, ou seja, se voce tiver dois itens do mesmo ID na bag e, um for o veradeiro e o outro falso, ele so remove se o item verdadeiro estiver no slot 1 da bag.
Entao eu desejo q ele remova o item verdadeiro independete se tem dois ou mais itens do mesmo ID, mas que remova o que estiver com a descriçao X.
Este é NPC quem eu estive tentando fazer pra q remova somente se o item tiver X decriçao.

  Mostrar conteúdo oculto


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureSay(cid,type,msg) npcHandler:onCreatureSay(cid, type, msg)
	if isInArray({"poem", "ps"}, msg) then
		npcHandler:say("Do you want to exchange this Poem for a {beach backpack}?", cid)
		talkState = 1
	local item = getPlayerItemCount(cid,6119) >= 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
		if item then
				doPlayerRemoveItem(cid,6119,1, getItemAttribute(item.uid, "description") == "test")
				doPlayerAddItem(cid,5949,1)
				npcHandler:say("here's your item", cid)
			else
				npcHandler:say("You don't have the item", cid)
		end
	end
end
npcHandler:addModule(FocusModule:new())

 

 

@Breno Alves

 


É pra checar se existe um ITEMID X com a descrição X no SLOT 1 e caso sim, remover?
Se não for isso reformule a sua ideia.

Postado
  • Autor
3 horas atrás, 139 disse:


É pra checar se existe um ITEMID X com a descrição X no SLOT 1 e caso sim, remover?
Se não for isso reformule a sua ideia.


image.png.86851d938e88f5751bca179971d5d53a.png

o item verde é quem esta com a descriçao, e o vermelho, é o normal.

Entao ele vai checar se o Player tem o item verde e vai remover somente o verde. Que no caso com a descriçao.
Porem, se tiver 2 itens do mesmo ID como a imagem mostra, ele so remove se o item verde for, o primeiro do slot da bag ou seja, se ele estiver lugar do item vermelho. Ou se o item verde for o unico item na bag.
entao eu gostaria que ele removesse somente o item verde idependete de qual slot esteja e quantos outros itens do mesmo ID tenha.
 

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