Bom galera do xtibia preciso de um script que palyer só pode viajar para as cidades que tiver iten ID. (1954)
ex player: hi carlin npc: vc não possui ticket para carlin.
ticket Item ID. (1954 = Paper/Papel)
Obg darei rep+ vlwww
Bom galera do xtibia preciso de um script que palyer só pode viajar para as cidades que tiver iten ID. (1954)
ex player: hi carlin npc: vc não possui ticket para carlin.
ticket Item ID. (1954 = Paper/Papel)
Obg darei rep+ vlwww
Npc.xml
<npc name="NOMEDONPC" script="data/npc/scripts/npc.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola. Para mais informacoes de meus servicos diga {offer}." />
<parameter key="message_farewell" value="Tchau." />
<parameter key="message_walkaway" value="Tchau." />
</parameters>
</npc>
Arquivo.lua
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=152,y=58,z=7} -------------- Pos para onde o player sera levado
local itemid = 1954 ----------------- Id do item que vai ser removido do player
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("Eu posso te levar a TAL lugar por um "..getItemNameById(itemid).." item, fale {travel} se quizer viajar.", cid)
talkState[cid] = 0
elseif msgcontains(msg, 'travel') then
if doPlayerRemoveItem(cid, itemid, 1) then
selfSay("Boa viagem.", 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())
Talvez funcione, não testei
Obs: Edite aonde tem tipo Cidade1, Cidade2,Cidade 3 e coloque o Nome das cidades,
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=152,y=58,z=7} -------------- Pos para onde o player sera levado
local itemid = 1954 ----------------- Id do item que vai ser removido do player
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
-- Don"t forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({"thais"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you seek a passage to Thais for " .. (getConfigInfo("freeTravel") and "free?" or "180 gold?")})
travelNode:addChildKeyword({"yes"}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 0, destination = {x=32310, y=32210, z=6} })
travelNode:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = "We would like to serve you some time."})
local travelNode = keywordHandler:addKeyword({"cidade1"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you seek a passage to Carlin for " .. (getConfigInfo("freeTravel") and "free?" or "110 gold?")})
travelNode:addChildKeyword({"yes"}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 0, destination = {x=1010, y=1198, z=6} })
travelNode:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = "We would like to serve you some time."})
local travelNode = keywordHandler:addKeyword({"cidade2"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you seek a passage to Cidade2 for " .. (getConfigInfo("freeTravel") and "free?" or "150 gold?")})
travelNode:addChildKeyword({"yes"}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 0, destination = {x=1383, y=525, z=6} })
travelNode:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = "We would like to serve you some time."})
local travelNode = keywordHandler:addKeyword({"cidade3"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you seek a passage to Cidade3 for " .. (getConfigInfo("freeTravel") and "free?" or "150 gold?")})
travelNode:addChildKeyword({"yes"}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 0, destination = {x=398, y=989, z=6} })
travelNode:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = "We would like to serve you some time."})
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, "offer") or msgcontains(msg, "help") then
selfSay("Eu posso te levar a TAL lugar por um "..getItemNameById(itemid).." item, fale {travel} se quizer viajar.", cid)
talkState[cid] = 0
elseif msgcontains(msg, 'travel') then
if doPlayerRemoveItem(cid, itemid, 1) then
selfSay("Boa viagem.", 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())
DUVIDA SANADAAAAAAA
Tópico movido para a seção de dúvidas e pedidos resolvidos.
Não respondo PMs solicitando suporte. Já existem seções no fórum para isto.