What do you mean? Can you talk more properly please.
If you need the code of NPC Buy addon system.
HERE:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Addons" script="data/npc/scripts/addons.lua" walkinterval="111" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
</npc>
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() end
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'forge') then
selfSay('I can give you magic sulphurs for 3 fire swords, fighting spirits for 2 royal helmets, enchanted chicken wings for 1 boots of haste, warriors sweat for 4 warrior helmets.', cid)
elseif msgcontains(msg, 'fire swords') or msgcontains(msg, 'magic sulphur') or msgcontains(msg, 'magicsulphur') or msgcontains(msg, 'fireswords') then
selfSay('Do you want to trade 3 fire swords for a magic sulphur.', cid)
talk_state = 1
elseif msgcontains(msg, 'royal helmets') or msgcontains(msg, 'royalhelmets') or msgcontains(msg, 'fighting spirit') or msgcontains(msg, 'fightingspirit') then
selfSay('Do you want to trade 2 royal helmets for a fighting spirit.', cid)
talk_state = 2
elseif msgcontains(msg, 'boots of haste') or msgcontains(msg, 'boh') or msgcontains(msg, 'enchanted chicken wing') or msgcontains(msg, 'chicken wing') then
selfSay('Do you want to trade 1 pair of boots of haste for an enchanted chicken wing.', cid)
talk_state = 3
elseif msgcontains(msg, 'warriors sweat') or msgcontains(msg, 'warriors sweat') or msgcontains(msg, 'warriorssweat') or msgcontains(msg, 'warrior helmet') or msgcontains(msg, 'warrior helmets') then
selfSay('Do you want to trade 4 warrior helmets for a warriors sweat.', cid)
talk_state = 4
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,2392) >= 3 then
if doPlayerTakeItem(cid,2392,3) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5904,1)
end
else
selfSay('You dont have the items i need.')
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if getPlayerItemCount(cid,2498) >= 2 then
if doPlayerTakeItem(cid,2498,2) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5884,1)
end
else
selfSay('You dont have the items i need.')
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
if getPlayerItemCount(cid,2195) >= 1 then
if doPlayerTakeItem(cid,2195,1) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5891,1)
end
else
selfSay('You dont have the items i need.', cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
if getPlayerItemCount(cid,2475) >= 4 then
if doPlayerTakeItem(cid,2475,4) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5885,1)
end
else
selfSay('You dont have the items i need.', cid)
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
selfSay('Bye then...', cid)
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Sweaty Cyclop:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() end
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'forge') then
selfSay('I can forge you royal steel from crown armors, hell steel from devil helmets, draconian steel from dragon shields, crude iron from giant swords and infernal bolts from soul orbs.', cid)
elseif msgcontains(msg, 'royal steel') or msgcontains(msg, 'royal') or msgcontains(msg, 'crown') or msgcontains(msg, 'crown armor') or msgcontains(msg, 'uth\'kean') then
selfSay('Do you want to trade a crown armor for royal steel?', cid)
talk_state = 1
elseif msgcontains(msg, 'hell steel') or msgcontains(msg, 'hell') or msgcontains(msg, 'devil') or msgcontains(msg, 'devil helmet') or msgcontains(msg, 'za\'ralator') then
selfSay('Do you want to trade a devil helmet for hell steel?', cid)
talk_state = 2
elseif msgcontains(msg, 'draconian steel') or msgcontains(msg, 'draconian') or msgcontains(msg, 'dragon') or msgcontains(msg, 'dragon shield') or msgcontains(msg, 'uth\'lokr') then
selfSay('Do you want to trade a dragon shield for draconian steel?', cid)
talk_state = 3
elseif msgcontains(msg, 'crude iron') or msgcontains(msg, 'crude') or msgcontains(msg, 'giant') or msgcontains(msg, 'gs') or msgcontains(msg, 'giant sword') or msgcontains(msg, 'uth\'prta') then
selfSay('Do you want to trade a giant sword for crude iron?', cid)
talk_state = 4
elseif msgcontains(msg, 'infernal') or msgcontains(msg, 'infernal bolt') or msgcontains(msg, 'infernal bolts') or msgcontains(msg, 'soul') or msgcontains(msg, 'soul orb') or msgcontains(msg, 'soul orbs') or msgcontains(msg, 'nasty lil\' bolt') then
selfSay('Do you want to trade a soul orb for 2 infernal bolts?', cid)
talk_state = 5
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,2487) >= 1 then
if doPlayerTakeItem(cid,2487,1) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5887,1)
end
else
selfSay('Come back when you have more!', cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if getPlayerItemCount(cid,2462) >= 1 then
if doPlayerTakeItem(cid,2462,1) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5888,1)
end
else
selfSay('Come back when you have more!', cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
if getPlayerItemCount(cid,2516) >= 1 then
if doPlayerTakeItem(cid,2516,1) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5889,1)
end
else
selfSay('Come back when you have more!', cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
if getPlayerItemCount(cid,2393) >= 1 then
if doPlayerTakeItem(cid,2393,1) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,5892,1)
end
else
selfSay('Come back when you have more!', cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 5 then
if getPlayerItemCount(cid,5944) >= 1 then
if doPlayerTakeItem(cid,5944,1) == 0 then
selfSay('Here you are.', cid)
doPlayerAddItem(cid,6529,2)
end
else
selfSay('Come back when you have more!', cid)
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) then
selfSay('Ok than.', cid)
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())