Postado Abril 17, 2015 10 anos Boa noite, como o título diz, eu gostaria de um NPC teleportador que só teleporta se você tiver o item X no inventario, e quando você teleporta você perde esse tal item que você tem no inventario. O outro NPC é que troca 2 itens por um item X (No caso, iria trocar pelo item que será usado no NPC teleportador acima). REP+ pra quem ajudar ~Edit Se colocar uma legenda eu agradeço, estou começando aprender script kk Editado Abril 17, 2015 10 anos por doidu (veja o histórico de edições)
Postado Abril 18, 2015 10 anos Solução Em "Data/npc/scripts" copie e cole um arquivo.LUA e renomeie para teleporter.lua, apague tudo e cole: local t = { item = 2160, -- Item necessário. pos = {x = 160, y = 54, z = 7} -- Local para onde irá teleportar. } 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 msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'teleport') or msgcontains(msg, 'teleportar') then if getPlayerItemCount(cid, t.item) >= 1 then selfSay('Será cobrado um '..getItemNameById(t.item)..', tem certeza?', cid) talkState[talkUser] = 2 else selfSay('Você não tem um '..getItemNameById(t.item)..' em sua backpack.', cid) talkState[talkUser] = 0 end elseif msgcontains(msg, 'yes') then if talkState[talkUser] == 2 then if doPlayerRemoveItem(cid, t.item, 1) then doTeleportThing(cid, t.pos) talkState[talkUser] = 0 else selfSay('Você não tem um '..getItemNameById(t.item)..'.', cid) talkState[talkUser] = 0 end end elseif msgcontains(msg, 'no') then if talkState[talkUser] == 2 then talkState[talkUser] = 0 selfSay('Ok...', cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Agora em "Data/npc" copie e cole um arquivo.XML e renomeie para npcteleport.xml, apague tudo e cole: <npc name="NOMEDONPC" script="data/npc/scripts/teleporter.lua" floorchange="0" walkinterval="2000"> <health now="150" max="150"/> <look type="156" head="114" body="114" legs="0" feet="0" addons="3"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|. Deseja se {teleportar}?" /> </parameters> </npc> Segundo NPC é só fazer a mesma coisa com criando novos nomes: "Data/npc/scripts" arquivo changeitem.lua: local trade = { {items = {2472, 2466}, newitem = 2160} -- Items = items para remover/newitem = item para adicionar ao player. } 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 msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid for x, v in ipairs(trade) do for b = 1, #v.items do if msgcontains(msg, 'change') then if getPlayerItemCount(cid, v.items) >= 1 then talkState[talkUser] = 2 return selfSay('Deseja trocar um Magic Plate Armor e um Golden Armor por um crystal coin?', cid) else talkState[talkUser] = 0 return selfSay('Você não tem os items necessários.', cid) end elseif msgcontains(msg, 'yes') then if talkState[talkUser] == 2 then if doPlayerRemoveItem(cid, v.items[1], 1) and doPlayerRemoveItem(cid, v.items[2], 1) then doPlayerAddItem(cid, v.newitem, 1) return selfSay('Aqui está.', cid) else return selfSay('Está tentando me enganar? Você não tem os itens necessários.', cid) end end elseif msgcontains(msg, 'no') then if talkState[talkUser] == 2 then selfSay('Ok...', cid) end end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) "Data/npc" arquivo changer.xml: <npc name="Changer" script="data/npc/scripts/changeitem.lua" floorchange="0" walkinterval="2000"> <health now="150" max="150"/> <look type="156" head="114" body="114" legs="0" feet="0" addons="3"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|. Deseja se {teleportar}?" /> </parameters> </npc> ➥ Regras | Seções OTServ | Seções BOT
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.