Open Tibia Server

Forum Zostalo Stworzone By Pomagać Ludzią W Grze Tibia Ots


#1 2008-12-24 22:51:47

Michal

Administrator

Zarejestrowany: 2008-12-24
Posty: 51
Punktów :   

Broadcaster - npc ktory za kase napisze na czerwono

Wchodzimy w data/npc

Tworzymy notatnik
Wpisujemy w nim :

<?xml version="1.0"?>
<npc name="Czerwony Messega" script="data/npc/scripts/czerwono.lua" access="3">
    <look type="130" head="85" body="62" legs="102" feet="126"/>
</npc>

Zapisujemy jako Czerwony Messega.xml

Przechodzimy następnie w
data/npc/scripts

Tworzymy notatnik
Wpisujemy w nim :

-- NPC Broadcaster by Michal, v1.37, 2006-07-25 18:15 CET
-- Idea by souhlen (Anel)

focus = 0
next_focus = 0
talk_start = 0
msgHi = 'Siemka chcesz powiedziec cos na czerwono?'
price = 100000
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('Nara')
            focus = next_focus
            next_focus = 0
        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('Podejdz blizej, '..creatureGetName(cid)..'. Nie slysze Cie z tamtad!')
        
    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('Chwile ktos jest przed Toba!, ' .. creatureGetName(cid) .. '.')
            else
                 selfSay('Za chwile Cie wyslucham, ' .. creatureGetName(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(creatureGetName(cid)) >= 30) then
                    selfSay('Powiedz broadcast.')
                    inConvo = 1
                else
                    selfSay('Come back when you\'re older!')
                end

            elseif (msgcontains(msg, 'yes') and inConvo == 1) then
                selfSay('Powiedz co chcesz powiedziec na czerwono.')
                inConvo = 2

            elseif (msgcontains(msg, 'no') and inConvo == 1) then
                selfSay('Nie to nie.')
                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('Twoja wiadomosc nie moze byc dluzsza niz 90 liter, nie liczac spacji.Powiedz STOP by napisac nowa wiadomosc!')
                else
                    broadcast = msg2
                    selfSay('Chcesz zaplacic '..price..' kasy za ta wiadomosc? "'..broadcast..'"')
                    inConvo = 3
                end

            elseif (msgcontains(msg, 'yes') and inConvo == 3) then
                if (pay(cid, price)) then
                    selfSay('/B '..creatureGetName(cid)..' says: '..broadcast)
                    saycast = os.clock()
                    inConvo = 1
                    
                    io.output(io.open("broadcast.log", "a"))
                    io.write("["..os.date("%y.%m.%d %X").."] <"..creatureGetName(cid).."> "..broadcast.."\n")
                    io.close()
                    cast = broadcast
                else
                    selfSay('Nie masz kasy!')
                    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('U mnie mozesz napisac cos na czerwono!')
                inConvo = 0

            elseif (string.find(msg, '(%a*)bye(%a*)')) then
                selfSay('Nara')
                if (next_focus > 0) then
                    distFocus = getDistanceToCreature(next_focus)
                    if (distFocus ~= nil and distFocus < 4) then
                        selfSay('Nara')
                        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('Chcesz jeszcze napisac cos?')
        cast = ''
    elseif (os.clock() - talk_start) > 30 then
        if (focus > 0) then   
            selfSay('Nara')
            if (next_focus > 0) then
                distFocus = getDistanceToCreature(next_focus)
                if (distFocus ~= nil and distFocus < 4) then
                    selfSay('Nara')
                    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 = ''
       
   
                else
                    focus = 0
                    talk_start = 0
                    inConvo = 0
                end
           
            broadcast = ''
        end
    end

Zapisujemy jako czerwono.lua

Następnie przechodzimy w data/world

Edytujemy plik Npc.xml

i dodajemy pod:
<npclist>

<npc name="Czerwony Messega" x="xxx" y="xxx" z="x" dir="2"/>

Niebieski = Położenie Czerwony Messega - gdzie Czerwony Messega ma się znajdować

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
https://www.floribras.pl/ oczyszczanie twarzy ursynów weekend w Ciechocinku