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
npcHandler:setMessage(MESSAGE_GREET, "Hum Humm! Welcume lil Player? Im make steel, {royal steel}.")
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, 'uth kean') or msgcontains(msg, 'crown')) then
selfSay('Do you want to change your crown armor for my piece of royal steel?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerItemCount(cid, 2487) >= 1) then
if(doPlayerRemoveMoney(cid, 0) == TRUE) then
local item = getPlayerItemById(cid, TRUE, 2487)
doTransformItem(item.uid, 5887)
selfSay('Cling clang.', cid)
else
selfSay('Sorry, you dont have enough gold.', cid)
end
else
selfSay('Sorry, you dont item.', cid)
end
else
if(msgcontains(msg, 'uth lokr') or msgcontains(msg, 'dragon shield')) then
selfSay('Firy steel it is. Need green ones breath to melt. Or red even better. Me can make from shield. Lil one want to trade?', cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if(getPlayerItemCount(cid, 2516) >= 1) then
if(doPlayerRemoveMoney(cid, 0) == TRUE) then
local item = getPlayerItemById(cid, TRUE, 2516)
doTransformItem(item.uid, 5889)
selfSay('Cling clang!', cid)
else
selfSay('Sorry, you dont have enough gold.', cid)
end
else
selfSay('Sorry, you dont item.', cid)
end
else
if(msgcontains(msg, 'za ralator') or msgcontains(msg, 'Devil helmet')) then
selfSay('Hellsteel is. Cursed and evil. Dangerous to work with. Me can make from evil helmet. Lil one want to trade?', cid)
talkState[talkUser] = 3
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
if(getPlayerItemCount(cid, 2462) >= 1) then
if(doPlayerRemoveMoney(cid, 0) == TRUE) then
local item = getPlayerItemById(cid, TRUE, 2462)
doTransformItem(item.uid, 5888)
selfSay('Cling clang! ', cid)
else
selfSay('Sorry, you dont have enough gold.', cid)
end
else
selfSay('Sorry, you dont have item.', cid)
end
else
if(msgcontains(msg, 'uth prta') or msgcontains(msg, 'Giant sword')) then
selfSay('Good iron is. Me friends use it much for fight. Me can make from weapon. Lil one want to trade?', cid)
talkState[talkUser] = 4
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
if(getPlayerItemCount(cid, 2393) >= 1) then
if(doPlayerRemoveMoney(cid, 0) == TRUE) then
local item = getPlayerItemById(cid, TRUE, 2393)
doTransformItem(item.uid, 5892)
selfSay('Cling clang! ', cid)
else
selfSay('Sorry, you dont have enough gold.', cid)
end
else
selfSay('Sorry, you dont item.', cid)
end
else
if(msgcontains(msg, 'soul orb') or msgcontains(msg, 'infernal bolt')) then
selfSay('Uh. Me can make some nasty lil bolt from soul orbs. Lil one want to trade all?', cid)
talkState[talkUser] = 5
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
if(getPlayerItemCount(cid, 5944) >= 1) then
if(doPlayerRemoveMoney(cid, 0) == TRUE) then
local item = getPlayerItemById(cid, TRUE, 5944)
doTransformItem(item.uid, 6529)
selfSay('Cling clang! ', cid)
else
selfSay('Sorry, you dont have enough gold.', cid)
end
else
selfSay('Sorry, you dont item.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Good bye lil one.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Heres one that might work you for
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 npcHandler:setMessage(MESSAGE_GREET, "Hum Humm! Welcume lil Player? Im make steel, {royal steel}.") 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, 'uth kean') or msgcontains(msg, 'crown')) then selfSay('Do you want to change your crown armor for my piece of royal steel?', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(getPlayerItemCount(cid, 2487) >= 1) then if(doPlayerRemoveMoney(cid, 0) == TRUE) then local item = getPlayerItemById(cid, TRUE, 2487) doTransformItem(item.uid, 5887) selfSay('Cling clang.', cid) else selfSay('Sorry, you dont have enough gold.', cid) end else selfSay('Sorry, you dont item.', cid) end else if(msgcontains(msg, 'uth lokr') or msgcontains(msg, 'dragon shield')) then selfSay('Firy steel it is. Need green ones breath to melt. Or red even better. Me can make from shield. Lil one want to trade?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerItemCount(cid, 2516) >= 1) then if(doPlayerRemoveMoney(cid, 0) == TRUE) then local item = getPlayerItemById(cid, TRUE, 2516) doTransformItem(item.uid, 5889) selfSay('Cling clang!', cid) else selfSay('Sorry, you dont have enough gold.', cid) end else selfSay('Sorry, you dont item.', cid) end else if(msgcontains(msg, 'za ralator') or msgcontains(msg, 'Devil helmet')) then selfSay('Hellsteel is. Cursed and evil. Dangerous to work with. Me can make from evil helmet. Lil one want to trade?', cid) talkState[talkUser] = 3 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then if(getPlayerItemCount(cid, 2462) >= 1) then if(doPlayerRemoveMoney(cid, 0) == TRUE) then local item = getPlayerItemById(cid, TRUE, 2462) doTransformItem(item.uid, 5888) selfSay('Cling clang! ', cid) else selfSay('Sorry, you dont have enough gold.', cid) end else selfSay('Sorry, you dont have item.', cid) end else if(msgcontains(msg, 'uth prta') or msgcontains(msg, 'Giant sword')) then selfSay('Good iron is. Me friends use it much for fight. Me can make from weapon. Lil one want to trade?', cid) talkState[talkUser] = 4 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then if(getPlayerItemCount(cid, 2393) >= 1) then if(doPlayerRemoveMoney(cid, 0) == TRUE) then local item = getPlayerItemById(cid, TRUE, 2393) doTransformItem(item.uid, 5892) selfSay('Cling clang! ', cid) else selfSay('Sorry, you dont have enough gold.', cid) end else selfSay('Sorry, you dont item.', cid) end else if(msgcontains(msg, 'soul orb') or msgcontains(msg, 'infernal bolt')) then selfSay('Uh. Me can make some nasty lil bolt from soul orbs. Lil one want to trade all?', cid) talkState[talkUser] = 5 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then if(getPlayerItemCount(cid, 5944) >= 1) then if(doPlayerRemoveMoney(cid, 0) == TRUE) then local item = getPlayerItemById(cid, TRUE, 5944) doTransformItem(item.uid, 6529) selfSay('Cling clang! ', cid) else selfSay('Sorry, you dont have enough gold.', cid) end else selfSay('Sorry, you dont item.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Good bye lil one.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
item = 'You do not have the required items.'
done = 'Here you are.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'offer') then
selfSay('You can here change some items for "spider silk yarn", "chunk of crude iron", "draconian steel", "warrior sweat", "magic sulphur", "enchanted chicken wing", "royal steel", "hell steel", "elane crossbow", "fighting spirit", "infernal bolt", "blue piece of cloth", "green piece of cloth", "red piece of cloth", "lottery ticket".', cid)
elseif msgcontains(msg, 'spider silk yarn') then
if getPlayerItemCount(cid,5879) >= 10 then
selfSay('Did you bring me the 10 Giant Silks ?', cid)
talk_state = 1
else
selfSay('I need a 10 Giant Spider Silks, to give you the spider silk yarn. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,5879) >= 10 then
if doPlayerRemoveItem(cid,5879, 10) == TRUE then
selfSay(done, cid)
doPlayerAddItem(cid, 5886, 1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'chunk of crude iron') then
if getPlayerItemCount(cid,2393) >= 1 then
selfSay('Did you bring me the Giant Sword ?', cid)
talk_state = 2
else
selfSay('I need a Giant Sword, to give you the chunk of crude iron. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,2393) >= 1 then
if doPlayerRemoveItem(cid,2393,1) == TRUE then
selfSay(done, cid)
doPlayerAddItem(cid,5892,1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'ticket') or msgcontains(msg, 'lottery') or msgcontains(msg, 'lottery ticket') or msgcontains(msg, 'lotery ticket') then
if getPlayerItemCount(cid,2160) >= 5 then
selfSay('Did you bring me the 5cc?', cid)
talk_state = 15
else
selfSay('I need a 5cc, to give you a lottery ticket. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 15 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 5 then
if doPlayerRemoveItem(cid,2160,5) == TRUE then
selfSay(addon_give)
doPlayerAddItem(cid,5957,1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'draconian steel') then
if getPlayerItemCount(cid,2516) >= 1 then
selfSay('Did you bring me Dragon Shield ?', cid)
talk_state = 3
else
selfSay('I need Dragon Shield, to give you the draconian steel. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,2516) >= 1 then
if doPlayerRemoveItem(cid,2516,1) == TRUE then
doPlayerAddItem(cid,5889,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'warrior sweat') then
if getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 then
selfSay('Did you bring me 4 warrior helmets?', cid)
talk_state = 4
else
selfSay('I need 4 warrior helmets, to give you the warrior sweat. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 4 then
talk_state = 0
if getPlayerItemCount(cid,2475) >= 4 then
if doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE then
doPlayerAddItem(cid,5885,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'magic sulphur') then
if getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 then
selfSay('Did you bring me 3 fire swords?', cid)
talk_state = 5
else
selfSay('I need 3 fire swords, to give you the magic sulpher. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 5 then
talk_state = 0
if getPlayerItemCount(cid,2392) >= 3 then
if doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE then
doPlayerAddItem(cid,5904,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'enchanted chicken wing') then
if getPlayerItemCount(cid,2195) >= 1 then
selfSay('Did you bring me boots of haste?', cid)
talk_state = 6
else
selfSay('I need boots of haste, to give you the enchanted chicken wing. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 6 then
talk_state = 0
if getPlayerItemCount(cid,2195) >= 1 then
if doPlayerRemoveItem(cid,2195,1) == TRUE then
doPlayerAddItem(cid,5891,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'royal steel') then
if getPlayerItemCount(cid,2487) >= 1 then
selfSay('Did you bring me the Crown Armor ?', cid)
talk_state = 7
else
selfSay('I need Crown Armor, to give you the royal steel. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 7 then
talk_state = 0
if getPlayerItemCount(cid,2487) >= 1 then
if doPlayerRemoveItem(cid,2487,1) == TRUE then
doPlayerAddItem(cid,5887,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'hell steel') then
if getPlayerItemCount(cid,2462) >= 1 then
selfSay('Did you bring me the Devil Helmet ?', cid)
talk_state = 8
else
selfSay('I need a Devil Helmet, to give you the hell steel. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 8 then
talk_state = 0
if getPlayerItemCount(cid,2462) >= 1 then
if doPlayerRemoveItem(cid,2462,1) == TRUE then
doPlayerAddItem(cid,5888,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'crossbow') then
if getPlayerItemCount(cid,5954) >= 15 then
selfSay('Did you bring me the 15 demon horns?', cid)
talk_state = 9
else
selfSay('I need a 15 demon horns, to give you the elane crossbow. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 9 then
talk_state = 0
if getPlayerItemCount(cid,5954) >= 15 then
if doPlayerRemoveItem(cid,5954,15) == TRUE then
doPlayerAddItem(cid,5947,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'fighting spirit') then
if getPlayerItemCount(cid,2498) >= 1 and getPlayerItemCount(cid,2498) >= 1 then
selfSay('Did you bring me the 2 Royal Helmets?', cid)
talk_state = 10
else
selfSay('I need a 2 Royal Helmets, to give you the Fighting Spirit. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 10 then
talk_state = 0
if getPlayerItemCount(cid,2498) >= 2 then
if doPlayerRemoveItem(cid,2498,1) == TRUE and doPlayerRemoveItem(cid,2498,1) == TRUE then
doPlayerAddItem(cid,5884,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'infernal bolt') then
if getPlayerItemCount(cid,5944) >= 1 then
selfSay('Did you bring me the Soul Orb?', cid)
talk_state = 11
else
selfSay('I need a Soul Orb, to give you the 10 Infernal Bolts. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 11 then
talk_state = 0
if getPlayerItemCount(cid,5944) >= 1 then
if doPlayerRemoveItem(cid,5944,1) == TRUE then
doPlayerAddItem(cid,6529,10)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'blue piece of cloth') then
if getPlayerItemCount(cid,2663) >= 1 then
selfSay('Did you bring me the Mystic Turban ?', cid)
talk_state = 12
else
selfSay('I need a Mystic Turban, to give you the Blue Piece of Cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 12 then
talk_state = 0
if getPlayerItemCount(cid,2663) >= 1 then
if doPlayerRemoveItem(cid,2663,1) == TRUE then
doPlayerAddItem(cid,5912,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'green piece of cloth') then
if getPlayerItemCount(cid,2652) >= 1 then
selfSay('Did you bring me the Green Tunic ?', cid)
talk_state = 13
else
selfSay('I need a Green Tunic, to give you the Green Piece of Cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 13 then
talk_state = 0
if getPlayerItemCount(cid,2652) >= 1 then
if doPlayerRemoveItem(cid,2652,1) == TRUE then
doPlayerAddItem(cid,5910,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'red piece of cloth') then
if getPlayerItemCount(cid,2655) >= 1 then
selfSay('Did you bring me the Red Robe ?', cid)
talk_state = 14
else
selfSay('I need a Red Robe, to give you the Red Piece of Cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 14 then
talk_state = 0
if getPlayerItemCount(cid,2655) >= 1 then
if doPlayerRemoveItem(cid,2655,1) == TRUE then
doPlayerAddItem(cid,5911,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())