Infectious
CrazY MoroN
- Joined
- Sep 8, 2007
- Messages
- 16
- Reaction score
- 0
Hi, i've been trying to modify this code:
to allow for multiple items for sale, and im getting errors :,(
this is my modified script:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- 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.
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'gear') or msgcontains(msg, 'eq') then
selfSay('The only thing i give right now is The corrupted sword. it has 107 attack and 71 defence with a +14 modifier.')
elseif msgcontains(msg, 'corrupted') or msgcontains(msg, 'sword') or msgcontains(msg, 'corrupted') or msgcontains(msg, 'sword') then
selfSay('Do you want to bye the corruptors sword? it will cost you 1000 demon dusts and 250 red dragon scales')
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,6530) >= 1 and getPlayerItemCount(cid,2152) >= 100 then
if doPlayerTakeItem(cid,5882,250) and doPlayerTakeItem(cid,5906,1000) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,2447,1)
end
else
selfSay('Sorry, you don\'t have the items i want.')
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())
to allow for multiple items for sale, and im getting errors :,(
this is my modified script:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- 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.
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'gear') or msgcontains(msg, 'eq') then
selfSay('The only thing i sell right now is The corrupted sword. it has 107 attack and 71 defence with a +14 modifier.')
elseif msgcontains(msg, 'corrupted') or msgcontains(msg, 'sword') or msgcontains(msg, 'corrupted') or msgcontains(msg, 'sword') then
selfSay('Do you want to buy the corruptors sword? it will cost you 1000 demon dusts and 250 red dragon scales')
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,5882) >= 250 and getPlayerItemCount(cid,5906) >= 1000 then
if doPlayerTakeItem(cid,5882,250) and doPlayerTakeItem(cid,5906,1000) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,7407,1)
end
else
selfSay('Sorry, you don\'t have the items i want.')
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
elseif msgcontains(msg, 'oblivion') or msgcontains(msg, 'shield') or msgcontains(msg, 'oblivion') or msgcontains(msg, 'shield') then
selfSay('Do you want to buy the oblivion shield? it will cost you 850 demon dusts and 200 red dragon scales')
talk_state = 2
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if getPlayerItemCount(cid,5882) >= 200 and getPlayerItemCount(cid,5906) >= 850 then
if doPlayerTakeItem(cid,5882,200) and doPlayerTakeItem(cid,5906,850) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,2523,1)
end
else
selfSay('Sorry, you don\'t have the items i want.')
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())
Last edited: