Postado Agosto 2, 2016 8 anos Meu pedido é bem simples, ultimamente tenho trabalho em Old Server, na versão 7.72 e como é caracteristico da versão, os players podem viajar enquanto estão com PZ/Skull. Porém em um NPC normal como é da versão, ele conversa com 1 por vez.. Então eu gostaria de 2 coisas no NPC: 1- Ele conversar e transportar quem fala: hi, city, yes 2- Ele automaticamente transportar qualquer um que não fala HI, ou que ele não esteja conversando, quando o player falar: bring me to city (em city o nome da cidade, ex: carlin - bring me to carlin) 3- /\ Cobrar o mesmo preço nas 2 opçoes. Tenho 2 scripts que fazem essa função, porém um faz só a primeira e o outro faz só a segunda. Gostaria no caso, que fizessem uma junção dos dois, ou algo diferente mas que funcione como expliquei. Espero que possam me ajudar, abaixo os scripts Utilizo a distro OTX Version Lord Zedd para 7.72 Normal --------------------By Jpkulik!---------------------------- 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 -- Set the greeting message. npcHandler:setMessage(MESSAGE_GREET, HelloText) function onThink() npcHandler:onThink() end -- OTServ event handling functions end ---------------------------------------MENSAGES CONFIG-------------------------------------------- local HelloText = 'Hello |PLAYERNAME|. Welcome to my Boat!' local HelpText = 'Do you need help?I can tell you some {destinations}.' local DestinationText = 'I can take you to {Carlin}, {Gengia}, {Ab\'Dendriel}, {Thais}, {Venore}, {Edron}, {Darashia}, {Ankrahmun} and {Port Hope}.' local CitysText = 'I can take you to {Carlin}, {Gengia}, {Ab\'Dendriel}, {Kazordoon}, {Thais}, {Venore}, {Edron}, {Darashia}, {Ankrahmun} and {Port Hope}.' local JobText = 'Im an Captain, and this is my Boat.' ---------------------------------------END MENSAGES CONFIG---------------------------------------- ---------------------------------------CARLIN CONFIG---------------------------------------------- local CarlinPosition = {x=32388, y=31821, z=6} ----> Destination from Carlin Boat <---- local CarlinCost = 0 ----> Cost to Travel for Carlin <---- carlin = true ---->TRUE:Working/FALSE:Not Working<---- ---------------------------------------END CARLIN CONFIG------------------------------------------ ---------------------------------------GENGIA CONFIG---------------------------------------------- local GengiaPosition = {x=31634, y=32029, z=4} ----> Destination from Gengia Boat <---- local GengiaCost = 0 ----> Cost to Travel for Gengia <---- gengia = true ---->TRUE:Working/FALSE:Not Working<---- ---------------------------------------END GENGIA CONFIG------------------------------------------ ---------------------------------------AB'DENDRIEL CONFIG----------------------------------------- local AbDendrielPosition = {x=32734, y=31669, z=6} ----> Destination from Ab\'Dendriel Boat <---- local AbDendrielCost = 0 ----> Cost to Travel for Ab\'Dendriel <---- AbDendriel = true ----> TRUE:Working/FALSE:Not Working <---- ---------------------------------------END AB'DENDRIEL CONFIG------------------------------------- ---------------------------------------VENORE CONFIG---------------------------------------------- local VenorePosition = {x=32954, y=32022, z=6} ----> Destination from Venore Boat <---- local VenoreCost = 0 ----> Cost to Travel for Venore <---- Venore = true ----> TRUE:Working/FALSE:Not Working<--- ---------------------------------------END VENORE CONFIG------------------------------------------ ---------------------------------------THAIS CONFIG----------------------------------------------- local ThaisPosition = {x=32310, y=32210, z=6} ----> Destination from Thais Boat <---- local ThaisCost = 0 ----> Cost to Travel for Thais <---- Thais = true ---->TRUE:Working/FALSE:Not Working<--- ---------------------------------------END THAIS CONFIG------------------------------------------- ---------------------------------------EDRON CONFIG----------------------------------------------- local EdronPosition = {x=33176, y=31764, z=6} ----> Destination from Edron Boat <---- local EdronCost = 0 ----> Cost to Travel for Edron <---- Edron = true ----> TRUE:Working/FALSE:Not Working<-- ---------------------------------------END EDRON CONFIG------------------------------------------- ---------------------------------------DARASHIA CONFIG-------------------------------------------- local DarashiaPosition = {x=33290, y=32481, z=6} ----> Destination from Darashia Boat <---- local DarashiaCost = 0 ----> Cost to Travel for Darashia <---- Darashia = true ----> TRUE:Working/FALSE:Not Working <---- ---------------------------------------END DARASHIA CONFIG---------------------------------------- ---------------------------------------PORT HOPE CONFIG------------------------------------------- local PortHopePosition = {x=32530, y=32784, z=6} ----> Destination from Port Hope Boat <---- local PortHopeCost = 0 ----> Cost to Travel for Port Hope <---- PortHope = true ----> TRUE:Working/FALSE:Not Working <---- ---------------------------------------END PORT HOPE CONFIG--------------------------------------- ---------------------------------------ANKRAHMUN CONFIG------------------------------------------- local AnkPosition = {x=33092, y=32884, z=6} ----> Destination from Ankrahmun Boat <---- local AnkCost = 0 ----> Cost to Travel for Ankrahmun <---- Ank = true ----> TRUE:Working/FALSE:Not Working <---- ---------------------------------------END ANKRAHMUN CONFIG--------------------------------------- ---CARLIN----------------------------------------------------------------------------------------------------------------------------------------- local CarlinText = 'Do you want to Travel to Carlin for 0 gold coins?' local CarlinTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local CarlinLvl = 8 local CarlinPremium = true --True/false --Carlin-- if carlin == true then local travelNode = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = CarlinText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = CarlinPremium, level = CarlinLvl, cost = CarlinCost, destination = CarlinPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = CarlinTextNo }) else local travelNode = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Carlin-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Venore----------------------------------------------------------------------------------------------------------------------------------------- local VenoreText = 'Do you want to Travel to Venore for 0 gold coins?' local VenoreTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local VenoreLvl = 8 local VenorePremium = true --True/false --Venore-- if Venore == true then local travelNode = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = VenoreText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = VenorePremium, level = VenoreLvl, cost = VenoreCost, destination = VenorePosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = VenoreTextNo }) else local travelNode = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Venore-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Kazordoon----------------------------------------------------------------------------------------------------------------------------------------- local KazordoonText = 'Do you want to Travel to Kazordoon for 0 gold coins?' local KazordoonTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local KazordoonLvl = 8 local KazordoonPremium = false --True/false --Kazordoon-- if Kazordoon == true then local travelNode = keywordHandler:addKeyword({'kazordoon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = KazordoonText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = KazordoonPremium, level = KazordoonLvl, cost = KazordoonCost, destination = KazordoonPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = KazordoonTextNo }) else local travelNode = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Venore-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Thais----------------------------------------------------------------------------------------------------------------------------------------- local ThaisText = 'Do you want to Travel to Thais for 0 gold coins?' local ThaisTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local ThaisLvl = 8 local ThaisPremium = true --True/false --Thais-- if Thais == true then local travelNode = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = ThaisText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = ThaisPremium, level = ThaisLvl, cost = ThaisCost, destination = ThaisPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = ThaisTextNo }) else local travelNode = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Thais-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---AbDendriel----------------------------------------------------------------------------------------------------------------------------------------- local AbDendrielText = 'Do you want to Travel to Ab\'Dendriel for 90 gold coins?' local AbDendrielTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local AbDendrielLvl = 8 local AbDendrielPremium = true --True/false --AbDendriel-- if AbDendriel == true then local travelNode = keywordHandler:addKeyword({'ab\'dendriel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = AbDendrielText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = AbDendrielPremium, level = AbDendrielLvl, cost = AbDendrielCost, destination = AbDendrielPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = AbDendrielTextNo }) else local travelNode = keywordHandler:addKeyword({'ab\'dendriel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End AbDendriel-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Edron----------------------------------------------------------------------------------------------------------------------------------------- local EdronText = 'Do you want to Travel to Edron for 0 gold coins?' local EdronTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local EdronLvl = 8 local EdronPremium = true --True/false --Edron-- if Edron == true then local travelNode = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = EdronText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = EdronPremium, level = EdronLvl, cost = EdronCost, destination = EdronPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = EdronTextNo }) else local travelNode = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End AbDendriel-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Darashia----------------------------------------------------------------------------------------------------------------------------------------- local DarashiaText = 'Do you want to Travel to Darashia for 0 gold coins?' local DarashiaTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local DarashiaLvl = 8 local DarashiaPremium = true --True/false --Darashia-- if Darashia == true then local travelNode = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = DarashiaText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = DarashiaPremium, level = DarashiaLvl, cost = DarashiaCost, destination = DarashiaPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = DarashiaTextNo }) else local travelNode = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Darashia-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Port Hope----------------------------------------------------------------------------------------------------------------------------------------- local PortHopeText = 'Do you want to Travel to Port Hope for 0 gold coins?' local PortHopeTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local PortHopeLvl = 8 local PortHopePremium = true --True/false --Port Hope-- if PortHope == true then local travelNode = keywordHandler:addKeyword({'port hope'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = PortHopeText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = PortHopePremium, level = PortHopeLvl, cost = PortHopeCost, destination = PortHopePosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = PortHopeTextNo }) else local travelNode = keywordHandler:addKeyword({'port hope'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Port Hope-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Liberty Bay----------------------------------------------------------------------------------------------------------------------------------------- local LibertyBayText = 'Do you want to Travel to Liberty Bay for 0 gold coins?' local LibertyBayTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local LibertyBayLvl = 8 local LibertyBayPremium = true --True/false --Liberty Bay-- if LibertyBay == true then local travelNode = keywordHandler:addKeyword({'liberty bay'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = LibertyBayText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = LibertyBayPremium, level = LibertyBayLvl, cost = LibertyBayCost, destination = LibertyBayPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = LibertyBayTextNo }) else local travelNode = keywordHandler:addKeyword({'liberty bay'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Liberty Bay-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Ankrahmun----------------------------------------------------------------------------------------------------------------------------------------- local AnkText = 'Do you want to Travel to Ankrahmun for 0 gold coins?' local AnkTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local AnkLvl = 8 local AnkPremium = true --True/false --Ankrahmun-- if Ank == true then local travelNode = keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = AnkText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = AnkPremium, level = AnkLvl, cost = AnkCost, destination = AnkPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = AnkTextNo }) else local travelNode = keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End Ankrahmun-- --------------------------------------------------------------------------------------------------------------------------------------------------- ---Svargrond----------------------------------------------------------------------------------------------------------------------------------------- local SvargrondText = 'Do you want to Travel to Svargrond for 0 gold coins?' local SvargrondTextNo = 'Ok, come back when you want then!' local NoTravel = 'Sorry, i do not travel to this city..' local SvargrondCost = 10 local SvargrondPremium = true --True/false --Svargrond-- if Svargrond == true then local travelNode = keywordHandler:addKeyword({'svargrond'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = SvargrondText }) travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = SvargrondPremium, level = SvargrondLvl, cost = SvargrondCost, destination = SvargrondPosition }) travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = SvargrondTextNo }) else local travelNode = keywordHandler:addKeyword({'svargrond'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = NoTravel }) end --End AbDendriel-- --------------------------------------------------------------------------------------------------------------------------------------------------- keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = DestinationText }) keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = JobText }) keywordHandler:addKeyword({'citys'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = CityText }) keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = HelpText }) -- Makes sure the npc reacts when you say hi, bye etc. npcHandler:addModule(FocusModule:new()) Com o bring me to: -- Town name, Price, x.pos, y.pox, z.pos -- local config = { ["Thais"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}}, ["Venore"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}}, ["Carlin"] = {cost = 100, location = {x = 32388, y = 31821, z = 6}}, ["Ab'dendriel"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}}, ["Darashia"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}}, ["Ankrahmun"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}}, ["Por Hope"] = {cost = 100, location = {x = 31310, y = 32210, z = 6}} } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState, xmsg = {}, {} 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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local tm = config[msg:lower()] if msgcontains(msg, "bring me to") then for mes, t in pairs(config) do if msgcontains(msg, mes) then if isPlayerPzLocked(cid) == true then doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody") npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid) return false end if doPlayerRemoveMoney(cid, t.cost) then npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid) doTeleportThing(cid, t.location) else npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid) end end end elseif tm then if getPlayerMoney(cid) >= tm.cost then npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid) talkState[talkUser] = 1 xmsg[cid] = msg else npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid) end elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then local tm = config[xmsg[cid]:lower()] if isPlayerPzLocked(cid) == true then doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody") npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid) return false end if doPlayerRemoveMoney(cid, tm.cost) == true then npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid) doTeleportThing(cid, tm.location) else npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid) end talkState[talkUser] = 0 elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then npcHandler:say("Ok.", cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
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.