77

[Pedido] Npc Teleport

Por 777777, 06 de mai. de 2012 em Scripts

npc
teleport
pedido
script
item
quest
3
1.6k
7777777
06 de maio de 2012 às 01:28

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

Lucaswc15L
06 de maio de 2012 às 09:30
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())

DantarrixD
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