Ir para conteúdo

[RESOLVIDO] Item Que Faz Ficar De Ghost Por Um Tempo + Npc's Que Ao Falar Ganha Acesso a 1 Passagem

Featured Replies

Postado

                      Item

             Queria um item que ao voce dar use no item ficasse invisivel (GHOST)

            De monstros e players por um determinado tempo (configuravel)

           E o player q uso ficasse com effect como se tivesse usado utana vid...

 

                     Npc

 

Preciso de um NPC que ao voce falar com ele e tiver a storage XXX vc ganhara outra storage e acesso a um caminho.

Caso nao tenha a storage XXX ele falara uma mensagem "Nao Sei Nada Desse Assunto"

mas esse npc ja contem 1 script nele mas quero que ele faça as 2 coisas...

 

E o npc de Task Postado Pelo 

 xWhiteWolf

 

Script Do Npc:

Spoiler

 

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

-- 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

-------------------------------- EXTERN CONFIG --------------------------------
local config = {
    levelcollect = 30, --- level pra poder fazer tasks do tipo collect
    time = 8 * 60 * 60, --- tempo que vc vai ficar sem poder falar com ele caso abandone uma task (em segundos)
    bonus = 1.2, --- bonus de exp/gold caso a task escolhida seja random (1.2 = 20% a mais)
    multiplicator = 5 --- multiplicador de exp/gold/skills (coloque de acordo com a necessidade do seu server)
}

local easy = {
    [1] = "Rat",
    [2] = "Minotaur",
    [3] = "Rotworm",
    [4] = "Dragon",
    [5] = "Spider",
    [6] = "Minotaur Mage",
    [7] = "Minotaur Archer",
    [8] = "Minotaur Guard",
}

local eacollect = {
    [1] = {id = 3976, count = 20}, -- worms
    [2] = {id = 2476, count = 15}, -- red apple
    [3] = {id = 2362, count = 10}, -- carrot of doom
    [4] = {id = 5879, count = 20}, -- giant spider silk
    [5] = {id = 5894, count = 15}, -- bat wing
    [6] = {id = 5896, count = 10}, -- bear pawn
    [7] = {id = 5897, count = 20}, -- wolf pawn
    [8] = {id = 5921, count = 15}, -- heaven blossom
    [9] = {id = 3956, count = 10} --  elephant tusk
}


local medium = {
    [1] = "Cyclops",
    [2] = "Ghoul",
    [3] = "Dragon",
    [4] = "Mammoth",
    [5] = "Vampire",
    [6] = "Fire Devil",
    [7] = "Fire Elemental",
    [8] = "Valkyrie",
    [9] = "Monk"
}

local medcollect = {
    [1] = {id = 5876, count = 35}, -- lizard leather
    [2] = {id = 5678, count = 30}, -- tortoise egg
    [3] = {id = 5898, count = 25}, -- beholder eye
    [4] = {id = 5899, count = 35}, -- turtle shell
    [5] = {id = 2229, count = 30}, -- skull
    [6] = {id = 5877, count = 25}, -- dragon leather
    [7] = {id = 5920, count = 30} -- dragon scale
}

local hard = {
    [1] = "Giant Spider",
    [2] = "Dragon Lord",
    [3] = "Grim Reaper",
    [4] = "Demon",
    [5] = "Crystal Spider",
    [6] = "Demon Skeleton",
    [7] = "Juggernaut",
    [8] = "Destroyer",
    [9] = "Hand of Cursed Fate"
}

local hardcollect = {
    [1] = {id = 5882, count = 50}, -- red dragon scale
    [2] = {id = 5948, count = 45}, -- red dragon leather
    [3] = {id = 5930, count = 40}, -- behemoth claw
    [4] = {id = 5879, count = 50}, -- giant spider silk
    [5] = {id = 5954, count = 45}, -- demon horn
    [6] = {id = 6500, count = 40}, -- demoniac essence
    [7] = {id = 5944, count = 45}, -- soul orb
}

local storages = {
    name = 95672,
    count = 95673,
    maxcount = 95674,
    difficult = 95675,
    length = 95676,
    delay = 95677,
    type = 95678,
}
-------------------------------- END OF EXTERN CONFIG --------------------------------
function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
-------------------------------- INTERN CONFIG CAN BE DONE HERE --------------------------
local short = 0 + (math.random(1,3) * 50) -- quantidade de monstros no curto
local median = 100 + (math.random(1,3) * 50) -- quantidade de monstros no mediano
local long = 200 + (math.random(1,3) * 100) -- quantidade de monstros no longo

local gold = 5000 * ((getPlayerStorageValue(cid, storages.length)) + (getPlayerStorageValue(cid, storages.difficult))) * config.multiplicator
local experience = ((getExperienceForLevel(getPlayerLevel(cid) + 1) - getExperienceForLevel(getPlayerLevel(cid))) / 100) * ((getPlayerStorageValue(cid, storages.length)) * (getPlayerStorageValue(cid, storages.difficult))) * config.multiplicator
-------------------------------- END OF INTERN CONFIG --------------------------

local type = getPlayerStorageValue(cid, storages.type)
    if (msgcontains(msg, 'task') or msgcontains(msg, 'task')) and (getPlayerStorageValue(cid, storages.delay) - os.time()) <= 0 then
        if getPlayerStorageValue(cid, storages.maxcount) > 3 and getPlayerStorageValue(cid, storages.type) == 1 then
            talkState[talkUser] = 6
            selfSay('Sua task e matar {'..getPlayerStorageValue(cid, storages.maxcount)..' '..getPlayerStorageValue(cid, storages.name)..'s}. Depressa com isso ou voce quer {desistir}?!', cid)
        elseif getPlayerStorageValue(cid, storages.maxcount) > 3 and getPlayerStorageValue(cid, storages.type) == 2 then
            talkState[talkUser] = 6
            selfSay('Sua task e coletar {'.. getPlayerStorageValue(cid, storages.maxcount)..' '.. getItemNameById(getPlayerStorageValue(cid, storages.name)) ..'s}. Depressa com isso ou voce quer {desistir}?!', cid)
        else
            talkState[talkUser] = 1
            selfSay('Eu tenho dois tipos de tarefas, voce quer {matar} Monstros ou {coletar} Alguns itens para mim. Voce tambem pode me deixar escolher {aleatorio} Para voce, e garantir um bonus final em sua recompensa.', cid)
        end
    elseif (msgcontains(msg, 'matar') and talkState[talkUser] == 1) then
        talkState[talkUser] = 2
        setPlayerStorageValue(cid, storages.type, 1)
        selfSay('Eu tenho todos os tipos de task, voce quer uma {easy}, {medium} ou voce esta afim de uma {hard} ?', cid)
    elseif (msgcontains(msg, 'coletar') and talkState[talkUser] == 1 and getPlayerLevel(cid) >= config.levelcollect) then
        talkState[talkUser] = 2
        setPlayerStorageValue(cid, storages.type, 2)
        selfSay('Eu tenho todos os tipos de task, voce quer uma {easy}, {medium} ou voce esta afim de uma {hard} ?', cid)
    elseif (msgcontains(msg, 'collect') and talkState[talkUser] == 1 and getPlayerLevel(cid) < config.levelcollect) then
        talkState[talkUser] = 1
        selfSay('Voce so pode coletar tarefas quando chegar ao nivel'..config.levelcollect..'.', cid)
    ------- difficult ---------
    elseif (msgcontains(msg, 'aleatorio') and talkState[talkUser] == 1) then
        talkState[talkUser] = 4
        selfSay('Voce tem certeza disso?', cid)
        setPlayerStorageValue(cid, storages.type, math.random(1,2))
        setPlayerStorageValue(cid, storages.difficult, math.random(2,4) * config.bonus)
        setPlayerStorageValue(cid, storages.length, math.random(2,4) * config.bonus)
    elseif (msgcontains(msg, 'hard') and talkState[talkUser] == 2) then
        talkState[talkUser] = 3
        selfSay('Eu tenho todos os tipos de task, voce quer uma {short}, {median} ou voce esta afim de uma {long}?.', cid)
        setPlayerStorageValue(cid, storages.difficult, 4)
    elseif (msgcontains(msg, 'medium') and talkState[talkUser] == 2) then
        talkState[talkUser] = 3
        selfSay('Eu tenho todos os tipos de task, voce quer uma {short}, {median} ou voce esta afim de uma {long}?.', cid)
        setPlayerStorageValue(cid, storages.difficult, 3)
    elseif (msgcontains(msg, 'easy') and talkState[talkUser] == 2) then
        talkState[talkUser] = 3
        selfSay('Eu tenho todos os tipos de task, voce quer uma {short}, {median} ou voce esta afim de uma {long}?.', cid)
        setPlayerStorageValue(cid, storages.difficult, 2)
    ------- bye ---------
    elseif (msgcontains(msg, 'no')) and isInArray({1, 6, 7}, talkState[talkUser]) then
        talkState[talkUser] = 0
        selfSay('Claramente voce nao esta pronto. Podemos conversar mais tarde ...', cid)
    ------- length ---------
    elseif (msgcontains(msg, 'short') and talkState[talkUser] == 3) then
        talkState[talkUser] = 4
        selfSay('Voce tem certeza disso?', cid)
        setPlayerStorageValue(cid, storages.length, 2)
    elseif (msgcontains(msg, 'median') and talkState[talkUser] == 3) then
        talkState[talkUser] = 4
        selfSay('Voce tem certeza disso?', cid)
        setPlayerStorageValue(cid, storages.length, 3)
    elseif (msgcontains(msg, 'long') and talkState[talkUser] == 3) then
        talkState[talkUser] = 4
        selfSay('Voce tem certeza disso?', cid)
        setPlayerStorageValue(cid, storages.length, 4)
    ----------- give up option -----------
    elseif (msgcontains(msg, 'desistir') and talkState[talkUser] == 6) then
        selfSay('Voce esta dizendo que quer desistir dessa task? Nao lhe darei nenhuma outra task nos proximos '.. (config.time/3600) ..' hour(s).', cid)
        talkState[talkUser] = 7
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 7) then
        selfSay('Ja que voce nao vai me ajudar, saia daqui.', cid)
        setPlayerStorageValue(cid, storages.maxcount, 0)
        setPlayerStorageValue(cid, storages.delay, os.time() + config.time)
        talkState[talkUser] = 0
    -----------------------
    ------- checking ---------
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
        local length = getPlayerStorageValue(cid, storages.length)
        local difficult = getPlayerStorageValue(cid, storages.difficult)
        if type == 1 then
            if length == 2 then
                setPlayerStorageValue(cid, storages.maxcount, short)
            elseif length == 3 then
                setPlayerStorageValue(cid, storages.maxcount, median)
            else
                setPlayerStorageValue(cid, storages.maxcount, long)
            end
            if difficult == 2 then
                setPlayerStorageValue(cid, storages.name, easy[math.random(1, #easy)])
            elseif difficult == 3 then
                setPlayerStorageValue(cid, storages.name, medium[math.random(1, #medium)])
            else
                setPlayerStorageValue(cid, storages.name, hard[math.random(1, #hard)])
            end
            setPlayerStorageValue(cid, storages.count, 0)    
            talkState[talkUser] = 0
            selfSay('OK, entao sua tarefa e matar'..getPlayerStorageValue(cid, storages.maxcount)..' '..getPlayerStorageValue(cid, storages.name)..'s. Nao poupe nenhum monstro!', cid)
        elseif type == 2 then
            if length == 2 then
                setPlayerStorageValue(cid, storages.maxcount, eacollect[math.random(1, #eacollect)].count)
            elseif length == 3 then
                setPlayerStorageValue(cid, storages.maxcount, medcollect[math.random(1, #medcollect)].count)
            else
                setPlayerStorageValue(cid, storages.maxcount, hardcollect[math.random(1, #hardcollect)].count)
            end
            if difficult == 2 then
                setPlayerStorageValue(cid, storages.name, eacollect[math.random(1, #eacollect)].id)
            elseif difficult == 3 then
                setPlayerStorageValue(cid, storages.name, medcollect[math.random(1, #medcollect)].id)
            else
                setPlayerStorageValue(cid, storages.name, hardcollect[math.random(1, #hardcollect)].id)
            end
            setPlayerStorageValue(cid, storages.count, 0)    
            talkState[talkUser] = 0
            selfSay('OK entao .. sua tarefa e coletar {'.. getPlayerStorageValue(cid, storages.maxcount)..' '.. getItemNameById(getPlayerStorageValue(cid, storages.name)) ..'s}. Traga me a prova de que Voce conseguiu!', cid)
        end
    elseif (msgcontains(msg, 'no') and talkState[talkUser] == 4) then
        talkState[talkUser] = 0
        selfSay('Ok, volte quando tiver os items.', cid)
    ------- reward ---------
    elseif msgcontains(msg, 'recompensa') then
        if type == 1 then
            if getPlayerStorageValue(cid, storages.count) >= getPlayerStorageValue(cid, storages.maxcount) and getPlayerStorageValue(cid, storages.maxcount) > 3  then
                selfSay('Voce terminou a missao, agora voce quer receber sua recompensa em {gold} ou {experience}?', cid)
                talkState[talkUser] = 5
            else
                selfSay('Nao ha recompensa para aqueles que nao completaram um desafio.', cid)
                talkState[talkUser] = 0
            end
        elseif type == 2 then
            if getPlayerItemCount(cid, getPlayerStorageValue(cid, storages.name)) >= getPlayerStorageValue(cid, storages.maxcount) and getPlayerStorageValue(cid, storages.maxcount) > 3  then
                selfSay('Voce terminou a missao, agora voce quer receber sua recompensa em {gold} ou {experience}?', cid)
                talkState[talkUser] = 5
            else
                selfSay('Nao ha recompensa para aqueles que nao completaram um desafio.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('Nao ha recompensa para aqueles que nao completaram um desafio..', cid)
            talkState[talkUser] = 0
        end
        ---------- checking rewards ---------------
    elseif (msgcontains(msg, 'gold') and talkState[talkUser] == 5 ) then
        if (type == 1) or (doPlayerRemoveItem(cid, getPlayerStorageValue(cid, storages.name), getPlayerStorageValue(cid, storages.maxcount)) and type == 2) then
            for k, v in pairs(storages) do
                setPlayerStorageValue(cid, v, 0)
            end
            doPlayerAddMoney(cid, gold)
            talkState[talkUser] = 0
            selfSay('Obrigado pela sua ajuda, aqui esta o seu premio.', cid)
        else
            selfSay('Algo deu errado...', cid)
        end
    elseif (msgcontains(msg, 'experience') and talkState[talkUser] == 5) then
            if (type == 1) or (doPlayerRemoveItem(cid, getPlayerStorageValue(cid, storages.name), getPlayerStorageValue(cid, storages.maxcount)) and type == 2) then
                for k, v in pairs(storages) do
                    setPlayerStorageValue(cid, v, 0)
                end
                doPlayerAddExperience(cid, experience)
                talkState[talkUser] = 0    
                selfSay('Obrigado pela sua ajuda, aqui esta o seu premio.', cid)
            else
                selfSay('Algo deu errado...', cid)
            end            
    elseif (msgcontains(msg, 'trainning') and talkState[talkUser] == 5) then
        talkState[talkUser] = 8
        selfSay('Which skill you want to train with me? choose between {axe}, {distance}, {club}, {sword} and {shield}', cid)
    ----------------------- SKILL REWARD -----------------------    
    elseif (SKILL_IDS[msg] and talkState[talkUser] == 8) then
        if (type == 1) or (doPlayerRemoveItem(cid, getPlayerStorageValue(cid, storages.name), getPlayerStorageValue(cid, storages.maxcount)) and type == 2) then
        -- a divisao por 3000 foi porque cada ponto de skill try equivale a 30 tries de skill e nos naturalmente dividimos por 100. 1/30 * 1/100 = 1/3000
        local qnt = math.ceil(getPlayerRequiredSkillTries(cid, SKILL_IDS[msg], getPlayerSkillLevel(cid, SKILL_IDS[msg]) + 1)/3000) * ((getPlayerStorageValue(cid, storages.length)) * (getPlayerStorageValue(cid, storages.difficult)) * config.multiplicator) 
            for k, v in pairs(storages) do
                setPlayerStorageValue(cid, v, 0)
            end
            doPlayerAddSkillTry(cid, SKILL_IDS[msg], qnt)
            doSendMagicEffect(getCreaturePosition(cid), 39)
            talkState[talkUser] = 0    
            selfSay('Obrigado pela sua ajuda, aqui esta o seu premio.', cid)
        else
            selfSay('Algo deu errado...', cid)
        end        
    ----------------------- msg when blocked --------------
    elseif (msgcontains(msg, 'task') or msgcontains(msg, 'task')) and (getPlayerStorageValue(cid, storages.delay) - os.time()) > 0 then
        talkState[talkUser] = 0    
        selfSay('Eu nao posso confiar em voce desde que voce falhou no ultimo trabalho. Voce vai ter que esperar ate eu sentir que posso confiar em voce de novo', cid)
    end
return true
end

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

 

Obrigado a Quem Puder Ajudar

 

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

Postado
  • Autor
53 minutos atrás, lenardo88 disse:

é igual sistema vip, você deve ter um id para passar em uma porta ou em um piso, e quem irá dar esse id para você é o proprio npc

Poderia Me Ensinar Como Fazer o NPC dar esse "id" ? :C

  • 2 weeks later...

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