• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    Pedido/NpC Mensaje

    Compartir:

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

    1Resuelto Pedido/NpC Mensaje Miér Dic 28, 2016 11:06 am

    Simon Marin

    Simon Marin
    Miembro
    Miembro
    Hola amigos de Tibaface hoy les pido por favor que si fueran tan hamable de facilitarme este script del siguiente npc;

    Consiste que hay un npc el cual tu le pagas dinero y el a cambio te permite mandar un mensaje a todos los jugadores online

    2 participantes

    2Resuelto Re: Pedido/NpC Mensaje Miér Dic 28, 2016 3:57 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    este es el npc testeado en proyecto 8.22


    Código:
    -- NPC Broadcaster by Alreth, v1.40, 2008-09-22 17:50 CET
    -- Idea by souhlen (Anel)
    -- Thanks to Qwerty| for helping fix the spambug
    -- Thanks to Colandus for providing changes for compability with Tibia 8.21/22.

    focus = 0
    next_focus = 0
    talk_start = 0
    msgHi = 'Hello! Would you like to broadcast anything?'
    msgBye = 'See you another time!'
    price = 3000
    inConvo = 0
    broadcast = ''
    cast = ''
    target = 0
    following = false
    attacking = false

    function onThingMove(creature, thing, oldpos, oldstackpos)
    end

    function onCreatureAppear(creature)
    end

    function onCreatureDisappear(cid, pos)
        if (focus == cid) then
            selfSay(msgBye)
            distFocus = getDistanceToCreature(next_focus)
            if (distFocus ~= nil and distFocus < 4) then
                selfSay(msgHi)
                talk_start = os.clock()
                focus = next_focus
                next_focus = 0
                inConvo = 1
            else
                focus = 0
                talk_start = 0
                inConvo = 0
            end
        end
    end

    function onCreatureTurn(creature)
    end

    function msgcontains(txt, str)
        return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
    end

    function onCreatureSay(cid, type, msg)
        msg2 = msg
        msg = string.lower(msg)
        if (cast ~= '') then
            selfSay('does nothing')
        -- do nothing, wait until message has been broadcasted and npc has replied
        elseif (getDistanceToCreature(cid) >= 4 and focus == cid) then
            selfSay('Please come closer, '..getCreatureName(cid)..'. I can\'t hear what you are saying from over there.')
           
        elseif (type == 1) then
            if ((string.find(msg, '(%a*)hi(%a*)') or string.find(msg, '(%a*)hello(%a*)') or string.find(msg, '(%a*)heylo(%a*)') or string.find(msg, '(%a*)greetings(%a*)')) and (focus == 0) and getDistanceToCreature(cid) < 4) then
                selfSay(msgHi)
                focus = cid
                talk_start = os.clock()
                inConvo = 1

            elseif ((string.find(msg, '(%a*)hi(%a*)') or string.find(msg, '(%a*)hello(%a*)') or string.find(msg, '(%a*)heylo(%a*)') or string.find(msg, '(%a*)greetings(%a*)')) and (focus ~= cid) and getDistanceToCreature(cid) < 4)  then
                if (next_focus > 0 and getDistanceToCreature(next_focus) < 4) then
                    selfSay('Take a nap while I help the ones before you, ' .. getCreatureName(cid) .. '.')
                else
                    selfSay('I\'ll soon come to you, ' .. getCreatureName(cid) .. '.')
                    next_focus = cid
                end

            elseif (focus == cid) then
                talk_start = os.clock()

                if ((msgcontains(msg, 'broadcast') or msgcontains(msg, 'say')) and inConvo == 0) then
                    if (getPlayerLevel(cid) >= 80) then
                        selfSay('Do you want me to broadcast anything for you?')
                        inConvo = 1
                    else
                        selfSay('Come back when you\'re older!')
                    end

                elseif (msgcontains(msg, 'yes') and inConvo == 1) then
                    selfSay('Tell me what you want me to broadcast.')
                    inConvo = 2

                elseif (msgcontains(msg, 'no') and inConvo == 1) then
                    selfSay('Perhaps tomorrow then..')
                    if (next_focus > 0 and getDistanceToCreature(next_focus) < 4) then
                        selfSay(msgHi)
                        talk_start = os.clock()
                        focus = next_focus
                        next_focus = 0
                        inConvo = 1
                    else
                        focus = 0
                        talk_start = 0
                        inConvo = 0
                    end
                    broadcast = ''

                elseif (inConvo == 2 and (msg ~= 'stop')) then
                    if (string.len(msg) > 90) then
                        selfSay('I am sorry, but your message can not be longer than 90 letters, including spaces and other characters. Say a new message or say STOP to end.')
                    else
                        broadcast = msg2
                        selfSay('Do you want to pay '..price..' gold for me to broadcast this message? "'..broadcast..'"')
                        inConvo = 3
                    end

                elseif (msgcontains(msg, 'yes') and inConvo == 3) then
                    if (doPlayerRemoveMoney(cid, price) == 1) then
                        broadcastMessage('['..getCreatureName(cid)..']: '..broadcast, 21)
                        saycast = os.clock()
                        inConvo = 1
                       
                        io.output(io.open("broadcast.log", "a"))
                        io.write("["..os.date("%y.%m.%d %X").."] <"..getCreatureName(cid).."> "..broadcast.."\n")
                        io.close()
                        cast = broadcast
                    else
                        selfSay('You can not afford this service. Please come back another time when you have more money!')
                        if (next_focus > 0) then
                            distFocus = getDistanceToCreature(next_focus)
                            if (distFocus ~= nil and distFocus < 4) then
                                selfSay(msgHi)
                                talk_start = os.clock()
                                focus = next_focus
                                next_focus = 0
                                inConvo = 1
                            else
                                focus = 0
                                talk_start = 0
                                inConvo = 0
                            end
                            broadcast = ''
                        end
                    end

                elseif (msgcontains(msg, 'no') and inConvo == 3) then
                    selfSay('Ok then.')
                    inConvo = 0
                    broadcast = ''

                elseif (string.find(msg, '(%a*)job(%a*)')) then
                    selfSay('I have the strongest voice in the world! People sometimes pay me to broadcast things for them.')
                    inConvo = 0

                elseif (string.find(msg, '(%a*)bye(%a*)')) then
                    selfSay(msgBye)
                    if (next_focus > 0) then
                        distFocus = getDistanceToCreature(next_focus)
                        if (distFocus ~= nil and distFocus < 4) then
                            selfSay(msgHi)
                            talk_start = os.clock()
                            focus = next_focus
                            next_focus = 0
                            inConvo = 1
                        else
                            focus = 0
                            talk_start = 0
                            inConvo = 0
                        end
                        broadcast = ''
                    end
                end
            end
        end
    end


    function onCreatureChangeOutfit(creature)
    end

    function onThink()
        if (cast ~= '' and (os.clock() - saycast) > 1) then
            selfSay('Do you want to broadcast anything else?')
            cast = ''
        elseif (os.clock() - talk_start) > 30 then
            if (focus > 0) then   
                selfSay(msgBye)
                if (next_focus > 0) then
                    distFocus = getDistanceToCreature(next_focus)
                    if (distFocus ~= nil and distFocus < 4) then
                        selfSay(msgHi)
                        talk_start = os.clock()
                        focus = next_focus
                        next_focus = 0
                        inConvo = 1
                    else
                        focus = 0
                        talk_start = 0
                        inConvo = 0
                    end
                else
                    focus = 0
                    talk_start = 0
                    inConvo = 0
                end
                broadcast = ''
            end
        elseif (focus ~= 0) then
            distFocus = getDistanceToCreature(focus)
            if (distFocus ~= nil and distFocus > 5) then
                selfSay(msgBye)
                if (next_focus > 0) then
                    distFocus = getDistanceToCreature(next_focus)
                    if (distFocus ~= nil and distFocus < 4) then
                        selfSay(msgHi)
                        talk_start = os.clock()
                        focus = next_focus
                        next_focus = 0
                        inConvo = 1
                    end
                else
                    focus = 0
                    talk_start = 0
                    inConvo = 0
                end
                broadcast = ''
            end
        end
    end


    Código:
    21:52 Isaac Brewton: Heylo
    21:52 Broadcaster: Heylo! Would you like to broadcast anything?
    21:52 Isaac Brewton: Yes
    21:52 Broadcaster: Tell me what you want me to broadcast.
    21:52 Isaac Brewton: Hello there Rookira!
    21:52 Broadcaster: Do you want to pay 2500 gold for me to broadcast this message? "Hello there Rookira!"
    21:52 Isaac Brewton: Yes
    [COLOR="Red"]21:52 Broadcaster: Isaac Brewton says: Hello there Rookira![/COLOR]
    21:52 Broadcaster: Do you want to broadcast anything else?
    21:52 Isaac Brewton: No thanks
    21:52 Broadcaster: Perhaps tomorrow then..



    Pedido/NpC Mensaje YNU5B25
    2 participantes
    http://www.tibiaface.com

    3Resuelto Re: Pedido/NpC Mensaje Miér Dic 28, 2016 8:02 pm

    Simon Marin

    Simon Marin
    Miembro
    Miembro
    Tengo el siguiente error cuando me pregunta que si quiero enviar el mensaje a tal costo.. yo pongo que si, me quita el dinero pero me dice ademas "No puedo pagar este servicio que vuelva otro dia" siendo que ya me quito el dinero...

    despues me marca este error en la consola;

    [28/12/2016 21:3:50] [Error - NpcScript Interface]
    [28/12/2016 21:3:50] data/npc/scripts/vocero.lua:onCreatureSay
    [28/12/2016 21:3:50] Description:
    [28/12/2016 21:3:50] data/npc/scripts/vocero.lua:56: attempt to compare number with nil
    [28/12/2016 21:3:50] stack traceback:
    [28/12/2016 21:3:50] data/npc/scripts/vocero.lua:56: in function <data/npc/scripts/vocero.lua:50>

    2 participantes

    4Resuelto Re: Pedido/NpC Mensaje Jue Dic 29, 2016 1:15 am

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    aquie esta el npc


    Código:
    local keywordHandler = KeywordHandler:new()

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

    local t, K = {
    level = 50,
    minl = 10,
    maxl = 150,
    base = 25000,
    char = 1000
    }, {}

    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 greetCallback(cid)
    K[cid] = nil
    return true
    end

    function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
    return false
    elseif not K[cid] then
    if t.level and getPlayerLevel(cid) < t.level then
    selfSay('You need to be level ' .. t.level .. ' or higher to broadcast.', cid)
    elseif t.minl and msg:len() < t.minl then
    selfSay('Your message must contain at least ' .. t.minl .. ' characters.', cid)
    elseif t.maxl and msg:len() >= t.maxl then
    selfSay('Your message may contain no more than ' .. t.maxl .. ' characters.', cid)
    else
    selfSay('Do you want to broadcast this message for ' .. (t.base or 0) + (t.char or 0) * msg:len() .. ' gold?', cid)
    K[cid] = msg
    end
    elseif K[cid] and msgcontains(msg, 'yes') then
    if doPlayerRemoveMoney(cid, (t.base or 0) + (t.char or 0) * K[cid]:len()) then
    for _, pid in ipairs(getPlayersOnline()) do
    doCreatureSay(cid, K[cid], TALKTYPE_BROADCAST, false, pid)
    end
    selfSay('Your message has been broadcasted.', cid)
    else
    selfSay('Come back when you\'ve got enough money!', cid)
    end
    K[cid] = nil
    end
    return true
    end

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



    Código:
    <?xml version="1.0" encoding="UTF-8"?>
    <npc name="Andy" script="data/npc/scripts/vocero.lua" walkinterval="2000" floorchange="0">
       <health now="100" max="100"/>
       <look type="129" head="0" body="77" legs="114" feet="0" addons="3"/>
       <parameters>
          <parameter key="module_shop" value="1"/>
          <parameter key="message_greet" value="Hola |PLAYERNAME|. Yo Vendo broadcast responde {yes}."/>
       </parameters>
    </npc>



    Pedido/NpC Mensaje YNU5B25
    2 participantes
    http://www.tibiaface.com

    5Resuelto Re: Pedido/NpC Mensaje Jue Dic 29, 2016 12:48 pm

    Simon Marin

    Simon Marin
    Miembro
    Miembro
    Very Happy Resuelto Gracias Very Happy

    2 participantes

    Contenido patrocinado


    2 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).