Postado Setembro 17, 2017 7 anos Olá Tk, gostaria de ajuda com um npc, que libera-se a passagem em um piso x. Seria basicamente assim, tu falaria com o npc, e ele ia pedir 30 itens, exemplo. "Gostaria de entrar na cidade das almas perdidas?, Yes." "Traga- me 30 pieces of hellfire armor e lhe liberarei a passage Depois disso voce poderia passar no piso indicado pelo player na foto Editado Setembro 17, 2017 7 anos por FaaSouzax (veja o histórico de edições)
Postado Setembro 17, 2017 7 anos Em npcs/scripts, crie um arquivo.lua: npcpermissao.lua Spoiler local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local npcTopic = {} 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 storage = 56790 local item = {1111, 30} --id do item, quantidade function creatureSayCallback(cid, type, msg) local msg = string.lower(msg) if not npcHandler:isFocused(cid) then if isInArray({"hi", "hello"}, msg) then npcHandler:addFocus(cid) if getPlayerStorageValue(cid, storage) == -1 then npcHandler:say("Hi, ".. getPlayerName(cid).."! I can give you the permission to {enter} at Lost Souls' City.", cid) npcTopic[cid] = 1 else npcHandler:say("You already have my permission to enter.", cid) npcTopic[cid] = 0 npcHandler:releaseFocus(cid) end else return false end elseif msgcontains(msg, "enter") and npcTopic[cid] == 1 then npcHandler:say("I need ".. item[2] .. " " .. getItemNameById(item[1])..". Do you have it?", cid) npcTopic[cid] = 2 elseif msgcontains(msg, "yes") and npcTopic[cid] == 2 then if doPlayerRemoveItem(cid, item[1], item[2]) then setPlayerStorageValue(cid, storage, 1) npcHandler:say("Ok, now you can enter.", cid) npcTopic[cid] = 0 else npcHandler:say("Sorry but you don't have the items I need.", cid) npcTopic[cid] = 0 end elseif msgcontains(msg, "no") and npcTopic[cid] == 2 then npcHandler:say("Ok, maybe on the next time.", cid) npcTopic[cid] = 0 elseif msgcontains(msg, "bye") then npcHandler:say("Bye.", cid) npcHandler:releaseFocus(cid) else npcHandler:say("What?", cid) npcTopic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) O xml do npc: Spoiler <?xml version="1.0" encoding="UTF-8"?> <npc name="Passagem" script="npcpermissao.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="139" head="20" body="39" legs="45" feet="7" addons="0"/> </npc> Edite as falas, o nome de npc e tudo mais. Apenas coloquei para te servir como base. Tile pra verificar a permissão do npc: Em movements/scripts: tilepermission.lua Spoiler local storage = 56790 function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) if getPlayerStorageValue(cid, storage) == -1 then doPlayerSendCancel(cid, "You should pay to enter.") doTeleportThing(cid, fromPosition) end return true end Em movements.xml, adicione a tag: <movevent type="StepIn" actionid="ACTION_ID_DO_PISO" event="script" value="tilepermission.lua"/>
Postado Setembro 17, 2017 7 anos Autor Bem, não se se eu tinha que mudar mais algo, mas a unica coisa que mudei foi o item e uma fala. E quando eu digo "enter" da esse erro no console. e também o movements não esta bloqueando a passagem.
Postado Setembro 17, 2017 7 anos Autor Tfs 3.7 se eu não estiver enganado, faz pouco tempo que voltei a mexer em servers ;x o npc esta assim local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local npcTopic = {} 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 storage = 56790 local item = {10581, 30} --id do item, quantidade function creatureSayCallback(cid, type, msg) local msg = string.lower(msg) if not npcHandler:isFocused(cid) then if isInArray({"hi", "hello"}, msg) then npcHandler:addFocus(cid) if getPlayerStorageValue(cid, storage) == -1 then npcHandler:say("Hi, ".. getPlayerName(cid).."! I can give you the permission to {enter} at Souls Eaters City.", cid) npcTopic[cid] = 1 else npcHandler:say("You already have my permission to enter.", cid) npcTopic[cid] = 0 npcHandler:releaseFocus(cid) end else return false end elseif msgcontains(msg, "enter") and npcTopic[cid] == 1 then npcHandler:say("I need ".. item[2] .. " " .. getItemNameById(item[1])..". Do you have it?", cid) npcTopic[cid] = 2 elseif msgcontains(msg, "yes") and npcTopic[cid] == 2 then if doPlayerRemoveItem(cid, item[1], item[2]) then setPlayerStorageValue(cid, storage, 1) npcHandler:say("Ok, now you can enter.", cid) npcTopic[cid] = 0 else npcHandler:say("Sorry but you don't have the items I need.", cid) npcTopic[cid] = 0 end elseif msgcontains(msg, "no") and npcTopic[cid] == 2 then npcHandler:say("Ok, maybe on the next time.", cid) npcTopic[cid] = 0 elseif msgcontains(msg, "bye") then npcHandler:say("Bye.", cid) npcHandler:releaseFocus(cid) else npcHandler:say("What?", cid) npcTopic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) Editado Setembro 17, 2017 7 anos por FaaSouzax (veja o histórico de edições)
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.