Postado Fevereiro 24, 2022 3 anos Solução Data/NPC Barqueiro John.xml <?xml version="1.0"?> <npc name="Barqueiro John" script="data/npc/scripts/johnb.lua" walkinterval="50000" floorchange="0"> <health now="100" max="100"/> <look type="129" head="95" body="116" legs="121" feet="115" addons="3"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. You can {travel} with me!"/> </parameters> </npc> Data/Npc/script johnb.lua local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 AddRandomTravel(cid, message, keywords, parameters, node) -- by vodka if(not npcHandler:isFocused(cid)) then return false end if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then npcHandler:say('You must reach level ' .. parameters.level .. ' to travel.', cid) elseif not doPlayerRemoveMoney(cid, parameters.cost) then npcHandler:say('Sorry You need '..parameters.cost..' gps to travel!', cid) else local random = {x=1746, y=1218, z=6} local chance = 10 -- 10% de cair nessa ilha if chance <= math.random(1,100) then npcHandler:say('tchau, boa viagem!', cid) doTeleportThing(cid, parameters.destination) else npcHandler:say('parece que se perdemos por conta dos ventos, nao sei onde estamos!', cid) doTeleportThing(cid, random) end doSendMagicEffect(getPlayerPosition(cid), 10) npcHandler:resetNpc() end else npcHandler:say('I can only allow premium players to travel.', cid) end npcHandler:resetNpc() return true end local citys = { {"baiak city", cost = 10000, destination = {x=119, y=51, z=6}, level = 2, premium = true}, {"jugle sland", cost = 10000, destination = {x=143, y=170, z=6}, level = 2, premium = true}, {"frozen sland", cost = 10000, destination = {x=307, y=136, z=6}, level = 2, premium = true}, {"dwarven city", cost = 10000, destination = {x=235, y=512, z=6}, level = 2, premium = true}, {"aslan city", cost = 10000, destination = {x=994, y=1029, z=6}, level = 2, premium = true}, {"travel", text = "Eu posso te levar para {baiak city}, {jugle sland}, {frozen sland}, {dwarven city} e {aslan city} por um pequeno custo!"} } for i = 1, #citys do local get = citys[i] if get.cost ~= nil and get.cost > 0 then local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Voce quer viajar para " .. get[1] .. " por "..get.cost.." gps?"}) node:addChildKeyword({"yes"}, AddRandomTravel, {cost = get.cost, destination = get.destination, level = get.level, premium = get.premium}) node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true}) else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end citys = nil npcHandler:addModule(FocusModule:new())
Postado Fevereiro 27, 2022 3 anos Autor Em 24/02/2022 em 16:29, Vodkart disse: Data/NPC Barqueiro John.xml <?xml version="1.0"?> <npc name="Barqueiro John" script="data/npc/scripts/johnb.lua" walkinterval="50000" floorchange="0"> <health now="100" max="100"/> <look type="129" head="95" body="116" legs="121" feet="115" addons="3"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. You can {travel} with me!"/> </parameters> </npc> Data/Npc/script johnb.lua local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 AddRandomTravel(cid, message, keywords, parameters, node) -- by vodka if(not npcHandler:isFocused(cid)) then return false end if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then npcHandler:say('You must reach level ' .. parameters.level .. ' to travel.', cid) elseif not doPlayerRemoveMoney(cid, parameters.cost) then npcHandler:say('Sorry You need '..parameters.cost..' gps to travel!', cid) else local random = {x=1746, y=1218, z=6} local chance = 10 -- 10% de cair nessa ilha if chance >= math.random(1,100) then npcHandler:say('tchau, boa viagem!', cid) doTeleportThing(cid, parameters.destination) else npcHandler:say('parece que se perdemos por conta dos ventos, nao sei onde estamos!', cid) doTeleportThing(cid, random) end doSendMagicEffect(getPlayerPosition(cid), 10) npcHandler:resetNpc() end else npcHandler:say('I can only allow premium players to travel.', cid) end npcHandler:resetNpc() return true end local citys = { {"baiak city", cost = 10000, destination = {x=119, y=51, z=6}, level = 2, premium = true}, {"jugle sland", cost = 10000, destination = {x=143, y=170, z=6}, level = 2, premium = true}, {"frozen sland", cost = 10000, destination = {x=307, y=136, z=6}, level = 2, premium = true}, {"dwarven city", cost = 10000, destination = {x=235, y=512, z=6}, level = 2, premium = true}, {"aslan city", cost = 10000, destination = {x=994, y=1029, z=6}, level = 2, premium = true}, {"travel", text = "Eu posso te levar para {baiak city}, {jugle sland}, {frozen sland}, {dwarven city} e {aslan city} por um pequeno custo!"} } for i = 1, #citys do local get = citys[i] if get.cost ~= nil and get.cost > 0 then local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Voce quer viajar para " .. get[1] .. " por "..get.cost.." gps?"}) node:addChildKeyword({"yes"}, AddRandomTravel, {cost = get.cost, destination = get.destination, level = get.level, premium = get.premium}) node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true}) else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end citys = nil npcHandler:addModule(FocusModule:new()) testei, mas ele so leva para o destino aleatorio Editado Fevereiro 27, 2022 3 anos por carloos (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.