local storage = 12345 -- Storage necessária para viajarlocal destination = {x=463, y=446, z=5} -- Posição onde o player irá teleporta local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg:lower()) endfunction onThink() npcHandler:onThink() endlocal talkState = {} 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, "city 1") then talkState[talkUser] = 1 if getPlayerStorageValue(cid, storage) > 0 then npcHandler:releaseFocus(cid) doTeleportThing(cid, destination) else selfSay("Me desculpe, mas você não tem acesso a city 1.", cid) end talkState[talkUser] = 0 end return trueend keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu posso levá-lo para? {city 1}'})npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())





info
Grupo: Campones
Registrado: 01/05/15
Posts: 49
Reputação: +2
Galera queria ajuda com um Npc, tipo ele funciona normal eu digo Hi ele diz: Hello Teste. say travel. eu digo travel ele diz: Eu posso levá-lo para? city 1 eu digo city 1 e ele me leva normal.
Porem gostaria que o npc verificasse se ele tem X storage se ele nao tiver ele nao e teleportado e ele manda uma mensagem pro player: Voce nao tem tal storage.
Script:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
local travelNode = keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu posso levá-lo para? {city 1}'})
travelNode:addChildKeyword({'city 1'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=463, y=446, z=5} })
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
Ah e se for possivel gostaria de saber se tem como arrumar o BUG de um jogador dizer que vai pra tal cidade e o outro diz ao mesmo tempo, ai quando o outro jogador diz yes vai pra cidade errada que foi a cidade que o outro jogador disse ...