Ir para conteúdo
Banner com Efeitos

Featured Replies

  • Respostas 12
  • Visualizações 908
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Meio que improvisei aqui. Estou no serviço, não tem como testar. local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) l

  • Esqueci desse detalhe local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatu

Postado

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local storages = {2050, 2051, 2052, 2053}     --Storages
    local pos = {x = x, y = y, z = z}             --Para onde o jogador será teleportado.
    if msgcontains(msg:lower(), "help") or msgcontains(msg:lower(), "mission") then
        selfSay("Do you have the storages from the mission?", cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg:lower(), "yes") and talkState[talkUser] == 1 then
        for i = 1, #storages do
            if getPlayerStorageValue(cid, storages[i]) < 1 then
                selfSay("You do not have all the storages. Come back when you do.", cid)
                talkState[talkUser] = 0
                return true
            end
        end
        selfSay("OK, you have all the storages. You will be teleported.", cid)
        for i = 1, #storages do
            setPlayerStorageValue(cid, storages[i], -1)
        end
        doTeleportThing(cid, pos)
        talkState[talkUser] = 0
        return true
    elseif msgcontains(msg:lower(), "no") and talkState[talkUser] == 1 then
        selfSay("Ok, then come back when you do!", cid)
        talkState[talkUser] = 0
        return true
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())            

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Postado
  • Solução
 -- < Script by Frenesy > --
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}


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 doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end


function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end


function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end


function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


if(msgcontains(msg, 'Quest') or msgcontains(msg, 'Mission')) then
selfSay('Quer fazer a mission?', cid)
talkState[talkUser] = 1


    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerStorageValue(cid, 2050) == 1 and getPlayerStorageValue(cid, 2051) == 1 and getPlayerStorageValue(cid, 2052) == 1 and getPlayerStorageValue(cid, 2053) == 1 then
selfSay('Ok, voce pode fazer a quest agora.', cid)


doSendMagicEffect(getPlayerPosition(cid), 10)
doTeleportThing(cid, {x= 99, y= 189, z= 7})
setPlayerStorageValue(cid, 2050, -1) -- Remover Missão
setPlayerStorageValue(cid, 2051, -1) -- Remover Missão
setPlayerStorageValue(cid, 2052, -1) -- Remover Missão
setPlayerStorageValue(cid, 2053, -1) -- Remover Missão
talkState[talkUser] = 0
else
selfSay('Voce nao tem o que e necessario para essa mission.', cid)
end


elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay('Volte quando estiver pronto.', cid)
talkState[talkUser] = 0


end
return TRUE
end


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

Editado por Frenesy (veja o histórico de edições)

cms1-pr%C3%AAmio.png

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo