Ir para conteúdo
  • 0

Npc que so venda item se tiver tal item!


lib

Pergunta

preciso de um npc que so venda os itens se tiver tal item na bp algume poderia me ajudar ficarei grato!

 

meu script de loot

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()					npcHandler:onThink()					end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'abyss hammer'}, 7414, 20000, 'abyss hammer')
shopModule:addSellableItem({'amazon armor'}, 2500, 2500, 'amazon armor')
shopModule:addSellableItem({'amazon shield'}, 2537, 4000, 'amazon shield')
shopModule:addSellableItem({'amber staff'}, 7426, 8000, 'amber staff')
shopModule:addSellableItem({'angelic axe'}, 196, 5000, 'angelic axe')
shopModule:addSellableItem({'arbalest'}, 5803, 20000, 'arbalest')
shopModule:addSellableItem({'arcane staff'}, 2453, 25000, 'arcane staff')
shopModule:addSellableItem({'assassin dagger'}, 7404, 20000, 'assassin dagger')
shopModule:addSellableItem({'avenger'}, 6528, 20000, 'avenger')
shopModule:addSellableItem({'berserker'}, 7403, 40000, 'berserker')
shopModule:addSellableItem({'blessed sceptre'}, 7429, 50000, 'blessed sceptre')
shopModule:addSellableItem({'blessed shield'}, 2523, 150000, 'blessed shield')


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por lib
Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0


local item = xxx --ID do item necessário.

 

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

 

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

 

local shopModule = ShopModule:new()

npcHandler:addModule(shopModule)

 

shopModule:addSellableItem({'abyss hammer'}, 7414, 20000, 'abyss hammer')

shopModule:addSellableItem({'amazon armor'}, 2500, 2500, 'amazon armor')

shopModule:addSellableItem({'amazon shield'}, 2537, 4000, 'amazon shield')

shopModule:addSellableItem({'amber staff'}, 7426, 8000, 'amber staff')

shopModule:addSellableItem({'angelic axe'}, 196, 5000, 'angelic axe')

shopModule:addSellableItem({'arbalest'}, 5803, 20000, 'arbalest')

shopModule:addSellableItem({'arcane staff'}, 2453, 25000, 'arcane staff')

shopModule:addSellableItem({'assassin dagger'}, 7404, 20000, 'assassin dagger')

shopModule:addSellableItem({'avenger'}, 6528, 20000, 'avenger')

shopModule:addSellableItem({'berserker'}, 7403, 40000, 'berserker')

shopModule:addSellableItem({'blessed sceptre'}, 7429, 50000, 'blessed sceptre')

shopModule:addSellableItem({'blessed shield'}, 2523, 150000, 'blessed shield')

 

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}

 

if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then

if(isSorcerer(cid) or isDruid(cid)) then

if getPlayerItemCount(cid, item) < 1 then

return selfSay("You need 1x "..getItemNameById(item)..".", cid)

end

 

if(getPlayerStorageValue(cid, 30002) == -1) then

selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)

talkState[talkUser] = 1

else

selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)

end

else

selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)

end

elseif(msgcontains(msg, 'yes')) then

if(talkState[talkUser] == 1) then

doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)

selfSay('Here you are young adept, take care yourself.', cid)

setPlayerStorageValue(cid, 30002, 1)

end

talkState[talkUser] = 0

elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then

selfSay('Ok then.', cid)

talkState[talkUser] = 0

end

 

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

  • 0

na verdade essa parte que vc editou n e utilizada e apenas essa

local item = xxx                   --ID do item necessário.

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()					npcHandler:onThink()					end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'abyss hammer'}, 7414, 20000, 'abyss hammer')
shopModule:addSellableItem({'amazon armor'}, 2500, 2500, 'amazon armor')
shopModule:addSellableItem({'amazon shield'}, 2537, 4000, 'amazon shield')
shopModule:addSellableItem({'amber staff'}, 7426, 8000, 'amber staff')
shopModule:addSellableItem({'angelic axe'}, 196, 5000, 'angelic axe')
shopModule:addSellableItem({'arbalest'}, 5803, 20000, 'arbalest')
shopModule:addSellableItem({'arcane staff'}, 2453, 25000, 'arcane staff')
shopModule:addSellableItem({'assassin dagger'}, 7404, 20000, 'assassin dagger')
shopModule:addSellableItem({'avenger'}, 6528, 20000, 'avenger')
shopModule:addSellableItem({'berserker'}, 7403, 40000, 'berserker')
shopModule:addSellableItem({'blessed sceptre'}, 7429, 50000, 'blessed sceptre')
shopModule:addSellableItem({'blessed shield'}, 2523, 150000, 'blessed shield')


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

..


help pls


up


up


.


up


up


up

Link para o comentário
Compartilhar em outros sites

  • 0

na verdade essa parte que vc editou n e utilizada e apenas essa

local item = xxx                   --ID do item necessário.

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()					npcHandler:onThink()					end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'abyss hammer'}, 7414, 20000, 'abyss hammer')
shopModule:addSellableItem({'amazon armor'}, 2500, 2500, 'amazon armor')
shopModule:addSellableItem({'amazon shield'}, 2537, 4000, 'amazon shield')
shopModule:addSellableItem({'amber staff'}, 7426, 8000, 'amber staff')
shopModule:addSellableItem({'angelic axe'}, 196, 5000, 'angelic axe')
shopModule:addSellableItem({'arbalest'}, 5803, 20000, 'arbalest')
shopModule:addSellableItem({'arcane staff'}, 2453, 25000, 'arcane staff')
shopModule:addSellableItem({'assassin dagger'}, 7404, 20000, 'assassin dagger')
shopModule:addSellableItem({'avenger'}, 6528, 20000, 'avenger')
shopModule:addSellableItem({'berserker'}, 7403, 40000, 'berserker')
shopModule:addSellableItem({'blessed sceptre'}, 7429, 50000, 'blessed sceptre')
shopModule:addSellableItem({'blessed shield'}, 2523, 150000, 'blessed shield')


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

..

help pls

up

up

.

up

up

up

 

o Zipter já fez...

Link para o comentário
Compartilhar em outros sites

  • 0

 

o Zipter já fez...

cara se for para responder tópicos com respostas inútil e melhor nem responder, eu falei que modo que ele fez n está certo e corrigi o script!

Link para o comentário
Compartilhar em outros sites

  • 0

cara se for para responder tópicos com respostas inútil e melhor nem responder, eu falei que modo que ele fez n está certo e corrigi o script!

 

Não é resposta inútil, só avisei que a dele eu testei e deu certo aqui, caso queira outro tipo faça você.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...