Postado Agosto 6, 2015 9 anos Olá, gostaria de uma ajudinha aqui, eu tenho um npc e não to conseguindo adicionar, um "back" para ele voltar para o templo. 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 local cfg = { toPos = {x=964, y=1025, z=14}, level = 1, Storage = 25747 } function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local player = Player(cid) if msgcontains(msg, 'bosses') then selfSay('There are some undead below, you agree to be teleported there?', cid) talkState[talkUser] = 1 elseif talkState[talkUser] == 1 then if msgcontains(msg, 'yes') then if player:getStorageValue(cfg.Storage) > 0 then selfSay('You\'ve done it.', cid) return FALSE end if getPlayerLevel(cid) >= cfg.level then doTeleportThing(cid, cfg.toPos) talkState[talkUser] = 0 else selfSay('Only players level ' ..cfg.level.. ' can pass.', cid) end end if msgcontains(msg, 'no') and talkState[talkUser] == 1 then selfSay('Okay, you\'re a smart and probably know the face of danger that exists there.', cid) talkState[talkUser] = 0 end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Agosto 7, 2015 9 anos Solução Tenta assim: 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 local cfg = { toPos = {x=964, y=1025, z=14}, level = 1, Storage = 25747, temploPos = {x = 444, y = 444, z = 7} } function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local player = Player(cid) if msgcontains(msg, 'bosses') then selfSay('There are some undead below, you agree to be teleported there?', cid) talkState[talkUser] = 1 elseif talkState[talkUser] == 1 then if msgcontains(msg, 'yes') then if player:getStorageValue(cfg.Storage) > 0 then selfSay('You\'ve done it.', cid) return FALSE end if getPlayerLevel(cid) >= cfg.level then doTeleportThing(cid, cfg.toPos) talkState[talkUser] = 0 else selfSay('Only players level ' ..cfg.level.. ' can pass.', cid) end end if msgcontains(msg, 'no') and talkState[talkUser] == 1 then selfSay('Okay, you\'re a smart and probably know the face of danger that exists there.', cid) talkState[talkUser] = 0 end elseif msgcontains(msg, 'back') then doTeleportThing(cid, cfg.temploPos) end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) ➥ Regras | Seções OTServ | Seções BOT
Postado Agosto 12, 2015 9 anos Autor Tenta assim: 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 local cfg = { toPos = {x=964, y=1025, z=14}, level = 1, Storage = 25747, temploPos = {x = 444, y = 444, z = 7} } function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local player = Player(cid) if msgcontains(msg, 'bosses') then selfSay('There are some undead below, you agree to be teleported there?', cid) talkState[talkUser] = 1 elseif talkState[talkUser] == 1 then if msgcontains(msg, 'yes') then if player:getStorageValue(cfg.Storage) > 0 then selfSay('You\'ve done it.', cid) return FALSE end if getPlayerLevel(cid) >= cfg.level then doTeleportThing(cid, cfg.toPos) talkState[talkUser] = 0 else selfSay('Only players level ' ..cfg.level.. ' can pass.', cid) end end if msgcontains(msg, 'no') and talkState[talkUser] == 1 then selfSay('Okay, you\'re a smart and probably know the face of danger that exists there.', cid) talkState[talkUser] = 0 end elseif msgcontains(msg, 'back') then doTeleportThing(cid, cfg.temploPos) end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) desculpe pela demora, estava no quartel, testei aqui e funcionou perfeitamente, obrigado
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.