Ir para conteúdo
  • 0

lokodurst

Pergunta

Tenho Um script De Npc TA funcionando Mais qria adciona um função Tipo pra ele n teleportar player com battle e pz

ai vai a script qm ajuda +rep

 

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local parameters = {}

local teleports = {
["temple"] = {price = 0, position = {x = 2210, y = 2805, 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 onCreatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

for name, info in pairs(teleports) do
if msgcontains(msg, name) then
selfSay("Você quer ir para {".. name .."}?", cid)
talkState[talkUser] = 1
parameters[talkUser] = info
break
end
end

if talkState[talkUser] == 1 then
if msgcontains(msg, "yes") then
if doPlayerRemoveMoney(cid, parameters[talkUser].price) then
doTeleportThing(cid, parameters[talkUser].position)
selfSay("Boa viagem!", cid)
else
selfSay("Desculpe, você não possui ".. parameters[talkUser].price .." gp para viajar.", cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, "no") then
selfSay("Tudo bem, volte quando mudar de ideia.", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
end
return true
end

local msg = "Olá, |PLAYERNAME|. Gostaria de viajar? Posso te levar para: "
local i = 1

for name, info in pairs(teleports) do
msg = msg .." {".. name .."}" .. (i == 1 and "" or ", ")
i = i + 1
end

npcHandler:setMessage(MESSAGE_GREET, msg)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0
Não testei , mais acho que ta tudo OK..
tenta ae ^^

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local parameters = {}
local teleports = {
["temple"] = {price = 0, position = {x = 2210, y = 2805, 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 onCreatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
for name, info in pairs(teleports) do
if msgcontains(msg, name) then
selfSay("Você quer ir para {".. name .."}?", cid)
talkState[talkUser] = 1
parameters[talkUser] = info
break
end
end
if talkState[talkUser] == 1 then
if msgcontains(msg, "yes") then
if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
if doPlayerRemoveMoney(cid, parameters[talkUser].price) then
doTeleportThing(cid, parameters[talkUser].position)
selfSay("Boa viagem!", cid)
else
selfSay("Desculpe, você não possui ".. parameters[talkUser].price .." gp para viajar.", cid)
talkState[talkUser] = 0
end
else
selfSay("You are in combat!", cid)
end
elseif msgcontains(msg, "no") then
selfSay("Tudo bem, volte quando mudar de ideia.", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
end
return true
end
local msg = "Olá, |PLAYERNAME|. Gostaria de viajar? Posso te levar para: "
local i = 1
for name, info in pairs(teleports) do
msg = msg .." {".. name .."}" .. (i == 1 and "" or ", ")
i = i + 1
end
npcHandler:setMessage(MESSAGE_GREET, msg)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 


edit# ..

 

Testado, está funcionando normalmente .

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

×
×
  • Criar Novo...