[Pedido] Npc Teleport

777777
Por 777777
em Scripts

777777

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 10/12/10Posts: 27

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.

Lucaswc15

avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 13/11/11Posts: 190Char no Tibia: Sweesh
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+

Dantarrix

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 29/04/12Posts: 49

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...