chauffaille
New Member
- Joined
- Sep 10, 2009
- Messages
- 198
- Reaction score
- 1
Hi, I have a doubt on a npc script
how do I later add another item to sell that same script?
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
npcHandler:say(getPlayerSex(cid) == 0 and "Oi, eu vendo itens especiais." or "como vai? eu vendo itens especiais.", cid)
Topic[cid] = 0
npcHandler:addFocus(cid)
elseif msgcontains(msg, "imperator armor") and npcHandler:isFocused(cid) then
npcHandler:say("quer comprar imperator armor por 50 pedras do inferno?", cid)
Topic[cid] = 1
elseif Topic[cid] == 1 then
if msgcontains(msg, "yes") then
if doPlayerRemoveItem(cid, 9020, 50) then
npcHandler:say("Aqui Está.", cid)
doPlayerAddItem(cid, 8891, 1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
Topic[cid] = 0
else
npcHandler:say("Voce nao tem pedras do inferno o suficiente.", cid)
Topic[cid] = 0
end
elseif msgcontains(msg, "no") then
npcHandler:say("Tudo bem.", cid)
Topic[cid] = 0
end
elseif(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") and npcHander:isFocused(cid) then
npcHandler:say("Good bye.", cid, TRUE)
Topic[cid] = nil
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "job") then
npcHandler:say("I can give you a new {cape} in exchange for a dirty one.", cid)
Topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
how do I later add another item to sell that same script?