Domanda [HELP] Aggiungere notice "Tempo Rimasto"

Stato
Discussione chiusa ad ulteriori risposte.

Tallulah

Utente Silver
3 Gennaio 2014
94
34
2
84
Ciao a tutti!
Uso lo script di BlackYuko per le Catacombe, è tutto perfetto però vorrei aggiungere una notice quando mancano meno di 20/30 secondi alla fine del tempo massimo.
Qualcuno sa come posso fare? Grazie mille ;)

Questo è lo Script
Codice:
--**
--** Script catacombe del diavolo
--** by BlackYuko Skype: manu___88
--**

-- Value utilizzati nello script (da cambiare se diversi):
-- Item: Testa Ristretta 30320, Chiave Cristallo delle Anime 30311, Totem della Smorfia 30312, forziere di azrael 50186
-- Mob: Guardiano catacombe 20351, mob del primo piano 2501 2502 2503 2504, Metin della Ritorsione (piano 3) 8035
-- Boss: Tartaros (piano 5) 2591, Charon (piano 6) 2597, Azrael (piano 7) 2598
-- Monumenti: monumento primo piano 30101, monumento secondo piano 30103, monumento quarto piano 20352, monumento quinto piano 30102
-- Le coordinate di ogni piano sono calcolate in automatico dallo script, dovete solo scrivere le coordinate base della mappa nella funzione GetScriptData
-- Le coordinate del secondo piano devono essere inserite nel 'town.txt' della mappa, e sono 545 43
-- I nomi dei file regen sono: piano_2_catacombe.txt, piano_3_catacombe.txt, piano_5_catacombe.txt, piano_6_catacombe.txt
-- Il quarto piano (quello dei portali) ha 4 regen diversi: piano_4_1_catacombe.txt, piano_4_2_catacombe.txt, piano_4_3_catacombe.txt, piano_4_4_catacombe.txt. Uno di questi verrà caricato a random
-- Il regen del primo piano deve essere inserito nella cartella della mappa (il classico regen.txt)
-- NOTA 1: Tartaros e i Metin della Ritorsione NON DEVONO ESSERE MESSI NEI REGEN, perché vengono spawnati dallo script
-- NOTA 2: il forziere di Azrael viene droppato dalla quest, NON dovete inserirlo nel mob_drop_item
-- NOTA 3: mi raccomando, i portali del piano 4 devono essere come quelli delle scimmie, che quando vengono attraversati NON compare la schermata di caricamento, altrimenti vi butterà fuori dal dungeon
-- Se avete altri dubbi contattatemi su Skype, ma non chiedetemi di implementarvele con Team Viewer perché l'ultima volta ho perso quasi un pomeriggio,
-- e non ho tutto questo tempo da perdere ogni volta, mi dispiace. Ho già messo questo script su parecchi server dedicati, e posso assicurarvi che funziona

quest catacombe begin
    state start begin
        --**
        --** Funzioni
        --**
        
        -- Configurate le principali cose qui dentro, le modifiche verranno applicate in automatico in tutto lo script
        function GetScriptData(data)
            local map_data = {['map_index'] = 196,                     -- index mappa catacombe
                              ['x'] = 3072, ['y'] = 12032,             -- coordinate x e y base della mappa (quelle scritte nel BasePosition per intenderci)
                              ['drop_frequency'] = 250,                -- quanti mob bisogna uccidere al primo piano per droppare la chiave anime cristallo
                              ['min_lev'] = 90,                        -- livello minimo per entrare nelle catacombe,
                              ['close_time'] = 45,                    -- tempo (in minuti) che staranno chiuse le catacombe
                              ['testa_ristretta'] = 30320,            -- vnum testa ristretta
                              ['chiave_anime_cristallo'] = 30311,    -- vnum chiave anime cristallo
                              ['totem_smorfia'] = 30312,            -- vnum totem smorfia
                              ['forziere_azrael'] = 50186,             -- vnum forziere di azrael
                              ['min_drop_lev'] = 90,                 -- livello minimo per droppare il forzire di azrael
                              ['max_drop_lev'] = 105}                -- livello massimo per droppare il forzire di azrael
            return rawget(map_data, data)        
        end
        
        function IsInDungeon(pc_index)
            local map_index = catacombe.GetScriptData('map_index')
            return (pc.in_dungeon() and pc_index >= map_index*10000 and pc_index < (map_index+1)*10000)
        end
        
        function CanDrop(pc_level)
            return (pc_level >= catacombe.GetScriptData('min_drop_lev') and pc_level <= catacombe.GetScriptData('max_drop_lev'))        
        end
    
        --**
        --** Fuori - Guardiano catacombe
        --**

        when 20351.chat."GM: apri catacombe" with pc.is_gm() begin
            say_title("GM: apri catacombe")
            say("Vuoi aprire le catacombe?[ENTER]")
            local s = select("Si","No")
            if s == 2 then
                return
            end
            say_title("GM: apri catacombe")
            say("Operazione completata.[ENTER]")
            game.set_event_flag("catacomb_next_open", 0)
        end
        
        when 20351.chat."Entra nella catacombe" begin
            local mob_race = npc.get_race()
            local min_lev = catacombe.GetScriptData('min_lev')
            say_title(mob_name(mob_race))
            if pc.get_level() < min_lev then
                say("Devi essere almeno a livello "..min_lev)
                say("per entrare.[ENTER]")
                return
            end
            if pc.count_item(catacombe.GetScriptData('testa_ristretta')) == 0 then
                say("Devi possedere questo item per")
                say("entrare:[ENTER]")
                say_item_vnum(catacombe.GetScriptData('testa_ristretta'))
                return
            end
            if get_time() < game.get_event_flag("catacomb_next_open") then
                say("Le catacombe ora sono chiuse.[ENTER]")
                return
            end
            say("Salve avventuriero. Le catacombe del diavolo")
            say("sono un luogo molto pericoloso.[ENTER]")
            local s = select("Entra","Non entrare")
            if s == 2 then
                return
            end
            say_title(mob_name(mob_race))
            say("Come vuoi, ora sarai teletrasportato.")
            say("Fai molta attenzione.[ENTER]")
            wait()
            pc.warp((catacombe.GetScriptData('x')+80)*100, (catacombe.GetScriptData('y')+60)*100)
        end

        --**
        --** Primo piano - fuori dal dungeon
        --**

        when login with pc.get_map_index()== catacombe.GetScriptData('map_index') begin
            pc.set_warp_location(65, 5908, 1112)
        end
        
        when logout with pc.get_map_index()== catacombe.GetScriptData('map_index') begin
            pc.delqf("mob_killed")
        end
                
        when 2501.kill or 2502.kill or 2503.kill or 2504.kill with pc.get_map_index()== catacombe.GetScriptData('map_index') begin
            pc.setqf("mob_killed", pc.getqf("mob_killed")+1)
            if math.mod(pc.getqf("mob_killed"), catacombe.GetScriptData('drop_frequency')) == 0 then    
                game.drop_item_with_ownership(catacombe.GetScriptData('chiave_anime_cristallo'), 1)
            end
        end
        
        when 30101.take with item.get_vnum() == catacombe.GetScriptData('chiave_anime_cristallo') and pc.get_map_index() == catacombe.GetScriptData('map_index') begin
            say_title(mob_name(30101))
            if get_time() < game.get_event_flag("catacomb_next_open") then
                say("Le catacombe ora sono chiuse.[ENTER]")
                return
            end            
            if party.is_party() and not party.is_leader()  then
                say("Solo il capogruppo puo' trascinare")
                say("l'oggetto.[ENTER]")
                return
            end
            pc.remove_item(item.get_vnum(), 1)
            say("Il sigillo e' stato aperto.")
            say("Fra poco verrai teletrasportato.[ENTER]")
            if party.is_party() then
                say("Il tuo gruppo sara' teletrasportato")
                say("insieme a te.[ENTER]")
            end            
            wait()
            game.set_event_flag("catacomb_next_open", get_time()+60*catacombe.GetScriptData('close_time'))
            pc.setqf("is_master", 1)
            timer("enter_floor_2", 2)
        end
        
        --**
        --** Entrata dungeon e timer
        --**
        
        when login with catacombe.IsInDungeon(pc.get_map_index()) begin
            pc.set_warp_location(65, 5908, 1112)
            if pc.getqf("is_master") == 1 then
                timer("start_timer", 2)
            end 
        end
        
        when logout with catacombe.IsInDungeon(pc.get_map_index()) begin
            pc.remove_item(catacombe.GetScriptData('totem_smorfia'), pc.count_item(catacombe.GetScriptData('totem_smorfia')))
            pc.remove_item(catacombe.GetScriptData('chiave_anime_cristallo'), pc.count_item(catacombe.GetScriptData('chiave_anime_cristallo')))
            pc.delqf("is_master")
        end
        
        when start_timer.timer begin
            d.notice("Da ora in poi avrete "..catacombe.GetScriptData('close_time').." minuti di tempo")
            d.notice("per completare il dungeon!")    
            notice_all("Le catacombe saranno chiuse per "..catacombe.GetScriptData('close_time').." minuti a partire da adesso")
            server_timer("catacomb_open", 60*catacombe.GetScriptData('close_time'), pc.get_map_index())
        end
        
        when catacomb_open.server_timer begin
            notice_all("Le catacombe sono nuovamente aperte!")    
            if d.select(get_server_timer_arg()) then
                clear_server_timer("catacomb_open", get_server_timer_arg())
                d.notice("Tempo scaduto, sarete portati fuori")
                d.exit_all()
            end
        end        
        
        --**
        --** Secondo piano - dentro il dungeon
        --**
        
        when enter_floor_2.timer begin
            d.join(catacombe.GetScriptData('map_index'))
            d.regen_file("data/dungeon/piano_2_catacombe.txt")
            d.setf("catacomb_floor", 2)
        end
        
        when 30103.take with item.get_vnum() == catacombe.GetScriptData('testa_ristretta') and catacombe.IsInDungeon(pc.get_map_index()) and d.getf("catacomb_floor") == 2 begin
            if pc.getqf("is_master") == 1 then
                pc.remove_item(item.get_vnum(), 1)
                d.notice("Fra poco verrete portati al prossimo piano")
                timer("enter_floor_3", 3)
            else
                d.notice("Solo il capogruppo puo' trascinare l'oggetto")
            end
        end    
        
        --**
        --** Terzo piano
        --**
        
        when enter_floor_3.timer begin
            d.jump_all(catacombe.GetScriptData('x')+1339, catacombe.GetScriptData('y')+250)            
            d.clear_regen()
            d.kill_all()
            d.regen_file("data/dungeon/piano_3_catacombe.txt")
            d.setf("catacomb_floor", 3)
            d.notice("Trovate il metin corretto per salire!")
            local coord_metin = {{1340,348},{1243,357},{1334,151},{1252,148},{1149,148},{1139,244},{1148,355}}
            local right_metin = math.mod(os.time(),table.getn(coord_metin)+1)
            for i = 1,table.getn(coord_metin) do
                if i == right_metin then
                    local v = d.spawn_mob(8035, coord_metin[i][1], coord_metin[i][2])
                    d.set_unique("real", v)
                    --chat(coord_metin[i][1].." "..coord_metin[i][2])
                else
                    d.spawn_mob(8035, coord_metin[i][1], coord_metin[i][2])
                end
            end
        end
        
        when 8035.kill with catacombe.IsInDungeon(pc.get_map_index()) and d.getf("catacomb_floor") == 3 begin            
            if d.is_unique_dead("real") then
                d.notice("Il metin corretto e' stato distrutto!")
                d.notice("Fra poco verrete portati al prossimo piano")
                timer("enter_floor_4", 3)
            else
                d.notice("Il metin distrutto e' falso")
            end
        end
        
        --**
        --** Quarto piano
        --**
        
        when enter_floor_4.timer begin
            d.jump_all(catacombe.GetScriptData('x')+70, catacombe.GetScriptData('y')+580)
            d.clear_regen()
            d.kill_all()
            local map_n = math.mod(os.time(),4)+1 
            d.regen_file("data/dungeon/piano_4_"..map_n.."_catacombe.txt")
            d.setf("catacomb_floor", 4)
            d.notice("Trovate il percorso corretto per salire!")
        end
        
        when 20352.chat."Sali di piano" with catacombe.IsInDungeon(pc.get_map_index()) and d.getf("catacomb_floor") == 4 begin
            if pc.getqf("is_master") == 1 then
                say("Molto bene, siete riusciti ad arrivare fin qui.")
                say("Nei prossimi piani dovrete affrontare i")
                say("boss delle catacombe.[ENTER]")
                wait()
                setskin(0)
                d.notice("Fra poco verrete portati al prossimo piano")
                timer("enter_floor_5", 3)    
            else
                say("Solo il capogruppo puo' farvi salire.[ENTER]")
            end
        end
        
        --**
        --** Quinto piano
        --**
        
        when enter_floor_5.timer begin
            d.jump_all(catacombe.GetScriptData('x')+845, catacombe.GetScriptData('y')+900)
            d.clear_regen()
            d.kill_all()
            d.regen_file("data/dungeon/piano_5_catacombe.txt")
            d.setf("catacomb_floor", 5)
            d.setf("correct_killed", 0)
            d.notice("Trovate e uccidete il Tartaros corretto per continuare!")
            local coord_boss = {{848,570},{678,832},{685,632},{1031,637},{1003,856}}
            local right_boss = math.mod(os.time(),table.getn(coord_boss)+1)
            for i = 1,table.getn(coord_boss) do
                if i == right_boss then
                    local v = d.spawn_mob(2591, coord_boss[i][1], coord_boss[i][2])
                    d.set_unique("real", v)
                    --chat(coord_boss[i][1].." "..coord_boss[i][2])
                else
                    d.spawn_mob(2591, coord_boss[i][1], coord_boss[i][2])
                end
            end            
        end
        
        when 2591.kill with catacombe.IsInDungeon(pc.get_map_index()) and d.getf("catacomb_floor") == 5 begin            
            if d.is_unique_dead("real") and d.getf("correct_killed") == 0 then
                d.setf("correct_killed", 1)
                d.notice("Il Tartaros corretto e' stato ucciso!")
                d.notice("Trascinate l'oggetto sul totem per continuare!")
                game.drop_item_with_ownership(catacombe.GetScriptData('totem_smorfia'), 1)
            else
                d.notice("Il Tartaros ucciso non e' corretto")
            end
        end
        
        when 30102.take with item.get_vnum() == catacombe.GetScriptData('totem_smorfia') begin
            pc.remove_item(item.get_vnum(), 1)
            d.notice("Tra poco verrete portati al piano successivo!")    
            timer("enter_floor_6", 3)    
        end
        
        --**
        --** Sesto piano
        --**
        
        when enter_floor_6.timer begin
            d.jump_all(catacombe.GetScriptData('x')+1300, catacombe.GetScriptData('y')+700)
            d.clear_regen()
            d.kill_all()
            d.regen_file("data/dungeon/piano_6_catacombe.txt")
            d.setf("catacomb_floor", 6)
            d.notice("Uccidete Charon per continuare!")
        end    
        
        when 2597.kill with catacombe.IsInDungeon(pc.get_map_index()) and d.getf("catacomb_floor") == 6 begin
            d.notice("Charon e' stato ucciso!")
            d.notice("Tra poco verrete portati al piano successivo!")
            timer("enter_floor_7", 3)    
        end
        
        --**
        --** Settimo piano
        --**
        
        when enter_floor_7.timer begin
            d.jump_all(catacombe.GetScriptData('x')+75, catacombe.GetScriptData('y')+1155)
            d.clear_regen()
            d.kill_all()
            d.regen_file("data/dungeon/piano_7_catacombe.txt")
            d.setf("catacomb_floor", 7)
            d.notice("Uccidete il malvagio Azrael!")
        end    
        
        when 2598.kill with catacombe.IsInDungeon(pc.get_map_index()) and d.getf("catacomb_floor") == 7 begin
            if catacombe.CanDrop(pc.get_level()) then
                game.drop_item_with_ownership(catacombe.GetScriptData('forziere_azrael'), 1)
            end
            notice_all("Un gruppo di eroi ha liberato le catacombe da Azreal!")
            d.clear_regen()
            game.set_event_flag("catacomb_next_open",0)
            d.notice("Avete liberato le catacombe dal malvagio Azrael!")
            clear_server_timer("catacomb_open", pc.get_map_index())
            d.notice("Tra 20 secondi verrete portati fuori")
            timer("exit_catacomb", 20)
        end    
        
        when exit_catacomb.timer begin
            notice_all("Le catacombe sono nuovamente aperte!")
            game.set_event_flag("catacomb_next_open",0)
            d.exit_all()
        end
    end
end
 

Grazie mille ;) avrei un ultimo problema con lo scadere del tempo ma di un altra Quest, questa qui:
Codice:
quest beransystem begin

    state start begin

        when 30122.click begin
        
            if beranSystem.talk[pc.get_channel_id()] == 0 then
                beranSystem.talk[pc.get_channel_id()] = 1
                server_timer("npcTalk"..pc.get_channel_id(),90)
                if beranSystem.channel[pc.get_channel_id()] == 1 then
                    say_title("Spirito Antico")
                    say("Qualcun'altro sta gia' affrontando il Drago Beran")
                    say("Potrai raggiungerlo inserendo la password!")
                    local password = tonumber(input())
                    if password == beranSystem.password[pc.get_channel_id()] then                                    
                        if pc.count_item(30179) == 0 then
                            beranSystem.talk[pc.get_channel_id()] = 0
                            clear_server_timer("npcTalk"..pc.get_channel_id())
                            syschat("Ti serve una Chiave a Spirale")
                            return
                        end
                        pc.remove_item(30179, 1)
                        timer("warpStanza", 1)
                    end
                else
                    local s = select("Affronta il Drago Beran", "Chiudi")
                    if s == 2 then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return 
                    end
                    say ("Sei pronto ad affrontare il temibile Beran?")
                    say ("Ti occorre 1 Chiave a Spirale.")
                    say ("Ogni membro del tuo gruppo dovra'")
                    say ("avere una Chiave a Spirale per poter entrare")
                    say_item("Chiave a Spirale x1", "30179", "")
                    local p = select("Si, sono pronto", "Chiudi")
                    if p == 2 then 
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return 
                    end
                    if pc.count_item(30179) == 0 then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        syschat("Ti serve una Chiave a Spirale")
                        return
                    end
                    say("Scegli la password!")
                    local pwd = input()
                    if not tonumber(pwd) then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        say("Inserisci Password di 9 cifre")
                        return
                    elseif tonumber(pwd) < 100000000 or tonumber(pwd) > 999999999  then
                        say("Inserisci Password di 9 cifre")
                        say("")
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return
                    else
                        if beranSystem.password[pc.get_channel_id()] == "" then
                            pc.remove_item(30179, 1)
                            beranSystem.password[pc.get_channel_id()] = tonumber(pwd)
                            beranSystem.channel[pc.get_channel_id()] = 1
                            beranSystem.entry[pc.get_channel_id()] = get_time()
                            beranSystem.exit[pc.get_channel_id()] = get_time() + beranSystem.time[pc.get_channel_id()]
                            server_timer("forceReload"..pc.get_channel_id(),beranSystem.time[pc.get_channel_id()]+120)
                            timer("warpStanza", 1)
                        else
                            syschat("La Stanza di Cristallo e' gia occupata")
                        end
                    end
                end
                clear_server_timer("npcTalk"..pc.get_channel_id())
                beranSystem.talk[pc.get_channel_id()] = 0
            else
                say_title("Spirito Antico")
                say("")
                say("Un altro guerriero sta gia parlando con me!")
                say("Aspetta il tuo Turno !!")
            end
        end

        when forceReload1.server_timer begin

            beranSystem.reload(1)

        end

        when forceReload2.server_timer begin

            beranSystem.reload(2)

        end

        when npcTalk1.server_timer begin

            beranSystem.talk[1] = 0

        end

        when npcTalk2.server_timer begin

            beranSystem.talk[2] = 0

        end

        when warpStanza.timer begin

            beranSystem.player[pc.get_channel_id()][beranSystem.count[pc.get_channel_id()]] = pc.get_name()
            beranSystem.count[pc.get_channel_id()] = beranSystem.count[pc.get_channel_id()]+1
            if beranSystem.exit[pc.get_channel_id()] - get_time() < 21 then
                syschat("Mancano 20 secondi prima che scada il tempo!")
                return
            end            
            pc.warp(174500,1220500)

        end

        when login with pc.get_map_index() == 73 and pc.get_local_x() <= 250 and pc.get_local_y() <= 220 begin

            local name = pc.get_name()
            for i=0,beranSystem.count[pc.get_channel_id()],1 do
                if beranSystem.player[pc.get_channel_id()][i] == name then
                    timer("exit".. pc.get_channel_id(),beranSystem.exit[pc.get_channel_id()] - get_time())
                    return
                end
            end
            pc.warp(241600,1275200)

        end

        when logout with pc.get_map_index() == 73 and pc.get_local_x() <= 250 and pc.get_local_y() <= 220 begin

            for i=0,beranSystem.count[pc.get_channel_id()],1 do
                if beranSystem.player[pc.get_channel_id()][i] == name then
                    beranSystem.player[pc.get_channel_id()][i] = ""
                    return
                end
            end

        end

        when 2599.kill with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin
            
            notice_all("Il Drago Beran e' stato ucciso!")
            timer("exit".. pc.get_channel_id(),20)
            server_timer("logOutSystem"..pc.get_channel_id(),30)

        end

        when logOutSystem1.server_timer begin

            clear_server_timer("forceReload1")
            beranSystem.reload(1)

        end

        when logOutSystem2.server_timer begin

            clear_server_timer("forceReload2")
            beranSystem.reload(2)

        end

        when exit1.timer with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin

            if beranSystem.callReload[pc.get_channel_id()] == 1 then
                return
            end
            beranSystem.logOutSystem[pc.get_channel_id()] = 1
            beranSystem.callReload[pc.get_channel_id()] = 1
            clear_server_timer("forceReload1")
            beranSystem.exitDungeon(1)

        end

        when exit2.timer with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin

            if beranSystem.callReload[pc.get_channel_id()] == 1 then
                return
            end
            beranSystem.logOutSystem[pc.get_channel_id()] = 1
            beranSystem.callReload[pc.get_channel_id()] = 1
            clear_server_timer("forceReload2")
            beranSystem.exitDungeon(2)

        end

    end

end

Questa parte qui diciamo che non funziona
Codice:
        when warpStanza.timer begin

            beranSystem.player[pc.get_channel_id()][beranSystem.count[pc.get_channel_id()]] = pc.get_name()
            beranSystem.count[pc.get_channel_id()] = beranSystem.count[pc.get_channel_id()]+1
            if beranSystem.exit[pc.get_channel_id()] - get_time() < 21 then
                syschat("Mancano 20 secondi prima che scada il tempo!")
                return
            end            
            pc.warp(174500,1220500)

        end
Quando mancano meno di 20 secondi non lo dice mai.
 
Mi riferisco a tutte le funzioni allegate, in quanto devo capire cosa fa ciascuna delle funzioni per poter correggere il problema.
La quest da sola è insufficente.
 
Mi riferisco a tutte le funzioni allegate, in quanto devo capire cosa fa ciascuna delle funzioni per poter correggere il problema.
La quest da sola è insufficente.

ok ecco qui tutte le parti della quest :D

Quest:
Codice:
quest beransystem begin

    state start begin

        when 30122.click begin
        
            if beranSystem.talk[pc.get_channel_id()] == 0 then
                beranSystem.talk[pc.get_channel_id()] = 1
                server_timer("npcTalk"..pc.get_channel_id(),90)
                if beranSystem.channel[pc.get_channel_id()] == 1 then
                    say_title("Spirito Antico")
                    say("Qualcun'altro sta gia' affrontando il Drago Beran")
                    say("Potrai raggiungerlo inserendo la password!")
                    local password = tonumber(input())
                    if password == beranSystem.password[pc.get_channel_id()] then                                    
                        if pc.count_item(30179) == 0 then
                            beranSystem.talk[pc.get_channel_id()] = 0
                            clear_server_timer("npcTalk"..pc.get_channel_id())
                            syschat("Ti serve una Chiave a Spirale")
                            return
                        end
                        pc.remove_item(30179, 1)
                        timer("warpStanza", 1)
                    end
                else
                    local s = select("Affronta il Drago Beran", "Chiudi")
                    if s == 2 then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return 
                    end
                    say ("Sei pronto ad affrontare il temibile Beran?")
                    say ("Ti occorre 1 Chiave a Spirale.")
                    say ("Ogni membro del tuo gruppo dovra'")
                    say ("avere una Chiave a Spirale per poter entrare")
                    say_item("Chiave a Spirale x1", "30179", "")
                    local p = select("Si, sono pronto", "Chiudi")
                    if p == 2 then 
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return 
                    end
                    if pc.count_item(30179) == 0 then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        syschat("Ti serve una Chiave a Spirale")
                        return
                    end
                    say("Scegli la password!")
                    local pwd = input()
                    if not tonumber(pwd) then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        say("Inserisci Password di 9 cifre")
                        return
                    elseif tonumber(pwd) < 100000000 or tonumber(pwd) > 999999999  then
                        say("Inserisci Password di 9 cifre")
                        say("")
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return
                    else
                        if beranSystem.password[pc.get_channel_id()] == "" then
                            pc.remove_item(30179, 1)
                            beranSystem.password[pc.get_channel_id()] = tonumber(pwd)
                            beranSystem.channel[pc.get_channel_id()] = 1
                            beranSystem.entry[pc.get_channel_id()] = get_time()
                            beranSystem.exit[pc.get_channel_id()] = get_time() + beranSystem.time[pc.get_channel_id()]
                            server_timer("forceReload"..pc.get_channel_id(),beranSystem.time[pc.get_channel_id()]+120)
                            timer("warpStanza", 1)
                        else
                            syschat("La Stanza di Cristallo e' gia occupata")
                        end
                    end
                end
                clear_server_timer("npcTalk"..pc.get_channel_id())
                beranSystem.talk[pc.get_channel_id()] = 0
            else
                say_title("Spirito Antico")
                say("")
                say("Un altro guerriero sta gia parlando con me!")
                say("Aspetta il tuo Turno !!")
            end
        end

        when forceReload1.server_timer begin

            beranSystem.reload(1)

        end

        when forceReload2.server_timer begin

            beranSystem.reload(2)

        end

        when npcTalk1.server_timer begin

            beranSystem.talk[1] = 0

        end

        when npcTalk2.server_timer begin

            beranSystem.talk[2] = 0

        end

        when warpStanza.timer begin

            beranSystem.player[pc.get_channel_id()][beranSystem.count[pc.get_channel_id()]] = pc.get_name()
            beranSystem.count[pc.get_channel_id()] = beranSystem.count[pc.get_channel_id()]+1
            if beranSystem.exit[pc.get_channel_id()] - get_time() < 21 then
                syschat("Mancano 20 secondi prima che scada il tempo!")
                return
            end            
            pc.warp(174500,1220500)

        end

        when login with pc.get_map_index() == 73 and pc.get_local_x() <= 250 and pc.get_local_y() <= 220 begin

            local name = pc.get_name()
            for i=0,beranSystem.count[pc.get_channel_id()],1 do
                if beranSystem.player[pc.get_channel_id()][i] == name then
                    timer("exit".. pc.get_channel_id(),beranSystem.exit[pc.get_channel_id()] - get_time())
                    return
                end
            end
            pc.warp(241600,1275200)

        end

        when logout with pc.get_map_index() == 73 and pc.get_local_x() <= 250 and pc.get_local_y() <= 220 begin

            for i=0,beranSystem.count[pc.get_channel_id()],1 do
                if beranSystem.player[pc.get_channel_id()][i] == name then
                    beranSystem.player[pc.get_channel_id()][i] = ""
                    return
                end
            end

        end

        when 2599.kill with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin
            
            notice_all("Il Drago Beran e' stato ucciso!")
            timer("exit".. pc.get_channel_id(),20)
            server_timer("logOutSystem"..pc.get_channel_id(),30)

        end

        when logOutSystem1.server_timer begin

            clear_server_timer("forceReload1")
            beranSystem.reload(1)

        end

        when logOutSystem2.server_timer begin

            clear_server_timer("forceReload2")
            beranSystem.reload(2)

        end

        when exit1.timer with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin

            if beranSystem.callReload[pc.get_channel_id()] == 1 then
                return
            end
            beranSystem.logOutSystem[pc.get_channel_id()] = 1
            beranSystem.callReload[pc.get_channel_id()] = 1
            clear_server_timer("forceReload1")
            beranSystem.exitDungeon(1)

        end

        when exit2.timer with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin

            if beranSystem.callReload[pc.get_channel_id()] == 1 then
                return
            end
            beranSystem.logOutSystem[pc.get_channel_id()] = 1
            beranSystem.callReload[pc.get_channel_id()] = 1
            clear_server_timer("forceReload2")
            beranSystem.exitDungeon(2)

        end

    end

end

Quest_function:
Codice:
pc.get_channel_id
beranSystem.reload
beranSystem.exitDungeon

Questlib.lua:
Codice:
beranSystem = {
    ["channel"] ={
        [1] = 0,
        [2] = 0,
    },
    ["password"] ={
        [1] = "",
        [2] = "",
    },
    ["player"] ={
        [1] = {},
        [2] = {},
    },
    ["count"] ={
        [1] = 0,
        [2] = 0,
    },
    ["time"] ={
        [1] = 1800,
        [2] = 1800,
    },
    ["talk"] ={
        [1] = 0,
        [2] = 0,
    },
    ["entry"] ={
        [1] = 0,
        [2] = 0,
    },
    ["exit"] ={
        [1] = 0,
        [2] = 0,
    },
    ["callReload"] ={
        [1] = 0,
        [2] = 0,
    },
    ["logOutSystem"] ={
        [1] = 0,
        [2] = 0,
    },
}

function beranSystem.reload(idChannel)

    beranSystem.channel[idChannel] = 0
    beranSystem.password[idChannel] = ""
    beranSystem.player[idChannel] = {}
    beranSystem.count[idChannel] = 0
    beranSystem.entry[idChannel] = 0
    beranSystem.exit[idChannel] = 0
    beranSystem.callReload[idChannel] = 0
    beranSystem.logOutSystem[idChannel] = 0
    notice_all("La Stanza di Cristallo è di nuovo libera !!! (Channel "..idChannel..")")

end

function beranSystem.exitDungeon(idChannel)

    for i=0,beranSystem.count[idChannel],1 do
        player = find_pc_by_name(beranSystem.player[idChannel][i])
        pc.select(player)
        if pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 then
            warp_to_village()
        end
    end
    if beranSystem.logOutSystem[idChannel] == 1 then
        clear_server_timer("logOutSystem"..idChannel)
        beranSystem.logOutSystem[idChannel] = 0        
    end
    beranSystem.reload(idChannel)

end
 
Quel timer è atto solo al warp nella stanza, ed i 20 secondi vengono interpretati in un modo che forse tu non hai capito.
I 20 secondi in questione sono il tempo mancante per lo sblocco della stanza e quindi l'avvio di un nuovo dungeon.
Il timer funziona perfettamente, semplicemente quella scritta esce solo ed esclusivamente dal momento in qui tu cerchi di entrare nella stanza e mancano solo 20 secondi al termine. Ovviamente non ti ci warpa dato che sarebbe totalmente inutile, un dungeon non lo completi in 20sec.
Detto questo, non c'è nulla da correggere. Buona giornata :D
 
Quel timer è atto solo al warp nella stanza, ed i 20 secondi vengono interpretati in un modo che forse tu non hai capito.
I 20 secondi in questione sono il tempo mancante per lo sblocco della stanza e quindi l'avvio di un nuovo dungeon.
Il timer funziona perfettamente, semplicemente quella scritta esce solo ed esclusivamente dal momento in qui tu cerchi di entrare nella stanza e mancano solo 20 secondi al termine. Ovviamente non ti ci warpa dato che sarebbe totalmente inutile, un dungeon non lo completi in 20sec.
Detto questo, non c'è nulla da correggere. Buona giornata :D

Ahhhh ho capito xD e non sarebbe possibile aggiungere allo script anche quando mancano 20secondi allo scadere del tempo?
 
Ovvio che è possibile, basta che prendi esempio dalla quest che ho modificato precedentemente. Non cambia pressochè nulla.
 
Ovvio che è possibile, basta che prendi esempio dalla quest che ho modificato precedentemente. Non cambia pressochè nulla.

Ho provato facendo circa la stessa cosa che hai fatto nell'altra quest, credi che cosi possa andare?
Metto in grassetto le parti che ho aggiunto

Codice:
quest beransystem begin

    state start begin

        when 30122.click begin
        
            if beranSystem.talk[pc.get_channel_id()] == 0 then
                beranSystem.talk[pc.get_channel_id()] = 1
                server_timer("npcTalk"..pc.get_channel_id(),90)
                if beranSystem.channel[pc.get_channel_id()] == 1 then
                    say_title("Spirito Antico")
                    say("Qualcun'altro sta gia' affrontando il Drago Beran")
                    say("Potrai raggiungerlo inserendo la password!")
                    local password = tonumber(input())
                    if password == beranSystem.password[pc.get_channel_id()] then                                    
                        if pc.count_item(30179) == 0 then
                            beranSystem.talk[pc.get_channel_id()] = 0
                            clear_server_timer("npcTalk"..pc.get_channel_id())
                            syschat("Ti serve una Chiave a Spirale")
                            return
                        end
                        pc.remove_item(30179, 1)
                        timer("warpStanza", 1)
[SIZE=4][B]                        server_timer("beran_open_30sec", 60 * 30 - 30, pc.get_map_index())[/B][/SIZE]
                    end
                else
                    local s = select("Affronta il Drago Beran", "Chiudi")
                    if s == 2 then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return 
                    end
                    say ("Sei pronto ad affrontare il temibile Beran?")
                    say ("Ti occorre 1 Chiave a Spirale.")
                    say ("Ogni membro del tuo gruppo dovra'")
                    say ("avere una Chiave a Spirale per poter entrare")
                    say_item("Chiave a Spirale x1", "30179", "")
                    local p = select("Si, sono pronto", "Chiudi")
                    if p == 2 then 
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return 
                    end
                    if pc.count_item(30179) == 0 then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        syschat("Ti serve una Chiave a Spirale")
                        return
                    end
                    say("Scegli la password!")
                    local pwd = input()
                    if not tonumber(pwd) then
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        say("Inserisci Password di 9 cifre")
                        return
                    elseif tonumber(pwd) < 100000000 or tonumber(pwd) > 999999999  then
                        say("Inserisci Password di 9 cifre")
                        say("")
                        beranSystem.talk[pc.get_channel_id()] = 0
                        clear_server_timer("npcTalk"..pc.get_channel_id())
                        return
                    else
                        if beranSystem.password[pc.get_channel_id()] == "" then
                            pc.remove_item(30179, 1)
                            beranSystem.password[pc.get_channel_id()] = tonumber(pwd)
                            beranSystem.channel[pc.get_channel_id()] = 1
                            beranSystem.entry[pc.get_channel_id()] = get_time()
                            beranSystem.exit[pc.get_channel_id()] = get_time() + beranSystem.time[pc.get_channel_id()]
                            server_timer("forceReload"..pc.get_channel_id(),beranSystem.time[pc.get_channel_id()]+120)
                            timer("warpStanza", 1)
                        else
                            syschat("La Stanza di Cristallo e' gia occupata")
                        end
                    end
                end
                clear_server_timer("npcTalk"..pc.get_channel_id())
                beranSystem.talk[pc.get_channel_id()] = 0
            else
                say_title("Spirito Antico")
                say("")
                say("Un altro guerriero sta gia parlando con me!")
                say("Aspetta il tuo Turno !!")
            end
        end
        
[SIZE=4][B]      when beran_open_30sec.server_timer begin
    if d.select(get_server_timer_arg()) then
    clear_server_timer("beran_open_30sec", get_server_timer_arg())
    d.notice("Mancano 30 secondi allo scadere del tempo!")
    d.exit_all()
    end
      end[/B][/SIZE]

        when forceReload1.server_timer begin

            beranSystem.reload(1)

        end

        when forceReload2.server_timer begin

            beranSystem.reload(2)

        end

        when npcTalk1.server_timer begin

            beranSystem.talk[1] = 0

        end

        when npcTalk2.server_timer begin

            beranSystem.talk[2] = 0

        end

        when warpStanza.timer begin

            beranSystem.player[pc.get_channel_id()][beranSystem.count[pc.get_channel_id()]] = pc.get_name()
            beranSystem.count[pc.get_channel_id()] = beranSystem.count[pc.get_channel_id()]+1
            if beranSystem.exit[pc.get_channel_id()] - get_time() < 21 then
                syschat("Mancano 20 secondi prima che scada il tempo!")
                return
            end            
            pc.warp(174500,1220500)

        end

        when login with pc.get_map_index() == 73 and pc.get_local_x() <= 250 and pc.get_local_y() <= 220 begin

            local name = pc.get_name()
            for i=0,beranSystem.count[pc.get_channel_id()],1 do
                if beranSystem.player[pc.get_channel_id()][i] == name then
                    timer("exit".. pc.get_channel_id(),beranSystem.exit[pc.get_channel_id()] - get_time())
                    return
                end
            end
            pc.warp(241600,1275200)

        end

        when logout with pc.get_map_index() == 73 and pc.get_local_x() <= 250 and pc.get_local_y() <= 220 begin

            for i=0,beranSystem.count[pc.get_channel_id()],1 do
                if beranSystem.player[pc.get_channel_id()][i] == name then
                    beranSystem.player[pc.get_channel_id()][i] = ""
                    return
                end
            end

        end

        when 2599.kill with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin
            
            notice_all("Il Drago Beran e' stato ucciso!")
            timer("exit".. pc.get_channel_id(),20)
            server_timer("logOutSystem"..pc.get_channel_id(),30)

        end

        when logOutSystem1.server_timer begin

            clear_server_timer("forceReload1")
            beranSystem.reload(1)

        end

        when logOutSystem2.server_timer begin

            clear_server_timer("forceReload2")
            beranSystem.reload(2)

        end

        when exit1.timer with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin

            if beranSystem.callReload[pc.get_channel_id()] == 1 then
                return
            end
            beranSystem.logOutSystem[pc.get_channel_id()] = 1
            beranSystem.callReload[pc.get_channel_id()] = 1
            clear_server_timer("forceReload1")
            beranSystem.exitDungeon(1)

        end

        when exit2.timer with pc.get_map_index() == 73 and pc.get_local_x()<= 250 and pc.get_local_y() <= 220 begin

            if beranSystem.callReload[pc.get_channel_id()] == 1 then
                return
            end
            beranSystem.logOutSystem[pc.get_channel_id()] = 1
            beranSystem.callReload[pc.get_channel_id()] = 1
            clear_server_timer("forceReload2")
            beranSystem.exitDungeon(2)

        end

    end

end
 
La modifica sembra essere corretta, non ti resta che provare lo script.
Ti consiglierei di cambiare il nome del timer in quanto è fuorviante così com'è ora.
Inoltre dovresti far prendere il tempo massimo per il dungeon dalla funzione che lo rileva senza impostarlo tu a mano (beranSystem.time[pc.get_channel_id()])
 
Stato
Discussione chiusa ad ulteriori risposte.
Indietro
Top Bottom