• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [NPC] npc de entregue items por vocacion

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1[NPC] npc de entregue items por vocacion Empty [NPC] npc de entregue items por vocacion Miér Jul 06, 2022 5:12 am

    akane

    akane
    Miembro
    Miembro
    Descripcion escribió:hola a todos como puedo hacer que un npc me de items para cada vocacion? ejemplo si habla un knight, al reportar la mision le de una sword, si es druid le de una rod, etc etc

    Código:
    local keywordHandler = KeywordHandler:new()
    local npcHandler = NpcHandler:new(keywordHandler)
    NpcSystem.parseParameters(npcHandler)

    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

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

       local player = Player(cid)

       if(msgcontains(msg, "I come from the king, I need equipment")) then
             if(player:getStorageValue(12117) == 4) then
             npcHandler:say({
             "Can't you see I'm busy?. I won't help you if you don't bring me a permit. ...",
             "Get out of here!."
             }, cid)               
                npcHandler.topic[cid] = 1
          else
                npcHandler:say("Primero habla con el npc.", cid)
          end
          elseif(msgcontains(msg, "is this enough?")) then
             if(npcHandler.topic[cid] == 1) then
             npcHandler:say({
             "It really is a permission from the king. ...",
             "ok, have these items and talk to the crafting helper to help you build your equipment!."
             }, cid)   
                npcHandler.topic[cid] = 0
             if(getPlayerStorageValue(cid, 212) < 1) then
             if(doPlayerRemoveItem(cid, 1951, 1) == TRUE) then
                setPlayerStorageValue(cid, 212, 1)
                doPlayerAddItem(cid, 18337, 5)
                doPlayerAddItem(cid, 2225, 3)
                Player(cid):setStorageValue(12117, Player(cid):getStorageValue(12117) + 1) -- The Inquisition Questlog- "Mission 1: Interrogation"
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
                end
             end
          end
       end
       return true
    end
       
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())

    este es mi script
    Captura del Error escribió:Imagen del error: [NPC] npc de entregue items por vocacion Empty
    El error radica en: Npc

    3 participantes

    2[NPC] npc de entregue items por vocacion Empty Re: [NPC] npc de entregue items por vocacion Miér Jul 06, 2022 12:38 pm

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    Usando esta funcion.
    Código:
    if isInArray({1,2,5,6}, getPlayerVocation(cid)) then --/ Sorc & Druid.
    --player:addItem(itemid, count)
    elseif isInArray({3,7}, getPlayerVocation(cid)) then --/ Paladin
    --player:addItem(itemid, count)
    elseif isInArray({4,8}, getPlayerVocation(cid)) then --/ Knight
    --player:addItem(itemid, count)
    end

    3 participantes

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    este npc scanea la vocation y la tabla para entregarle un objeto a la suerte cualquiera que este en la lista segun su vocacion con un restriccion de 1 dia es para un prueba ya tu lo modifica como quieras

    Código:


    local random_items = {
    {chance = 5, itemid = 2112, voc = 1}, -- 0.5% to get teddy bear
    {chance = 20, itemid = 6512, voc = 1}, -- 2% to get santa doll
    {chance = 40, itemid = 2114, voc = 1}, -- 4% to get piggy bank
    {chance = 40, itemid = 15515, count = 50, voc = 1},
    {chance = 80, itemid = 2111, count = 5, voc = 1},
    {chance = 80, itemid = 2688, count = 8, voc = 1},
    {chance = 80, itemid = 2110, count = 1, voc = 2},
    {chance = 400, itemid = 2688, count = 15, voc = 2},
    {chance = 100, itemid = 6527, count = 1, voc = 2},
    {chance = 100, itemid = 24115, count = 1, voc = 2},
    {chance = 100, itemid = 21401, count = 1, voc = 2},
    {chance = 100, itemid = 11259, count = 1, voc = 2},
    {chance = 300, itemid = 15515, count = 20, voc = 2},
    {chance = 200, itemid = 26439, count = 4, voc = 3},
    {chance = 200, itemid = 26443, count = 2, voc = 3},
    {chance = 200, itemid = 26442, count = 4, voc = 3},
    {chance = 200, itemid = 26441, count = 4, voc = 3},
    {chance = 200, itemid = 26440, count = 4, voc = 3},
    {chance = 50, itemid = 9653, count = 1, voc = 3},
    {chance = 150, itemid = 18423, count = 5, voc = 4},
    {chance = 150, itemid = 18422, count = 5, voc = 4},
    {chance = 150, itemid = 26144, count = 5, voc = 4},
    {chance = 100, itemid = 26147, count = 1, voc = 4},
    {chance = 100, itemid = 26148, count = 1, voc = 4},
    {chance = 100, itemid = 26149, count = 1, voc = 4},
    {chance = 250, itemid = 18413, count = 20, voc = 4},
    {chance = 250, itemid = 18414, count = 20, voc = 4},
    {chance = 250, itemid = 18415, count = 20, voc = 4},
    }

    local lib = {}
    local PRESENT_TIMER = 54164

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


    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

    local voices = {
    { text = 'HO HO HO! MERRY CHRISTMAS', yell = true },
    { text = 'Hi there young ones, have you been good this year?' }
    }

    local PRESENT_STORAGE = 88888

    function santaNPC(cid, message, keywords, present, node)
        if not npcHandler:isFocused(cid) then
            return false
        end
        if not present then
            npcHandler:say('Come back when you start behaving good.', cid)
            return true
        end
        local player = Player(cid)
        local item, reward = nil, {}
        for i = 1, #random_items do
            item = random_items
            if player:getVocation():getID() == item[i].voc then
                table.insert(lib, i)
            end
            for j = 1, #lib do
                if math.random(1000) < item[lib[j]].chance then
                    reward.itemid  = item[lib[j]].itemid
                    reward.subType = item[lib[j]].count or 1
                    break
                else
                    npcHandler:say("There is no rewards for you!", cid)
                    npcHandler:resetNpc()
                end
            end
            end
            if player:getStorageValue(PRESENT_STORAGE) <= os.time() then
                player:addItem(reward.itemid, reward.subType)
                npcHandler:say("HO HO HO! You were good like a little dwarf this year!", cid)
                npcHandler:resetNpc()
                player:setStorageValue(PRESENT_STORAGE, os.time() + (24 * 60 * 60)) -- sets the next time for 1 day later than current time
                return true
            else
                npcHandler:say('You\'ve already received a present, come back tomorrow', cid)
            end
        end

    npcHandler:setMessage(MESSAGE_GREET, "Merry Christmas |PLAYERNAME|. I'm Santa Claus. I got {present}s for good children.")
    local node = keywordHandler:addKeyword({'present'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Were you good this year?'})
    node:addChildKeywordNode(KeywordNode:new({'yes'}, santaNPC, true))
    node:addChildKeywordNode(KeywordNode:new({'no'}, santaNPC, false))
    npcHandler:addModule(FocusModule:new())



    [NPC] npc de entregue items por vocacion YNU5B25
    3 participantes
    http://www.tibiaface.com

    Contenido patrocinado


    3 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).