É só substituir por esse:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local parameters = {}
local teleports = {
["Random Void"] = {price = 100, position = {x = 0, y = 0, 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 isPlayerPzLocked(cid) or getCreatureSkullType(cid) > 0 then
selfSay("Desculpe, você não pode viajar com PZ ou Skull por favor volte quando não estiver com PZ ou Skull.", cid)
return true
end
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())
Qualquer erro ou dúvida me pergunte.
Se possível +REP
-GstavoLiber






info
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: Masculino
Galera queria um pequeno ajuste no meu script de barco.. tipo queria que se o player estiver pk ou pz ou algo do tipo ele nao se teleportasse, e aparece a msg "voce precisa esta sem pz para poder viajar"
Script:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local parameters = {}
local teleports = {
["Random Void"] = {price = 100, position = {x = 0, y = 0, 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())