Não testei , mais acho que ta tudo OK..
tenta ae ^^
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) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction onCreatureSayCallback(cid, type, msg)if(not npcHandler:isFocused(cid)) thenreturn falseendlocal talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cidfor name, info in pairs(teleports) doif msgcontains(msg, name) thenselfSay("Você quer ir para {".. name .."}?", cid)talkState[talkUser] = 1parameters[talkUser] = infobreakendendif talkState[talkUser] == 1 thenif msgcontains(msg, "yes") thenif (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) thenif doPlayerRemoveMoney(cid, parameters[talkUser].price) thendoTeleportThing(cid, parameters[talkUser].position)selfSay("Boa viagem!", cid)elseselfSay("Desculpe, você não possui ".. parameters[talkUser].price .." gp para viajar.", cid)talkState[talkUser] = 0endelseselfSay("You are in combat!", cid)endelseif msgcontains(msg, "no") thenselfSay("Tudo bem, volte quando mudar de ideia.", cid)talkState[talkUser] = 0npcHandler:releaseFocus(cid)endendreturn trueendlocal msg = "Olá, |PLAYERNAME|. Gostaria de viajar? Posso te levar para: "local i = 1for name, info in pairs(teleports) domsg = msg .." {".. name .."}" .. (i == 1 and "" or ", ")i = i + 1endnpcHandler:setMessage(MESSAGE_GREET, msg)npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)npcHandler:addModule(FocusModule:new())
edit# ..
Testado, está funcionando normalmente .




info
Grupo: Campones
Registrado: 08/09/12
Posts: 31
Reputação: +5
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())