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())
3
1.6k
info
Grupo: Cavaleiro
Registrado: 13/11/11
Posts: 190
Reputação: +20
Char no Tibia: Sweesh

06 de maio de 2012 às 09:30
06 de maio de 2012 às 11:04
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...
Editado Maio 6 por Dantarrixx



info
Grupo: Campones
Registrado: 09/12/10
Posts: 27
Reputação: +9
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.
Editado Maio 6 por Patrickstrela