Olá, estou elaborando uma quest que nela tem um npc que você entrega um item pra ele (esse item some da sua bp) ai ele te teleporta pra outro local.
Postado em maio 06, 2012
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, 'travel')) then
selfSay('Ola |PLAYERNAME|, me de o item xxx e posso te teleportar. Ok?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerItemCount(cid,ID DO ITEM) >= 1 then
if(doPlayerRemoveItem(cid, ID DO ITEM,1) == true) then
selfSay('Boa Viagem!', cid)
talkState[talkUser] = 0
else
selfSay('Voc\ê n\ão tem o iten.', cid)
talkState[talkUser] = 0
end
else
selfSay('Voc\ê n\ão tem o iten.', cid)
talkState[talkUser] = 0
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Ajudei?
REP+
Postado em maio 06, 2012
More shorter than the other:
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, 'travel')) then
selfSay('Ola |PLAYERNAME|, me de o item xxx e posso te teleportar. Ok?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, ID DO ITEM,1) == true) then
selfSay('Boa Viagem!', cid)
talkState[talkUser] = 0
else
selfSay('Voc\ê n\ão tem o iten.', cid)
talkState[talkUser] = 0
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
That helps to save some RAM... With 1 script, not too much... But with 30 or 40, you are saving a lot...






