First of all i'm using tfs 0.3.6
I want to do a npc that asks for 4 items (for example) and removes it from you, then adds to you a complete different item (just one)
I don't have any idea on how to .lua. I was just entering things that seemed logical but i can't make it work!
thats why i'm here
I'm using this one, the npc answers to everything but keeps saying You don't have the required items (i have them all)
thanks!
I want to do a npc that asks for 4 items (for example) and removes it from you, then adds to you a complete different item (just one)
I don't have any idea on how to .lua. I was just entering things that seemed logical but i can't make it work!
thats why i'm here
I'm using this one, the npc answers to everything but keeps saying You don't have the required items (i have them all)
Code:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'acces') or msgcontains(msg, 'quests')) then
selfSay('Did you bring me 10 golden nuggets, 10 magic plate armor, 10 golden legs and 10 mastermind shields?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerItemCount(cid, 2157) >= 1 and getPlayerItemCount(cid, 2470) >= 1 and getPlayerItemCount(cid, 2472) >= 1 and getPlayerItemCount(cid, 2514)) >= 1 then
if (doPlayerRemoveItem(cid,2157,1) and doPlayerRemoveItem(cid,2470,1) and doPlayerRemoveItem(cid,2472,1) and doPlayerRemoveItem(cid,2514,1)) == 0 then
doPlayerAddItem(cid, 11401)
selfSay('Use this item to gain acces for the quests.', cid)
else
selfSay('You dont have the required items.', cid)
end
else
selfSay('You dont have the required items.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Maybe later?.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
thanks!
Last edited: