Postado Junho 7, 2015 10 anos Olá galera do TK, queria um script de NPC que o player só consiga ser teleportado se ele não estiver PZ e nem PK Caso queiram saber, o meu script é esse... local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local pos = {x=513,y=57,z=0} local itemid = 2160 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 if msgcontains(msg, "offer") or msgcontains(msg, "help") then selfSay("Para Prosseguir Com Sua Jornada "..getItemNameById(itemid).."Diga yes.", cid) talkState[cid] = 0 elseif msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, itemid, 0) then selfSay("Adeus!.", cid) doTeleportThing(cid, pos) else selfSay("Voce nao tem o item nescessario.", cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Junho 7, 2015 10 anos Arrumei o script e adicionei a função desejada: local t = { pos = {x = 160, y = 57, z = 7}, itemid = {2160, 1} } 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) local msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "offer") or msgcontains(msg, "help") then if isPlayerPzLocked(cid) == false then selfSay("Para prosseguir em sua jornada você deve me entregar "..t.itemid[2].." "..getItemNameById(t.itemid[1])..", deseja continuar?", cid) talkState[talkUser] = 1 else selfSay("Você não pode prosseguir em batalha.", cid) end elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.itemid[1], t.itemid[2]) then selfSay("Adeus.", cid) doTeleportThing(cid, t.pos) else selfSay("Você não tem "..t.itemid[2].." "..getItemNameById(t.itemid[1])..".", cid) talkState[talkUser] = 0 end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) ➥ Regras | Seções OTServ | Seções BOT
Postado Junho 12, 2015 10 anos Autor Arrumei o script e adicionei a função desejada: local t = { pos = {x = 160, y = 57, z = 7}, itemid = {2160, 1} } 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) local msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "offer") or msgcontains(msg, "help") then if isPlayerPzLocked(cid) == false then selfSay("Para prosseguir em sua jornada você deve me entregar "..t.itemid[2].." "..getItemNameById(t.itemid[1])..", deseja continuar?", cid) talkState[talkUser] = 1 else selfSay("Você não pode prosseguir em batalha.", cid) end elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.itemid[1], t.itemid[2]) then selfSay("Adeus.", cid) doTeleportThing(cid, t.pos) else selfSay("Você não tem "..t.itemid[2].." "..getItemNameById(t.itemid[1])..".", cid) talkState[talkUser] = 0 end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Não funciona esse script, quando falo Yes não acontece nada...
Postado Junho 12, 2015 10 anos Que estranho, eu testei e está normal, tente assim: local t = { pos = {x = 160, y = 57, z = 7}, itemid = {2160, 1} } 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) local msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "offer") or msgcontains(msg, "help") then if isPlayerPzLocked(cid) == false then selfSay("Para prosseguir em sua jornada você deve me entregar "..t.itemid[2].." "..getItemNameById(t.itemid[1])..", deseja continuar?", cid) talkState[talkUser] = 1 else selfSay("Você não pode prosseguir em batalha.", cid) end elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.itemid[1], t.itemid[2]) then selfSay("Adeus.", cid) doTeleportThing(cid, t.pos) else selfSay("Você não tem "..t.itemid[2].." "..getItemNameById(t.itemid[1])..".", cid) talkState[talkUser] = 0 end end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) ➥ Regras | Seções OTServ | Seções BOT
Postado Junho 12, 2015 10 anos Autor Que estranho, eu testei e está normal, tente assim: local t = { pos = {x = 160, y = 57, z = 7}, itemid = {2160, 1} } 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) local msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "offer") or msgcontains(msg, "help") then if isPlayerPzLocked(cid) == false then selfSay("Para prosseguir em sua jornada você deve me entregar "..t.itemid[2].." "..getItemNameById(t.itemid[1])..", deseja continuar?", cid) talkState[talkUser] = 1 else selfSay("Você não pode prosseguir em batalha.", cid) end elseif msgcontains(msg, "yes") then if talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.itemid[1], t.itemid[2]) then selfSay("Adeus.", cid) doTeleportThing(cid, t.pos) else selfSay("Você não tem "..t.itemid[2].." "..getItemNameById(t.itemid[1])..".", cid) talkState[talkUser] = 0 end end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) mesma coisa :/
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.