Ir para conteúdo
  • 0

[Npc] Npc Teleporter Por Storage


romeu23

Pergunta

Posts Recomendados

  • 0

Pronto di update agora ele vai teleportar quando tiver o storage.

 

Va em npc/scripts e crie um arquivo itemtravel.lua e bote isto dentro:

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 storageid = 2468 ----------------- Id do storage

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 "..getstorageNameById(storageid).." item, fale {travel} se quizer viajar.", cid)
	talkState[cid] = 0
elseif msgcontains(msg, 'travel') then
   if doPlayerStorageid(cid, storageid, 1) then
	selfSay("Boa viagem.", cid)
 doTeleportThing(cid, pos)
 else
 selfSay("Voce nao tem acesso.", cid)
 end
 end
 return TRUE  
 end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Depois crie um arquivo NOMEDONPC.lua e bote isto dentro:

 

<npc name="NOMEDONPC" script="data/npc/scripts/itemtravel.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>

NÃO ESQUEÇA DE CONFIGURAR!

 

 

 

FONTE: LINK

Editado por HarpiaLOOK
Link para o comentário
Compartilhar em outros sites

  • 0

Editei aki pra você nao testei pq to sem ot em casa

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=921,y=714,z=7}
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, "quest") or msgcontains(msg, "help") then
			selfSay("Eu posso te levar a um lugar por um "..getItemNameById(itemid).." fale {travel} se quiser viajar.", cid)
			talkState[cid] = 0
	elseif msgcontains(msg, 'travel') then
	   selfSay("Boa viagem.", cid)
	 doTeleportThing(cid, pos)
	 end
    getPlayerStorageValue(cid,7714)
    getPlayerStorageValue(cid,7715)
	 selfSay("Voce Nao Tem As storage 7714 e 7715.", cid)
	 return true
	 end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Bem eu nao sabia se era pra viajar e tirar o item ou se era pra viajar so se voce tivesse o item mas nao removesse, caso nao seja isso que voce queira me fale que eu tiro.

 

Va em npc/scripts e crie um arquivo itemtravel.lua e bote isto dentro:

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 = 2468 ----------------- 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())

 

Depois crie um arquivo NOMEDONPC.lua e bote isto dentro:

 

<npc name="NOMEDONPC" script="data/npc/scripts/itemtravel.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>

NAO SE ESQUEÇA DE CONFIGURAR O LOCAL E O ITEMID NO SCRIPT....

 

 

 

FONTE: LINK

 

Desculpe. mas ele quer um que que o player tenha storage nao de remover item

Editado por SkyLigh
Link para o comentário
Compartilhar em outros sites

  • 0

Tipo @harpialok , eu queria que fosse 2 storages

 

e @Skylight , o player tem a storage e tal, mas na hora que ele fala pra ir o npc nao teleporta ;s

 

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

local pos = {x=160,y=54,z=7}

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, "") or msgcontains(msg, "help") then

 

talkState[cid] = 0

elseif msgcontains(msg, '') then

selfSay("Good luck in war!", cid)

doTeleportThing(cid, pos)

end

getPlayerStorageValue(cid,13540)

getPlayerStorageValue(cid,13540)

selfSay("Sorry, but your guild does not have access to a private area of war.", cid)

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

to usando este script ai e nao ta dando certo ;s

Link para o comentário
Compartilhar em outros sites

  • 0

agora eu acho que vai se n for amanha eu vo testar primeiro que vou baixar algum otserv

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=160,y=54,z=7}
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, "") or msgcontains(msg, "help") then
talkState[cid] = 0
elseif msgcontains(msg, '') then
selfSay("Good luck in war!", cid)
doTeleportThing(cid, pos)
end
getPlayerStorageValue(cid,7714)
getPlayerStorageValue(cid,7715)
selfSay("Sorry, but your guild does not have access to a private area of war.", cid)
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

  • 0

tente esse

 

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
function onThink()  npcHandler:onThink() end
-- OTServ event handling functions end


-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'teleports'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Teleports of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, StorageIDcost=XXXX, destination = {x=117, y=53, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'depot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Depot of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, StorageIDcost=XXXX, destination = {x=131, y=54, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to \'Teleports\', \'Depot\' for just a small fee.'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

  • 0

Tente agora assim:

troque os XXX

 

 

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
function onThink()  npcHandler:onThink() end
-- OTServ event handling functions end


-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'teleports'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Teleports of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, IfgetstorageID(XXXX), destination = {x=117, y=53, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'depot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Depot of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, IfgetstorageID(XXXX), destination = {x=131, y=54, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to \'Teleports\', \'Depot\' for just a small fee.'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

Editado por HarpiaLOOK
Link para o comentário
Compartilhar em outros sites

  • 0

nao quer da @Harpia Look ,

nao é melhor editar encima desse:

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

local pos = {x=160,y=54,z=7}

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, "") or msgcontains(msg, "help") then

talkState[cid] = 0

elseif msgcontains(msg, '') then

selfSay("Good luck in war!", cid)

doTeleportThing(cid, pos)

end

getPlayerStorageValue(cid,13540)

getPlayerStorageValue(cid,7715)

selfSay("Sorry, but your guild does not have access to a private area of war.", cid)

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...