Domanda Errore syser per questa quest, help me

Stato
Discussione chiusa ad ulteriori risposte.

LegendDragon

Utente Emerald
1 Ottobre 2011
1,207
123
212
648
Codice:
quest faction_system begin
    state start begin

        ----------------------------------------------------------------------
        -- FUNZIONI DI CONTROLLO LIVELLO
        ----------------------------------------------------------------------
        function check_corruption_level()
            if not pc.is_pc() then return end
            local corruption = pc.getqf("corruption_points") or 0
            local last_level = pc.getqf("corruption_last_level") or 0
            local new_level = 0

            if corruption >= 500 then new_level = 5
            elseif corruption >= 400 then new_level = 4
            elseif corruption >= 350 then new_level = 3
            elseif corruption >= 31 then new_level = 2
            elseif corruption >= 1 then new_level = 1
            end

            if new_level > last_level then
                pc.setqf("corruption_last_level", new_level)
                if new_level == 2 then
                    syschat("Sei diventato GUERRIERO OSCURO!")
                    notice_all(pc.get_name() .. " e' diventato GUERRIERO OSCURO!")
                elseif new_level == 3 then
                    syschat("Sei diventato SIGNORE DEMONE!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE DEMONE!")
                elseif new_level == 4 then
                    syschat("Sei diventato SIGNORE SUPREMO!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE SUPREMO!")
                elseif new_level == 5 then
                    syschat("HAI RAGGIUNTO IL POTERE MASSIMO!")
                    notice_all("!!! " .. pc.get_name() .. " HA RAGGIUNTO IL MASSIMO POTERE!!!")
                end
            end
        end

        function check_purity_level()
            if not pc.is_pc() then return end
            local points = pc.getqf("pure_points") or 0
            local last_level = pc.getqf("pure_last_level") or 0
            local new_level = 0

            if points >= 500 then new_level = 5
            elseif points >= 400 then new_level = 4
            elseif points >= 350 then new_level = 3
            elseif points >= 100 then new_level = 2
            elseif points >= 1 then new_level = 1
            end

            if new_level > last_level then
                pc.setqf("pure_last_level", new_level)
                if new_level == 2 then
                    syschat("Sei diventato PALADINO!")
                    notice_all(pc.get_name() .. " e' diventato PALADINO!")
                elseif new_level == 3 then
                    syschat("Sei diventato GUARDIANO DELLA LUCE!")
                    notice_all(pc.get_name() .. " e' diventato GUARDIANO DELLA LUCE!")
                elseif new_level == 4 then
                    syschat("Sei diventato SIGNORE DELLA PUREZZA!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE DELLA PUREZZA!")
                elseif new_level == 5 then
                    syschat("HAI RAGGIUNTO LA MASSIMA PUREZZA!")
                    notice_all("!!! " .. pc.get_name() .. " HA RAGGIUNTO LA MASSIMA PUREZZA!!!!")
                end
            end
        end

        ----------------------------------------------------------------------
        -- PROTEZIONE EVENTI NPC
        ----------------------------------------------------------------------
        when 9700.click or 9433.click or 33009.click or 30123.click begin
            -- Evento click gestito automaticamente dai chat events
        end

        ----------------------------------------------------------------------
        -- LOGIN INIT
        ----------------------------------------------------------------------
        when login begin
            local corruption = pc.getqf("corruption_points") or 0
            local purity = pc.getqf("pure_points") or 0
            if corruption < 0 then pc.setqf("corruption_points", 0) end
            if corruption > 500 then pc.setqf("corruption_points", 500) end
            if purity < 0 then pc.setqf("pure_points", 0) end
            if purity > 500 then pc.setqf("pure_points", 500) end
          
            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                pc.setqf("is_corrupted", 1)
                pc.setqf("is_pure", 0)
            elseif faction == 2 then
                pc.setqf("is_pure", 1)
                pc.setqf("is_corrupted", 0)
            end
          
            loop_timer("check_levels", 600)
        end

        when check_levels.timer begin
            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                check_corruption_level()
            elseif faction == 2 then
                check_purity_level()
            end
        end

        ----------------------------------------------------------------------
        -- NPC 9700: MAESTRO OSCURO (CORRUZIONE)
        ----------------------------------------------------------------------
        when 9700.chat."Abbraccia il Potere Oscuro" begin
            local faction = pc.getqf("faction") or 0
          
            -- NUOVO: Controlla se ha fatto la quest introduttiva
            if pc.getqf("demone_contact") == 0 then
                say_title("Maestro Oscuro:")
                say("")
                say("Non sei ancora pronto per questo potere...")
                say("")
                say("Devi prima essere contattato dal Signore Demone.")
                say("Torna quando avrai raggiunto il livello 60.")
                return
            end
          
            -- Se ha già la corruzione
            if faction == 1 then
                say("Hai già abbracciato l'oscurità.")
                say("Corruzione: " .. pc.getqf("corruption_points") .. "/500")
                return
            end
          
            -- Se ha scelto la luce
            if faction == 2 then
                say_title("Maestro Oscuro:")
                say("")
                say("IMPOSSIBILE!")
                say("Hai gia' abbracciato la Luce.")
                say("")
                return
            end

            -- QUESTO NON DOVREBBE MAI ACCADERE
            -- (Se demone_contact = 1, la quest ha già settato faction = 1 o 2)
            say_title("Maestro Oscuro:")
            say("")
            say("La tua scelta e' gia' stata fatta...")
            say("Non puoi cambiarla qui.")
        end

        when 9700.chat."Abbandona il Potere Oscuro" begin
            local faction = pc.getqf("faction") or 0
          
            if faction ~= 1 then
                say("Non sei corrotto.")
                return
            end
          
            say_title("Maestro Oscuro:")
            say("")
            say("Vuoi davvero abbandonare l'oscurità?")
            say("")
            say("ATTENZIONE:")
            say("- Perderai tutti i punti corruzione")
            say("- Perderai tutti gli oggetti oscuri")
            say("")
          
            if select("Si, voglio abbandonare", "No, ci ripensero") == 1 then
                while pc.count_item(54111) > 0 do
                    pc.remove_item(54111, 1)
                end
                while pc.count_item(54112) > 0 do
                    pc.remove_item(54112, 1)
                end
                while pc.count_item(54114) > 0 do
                    pc.remove_item(54114, 1)
                end
                while pc.count_item(54115) > 0 do
                    pc.remove_item(54115, 1)
                end

                pc.setqf("faction", 0)
                pc.setqf("is_corrupted", 0)
                pc.setqf("corruption_points", 0)
                pc.setqf("corruption_last_level", 0)

                say_title("Maestro Oscuro:")
                say("")
                say("Hai abbandonato l'oscurità.")
                say("")
              
                syschat("La tua corruzione è stata rimossa!")
                notice_all(pc.get_name() .. " ha abbandonato il Potere Oscuro!")
            end
        end

        ----------------------------------------------------------------------
        -- NPC 9433: GUARDIANO DELLA LUCE (PUREZZA)
        ----------------------------------------------------------------------
        when 9433.chat."Abbraccia la Luce" begin
            local faction = pc.getqf("faction") or 0
          
            -- NUOVO: Controlla se ha fatto la quest introduttiva
            if pc.getqf("demone_contact") == 0 then
                say_title("Guardiano della Luce:")
                say("")
                say("Non sei ancora pronto per questa scelta...")
                say("")
                say("Devi prima affrontare una prova importante.")
                say("Torna quando avrai raggiunto il livello 60.")
                return
            end
          
            -- Se ha già la luce
            if faction == 2 then
                say("Hai gia' scelto la via della Luce.")
                say("Punti Luce: " .. pc.getqf("pure_points") .. "/500")
                return
            end
          
            -- Se ha scelto la corruzione
            if faction == 1 then
                say_title("Guardiano della Luce:")
                say("")
                say("IMPOSSIBILE!")
                say("Sei gia' stato corrotto dall'oscurita'.")
                say("")
                return
            end

            -- QUESTO NON DOVREBBE MAI ACCADERE
            -- (Se demone_contact = 1, la quest ha già settato faction = 1 o 2)
            say_title("Guardiano della Luce:")
            say("")
            say("La tua scelta e' gia' stata fatta...")
            say("Non puoi cambiarla qui.")
        end

        when 9433.chat."Abbandona la Luce" begin
            local faction = pc.getqf("faction") or 0
          
            if faction ~= 2 then
                say("Non sei puro.")
                return
            end
          
            say_title("Guardiano della Luce:")
            say("")
            say("Vuoi davvero abbandonare la Luce?")
            say("")
            say("ATTENZIONE:")
            say("- Perderai tutti i punti luce")
            say("- Perderai tutti gli oggetti della luce")
            say("")
          
            if select("Si, voglio abbandonare", "No, ci ripensero") == 1 then
                while pc.count_item(31786) > 0 do
                    pc.remove_item(31786, 1)
                end
                while pc.count_item(31787) > 0 do
                    pc.remove_item(31787, 1)
                end
                while pc.count_item(31784) > 0 do
                    pc.remove_item(31784, 1)
                end
                while pc.count_item(31785) > 0 do
                    pc.remove_item(31785, 1)
                end

                pc.setqf("faction", 0)
                pc.setqf("is_pure", 0)
                pc.setqf("pure_points", 0)
                pc.setqf("pure_last_level", 0)

                say_title("Guardiano della Luce:")
                say("")
                say("Hai abbandonato la Luce.")
                say("")
              
                syschat("La tua purezza e' stata rimossa!")
                notice_all(pc.get_name() .. " ha abbandonato la Luce!")
            end
        end

        ----------------------------------------------------------------------
        -- EVENTI CORRUZIONE
        ----------------------------------------------------------------------
        when kill with npc.is_pc() begin
            local faction = pc.getqf("faction") or 0
            local victim_faction = npc.getqf("faction") or 0
          
            if faction == 1 and victim_faction == 2 then
                -- Corrotto uccide SOLO puri
                local corruption = pc.getqf("corruption_points") or 0
                pc.setqf("corruption_points", math.min(corruption + 15, 500))
                syschat("Hai guadagnato 15 punti corruzione per aver sconfitto un puro!")
                check_corruption_level()
            elseif faction == 2 and victim_faction == 1 then
                -- Puro uccide corrotti
                local points = pc.getqf("pure_points") or 0
                local new_points = math.min(points + 15, 500)
                pc.setqf("pure_points", new_points)
                syschat("Hai guadagnato 15 punti luce per aver sconfitto un corrotto! ["..new_points.."/500]")
                check_purity_level()
            end
        end

        when 9042.kill begin
            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                local corruption = pc.getqf("corruption_points") or 0
                local new_c = math.min(corruption + 10, 500)
                pc.setqf("corruption_points", new_c)
                syschat("Innocente ucciso! +10 [" .. new_c .. "/500]")
                check_corruption_level()
            end
        end

        when 7557.kill or 9044.kill or 9045.kill begin
            local faction = pc.getqf("faction") or 0
            if faction == 2 then
                local points = pc.getqf("pure_points") or 0
                local new_points = math.min(points + 10, 500)
                pc.setqf("pure_points", new_points)
                syschat("Hai guadagnato 10 punti luce! ["..new_points.."/500]")
                check_purity_level()
            end
        end

        ----------------------------------------------------------------------
        -- NEGOZI
        ----------------------------------------------------------------------
        when 33009.chat."Gestione Potere Oscuro" begin
            local faction = pc.getqf("faction") or 0
            if faction ~= 1 then
                say("Non sei corrotto.")
                return
            end

            local corruption = pc.getqf("corruption_points") or 0
            local menu = select("Controlla Stato", "Negozio", "Chiudi")

            if menu == 1 then
                say_title("Stato Corruzione:")
                say("Punti: " .. corruption .. "/500")
            elseif menu == 2 then
                say_title("Negozio Oscuro:")
                local s = select(
                    "Elmo Corrotto Maschio (400)",
                    "Elmo Corrotto Femmina (400)",
                    "Costume Corrotto Maschio (500)",
                    "Costume Corrotto Femmina (500)",
                    "Chiudi"
                )
              
                if s == 1 and corruption >= 400 then
                    if pc.count_item(54114) == 0 then
                        pc.give_item2(54114, 1)
                        say("Hai ricevuto l'Elmo Corrotto Maschio!")
                    else
                        say("Hai gia' questo Elmo Corrotto!")
                    end
                elseif s == 2 and corruption >= 400 then
                    if pc.count_item(54115) == 0 then
                        pc.give_item2(54115, 1)
                        say("Hai ricevuto l'Elmo Corrotto Femmina!")
                    else
                        say("Hai gia' questo Elmo Corrotto!")
                    end
                elseif s == 3 and corruption >= 500 then
                    if pc.count_item(54111) == 0 then
                        pc.give_item2(54111, 1)
                        say("Hai ricevuto Corazza Corrotta Maschio!")
                    else
                        say("Hai gia' questa Corazza Corrotta!")
                    end
                elseif s == 4 and corruption >= 500 then
                    if pc.count_item(54112) == 0 then
                        pc.give_item2(54112, 1)
                        say("Hai ricevuto Corazza Corrotta Femmina!")
                    else
                        say("Hai gia' questa Corazza Corrotta!")
                    end
                else
                    say("Requisiti non rispettati.")
                end
            end
        end

        when 30123.chat."Gestione Luce" begin
            local faction = pc.getqf("faction") or 0
            if faction ~= 2 then
                say("Non sei della fazione della Luce.")
                return
            end

            local points = pc.getqf("pure_points") or 0
            local menu = select("Controlla Stato", "Negozio Luce", "Chiudi")

            if menu == 1 then
                say_title("Stato Punti Luce:")
                say("Punti: " .. points .. "/500")
            elseif menu == 2 then
                say_title("Negozio della Luce:")
                local s = select(
                    "Elmo Purezza Maschio (400)",
                    "Elmo Purezza Femmina (400)",
                    "Corazza Purezza Maschio (500)",
                    "Corazza Purezza Femmina (500)",
                    "Chiudi"
                )

                if s == 1 and points >= 400 then
                    if pc.count_item(31786) == 0 then
                        pc.give_item2(31786, 1)
                        say("Hai ricevuto l'Elmo Purezza Maschio!")
                    else
                        say("Hai gia' questo Elmo Purezza!")
                    end
                elseif s == 2 and points >= 400 then
                    if pc.count_item(31787) == 0 then
                        pc.give_item2(31787, 1)
                        say("Hai ricevuto l'Elmo Purezza Femmina!")
                    else
                        say("Hai già questo Elmo Purezza!")
                    end
                elseif s == 3 and points >= 500 then
                    if pc.count_item(31784) == 0 then
                        pc.give_item2(31784, 1)
                        say("Hai ricevuto Corazza Purezza Maschio!")
                    else
                        say("Hai gia' questa Corazza Purezza!")
                    end
                elseif s == 4 and points >= 500 then
                    if pc.count_item(31785) == 0 then
                        pc.give_item2(31785, 1)
                        say("Hai ricevuto Corazza Purezza Femmina!")
                    else
                        say("Hai gia' questa Corazza Purezza!")
                    end
                else
                    say("Requisiti non rispettati.")
                end
            end
        end
    end
end


mi esce questo errore:
SYSERR: Dec 23 04:27:36 :: RunState: LUA_ERROR: [string "faction_system"]:2: attempt to call field `getqf' (a nil value)
SYSERR: Dec 23 04:27:36 :: WriteRunningStateToSyserr: LUA_ERROR: quest faction_system.start click
 
Prova cosi:

CSS:
quest faction_system begin
    function check_corruption_level()
        if not pc.is_pc() then return end
        local corruption = pc.getqf("corruption_points") or 0
        local last_level = pc.getqf("corruption_last_level") or 0
        local new_level = 0
        if corruption >= 500 then new_level = 5
        elseif corruption >= 400 then new_level = 4
        elseif corruption >= 350 then new_level = 3
        elseif corruption >= 31 then new_level = 2
        elseif corruption >= 1 then new_level = 1
        end
        if new_level > last_level then
            pc.setqf("corruption_last_level", new_level)
            local titles = {[2]="GUERRIERO OSCURO", [3]="SIGNORE DEMONE", [4]="SIGNORE SUPREMO", [5]="IL POTERE MASSIMO"}
            if titles[new_level] then
                syschat("Sei diventato " .. titles[new_level] .. "!")
                notice_all(pc.get_name() .. " e' diventato " .. titles[new_level] .. "!")
            end
        end
    end

    function check_purity_level()
        if not pc.is_pc() then return end
        local points = pc.getqf("pure_points") or 0
        local last_level = pc.getqf("pure_last_level") or 0
        local new_level = 0
        if points >= 500 then new_level = 5
        elseif points >= 400 then new_level = 4
        elseif points >= 350 then new_level = 3
        elseif points >= 100 then new_level = 2
        elseif points >= 1 then new_level = 1
        end
        if new_level > last_level then
            pc.setqf("pure_last_level", new_level)
            local titles = {[2]="PALADINO", [3]="GUARDIANO DELLA LUCE", [4]="SIGNORE DELLA PUREZZA", [5]="LA MASSIMA PUREZZA"}
            if titles[new_level] then
                syschat("Sei diventato " .. titles[new_level] .. "!")
                notice_all(pc.get_name() .. " e' diventato " .. titles[new_level] .. "!")
            end
        end
    end

    state start begin
        when login begin
            local corruption = pc.getqf("corruption_points") or 0
            local purity = pc.getqf("pure_points") or 0
            pc.setqf("corruption_points", math.max(0, math.min(corruption, 500)))
            pc.setqf("pure_points", math.max(0, math.min(purity, 500)))
            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                pc.setqf("is_corrupted", 1)
                pc.setqf("is_pure", 0)
            elseif faction == 2 then
                pc.setqf("is_pure", 1)
                pc.setqf("is_corrupted", 0)
            end
            loop_timer("check_levels", 600)
        end

        when check_levels.timer begin
            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                faction_system.check_corruption_level()
            elseif faction == 2 then
                faction_system.check_purity_level()
            end
        end

        when 9700.chat."Abbraccia il Potere Oscuro" begin
            if pc.getqf("demone_contact") == 0 then
                say_title("Maestro Oscuro:")
                say("Non sei ancora pronto per questo potere...")
                return
            end
            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                say("Hai gia' abbracciato l'oscurita'.")
                say("Corruzione: " .. pc.getqf("corruption_points") .. "/500")
            elseif faction == 2 then
                say("Hai gia' scelto la Luce.")
            end
        end

        when 9700.chat."Abbandona il Potere Oscuro" begin
            if pc.getqf("faction") ~= 1 then return end
            say_title("Maestro Oscuro:")
            say("Vuoi davvero abbandonare l'oscurità?")
            if select("Si", "No") == 1 then
                local items = {54111, 54112, 54114, 54115}
                for _, v in ipairs(items) do
                    while pc.count_item(v) > 0 do pc.remove_item(v, 1) end
                end
                pc.setqf("faction", 0)
                pc.setqf("corruption_points", 0)
                pc.setqf("corruption_last_level", 0)
                syschat("Oscurità rimossa!")
            end
        end

        when 9433.chat."Abbraccia la Luce" begin
            if pc.getqf("demone_contact") == 0 then
                say_title("Guardiano della Luce:")
                say("Non sei ancora pronto...")
                return
            end
            local faction = pc.getqf("faction") or 0
            if faction == 2 then
                say("Hai gia' scelto la via della Luce.")
                say("Punti Luce: " .. pc.getqf("pure_points") .. "/500")
            elseif faction == 1 then
                say("Sei gia' corrotto.")
            end
        end

        when 9433.chat."Abbandona la Luce" begin
            if pc.getqf("faction") ~= 2 then return end
            say_title("Guardiano della Luce:")
            say("Vuoi abbandonare la Luce?")
            if select("Si", "No") == 1 then
                local items = {31786, 31787, 31784, 31785}
                for _, v in ipairs(items) do
                    while pc.count_item(v) > 0 do pc.remove_item(v, 1) end
                end
                pc.setqf("faction", 0)
                pc.setqf("pure_points", 0)
                pc.setqf("pure_last_level", 0)
                syschat("Luce rimossa!")
            end
        end

        when kill with npc.is_pc() begin
            local f = pc.getqf("faction") or 0
            local vf = npc.getqf("faction") or 0
            if f == 1 and vf == 2 then
                pc.setqf("corruption_points", math.min(pc.getqf("corruption_points") + 15, 500))
                faction_system.check_corruption_level()
            elseif f == 2 and vf == 1 then
                pc.setqf("pure_points", math.min(pc.getqf("pure_points") + 15, 500))
                faction_system.check_purity_level()
            end
        end

        when 9042.kill begin
            if pc.getqf("faction") == 1 then
                pc.setqf("corruption_points", math.min(pc.getqf("corruption_points") + 10, 500))
                faction_system.check_corruption_level()
            end
        end

        when 7557.kill or 9044.kill or 9045.kill begin
            if pc.getqf("faction") == 2 then
                pc.setqf("pure_points", math.min(pc.getqf("pure_points") + 10, 500))
                faction_system.check_purity_level()
            end
        end

        when 33009.chat."Negozio Oscuro" begin
            if pc.getqf("faction") ~= 1 then return end
            local c = pc.getqf("corruption_points")
            local s = select("Elmo M (400)", "Elmo F (400)", "Corazza M (500)", "Corazza F (500)", "Chiudi")
            local data = {[1]={54114,400}, [2]={54115,400}, [3]={54111,500}, [4]={54112,500}}
            if data[s] then
                if c >= data[s][2] and pc.count_item(data[s][1]) == 0 then
                    pc.give_item2(data[s][1], 1)
                else
                    say("Requisiti non soddisfatti o oggetto già posseduto.")
                end
            end
        end

        when 30123.chat."Negozio Luce" begin
            if pc.getqf("faction") ~= 2 then return end
            local p = pc.getqf("pure_points")
            local s = select("Elmo M (400)", "Elmo F (400)", "Corazza M (500)", "Corazza F (500)", "Chiudi")
            local data = {[1]={31786,400}, [2]={31787,400}, [3]={31784,500}, [4]={31785,500}}
            if data[s] then
                if p >= data[s][2] and pc.count_item(data[s][1]) == 0 then
                    pc.give_item2(data[s][1], 1)
                else
                    say("Requisiti non soddisfatti o oggetto già posseduto.")
                end
            end
        end
    end
end
 
Ultima modifica:
Prova così:
CSS:
quest faction_system begin
    state start begin

        ----------------------------------------------------------------------
        -- FUNZIONI DI CONTROLLO LIVELLO
        ----------------------------------------------------------------------
        function check_corruption_level()
            local corruption = pc.getqf("corruption_points") or 0
            local last_level = pc.getqf("corruption_last_level") or 0
            local new_level = 0

            if corruption >= 500 then new_level = 5
            elseif corruption >= 400 then new_level = 4
            elseif corruption >= 350 then new_level = 3
            elseif corruption >= 31 then new_level = 2
            elseif corruption >= 1 then new_level = 1
            end

            if new_level > last_level then
                pc.setqf("corruption_last_level", new_level)

                if new_level == 2 then
                    syschat("Sei diventato GUERRIERO OSCURO!")
                    notice_all(pc.get_name() .. " e' diventato GUERRIERO OSCURO!")
                elseif new_level == 3 then
                    syschat("Sei diventato SIGNORE DEMONE!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE DEMONE!")
                elseif new_level == 4 then
                    syschat("Sei diventato SIGNORE SUPREMO!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE SUPREMO!")
                elseif new_level == 5 then
                    syschat("HAI RAGGIUNTO IL POTERE MASSIMO!")
                    notice_all("!!! " .. pc.get_name() .. " HA RAGGIUNTO IL MASSIMO POTERE!!!")
                end
            end
        end

        function check_purity_level()
            local points = pc.getqf("pure_points") or 0
            local last_level = pc.getqf("pure_last_level") or 0
            local new_level = 0

            if points >= 500 then new_level = 5
            elseif points >= 400 then new_level = 4
            elseif points >= 350 then new_level = 3
            elseif points >= 100 then new_level = 2
            elseif points >= 1 then new_level = 1
            end

            if new_level > last_level then
                pc.setqf("pure_last_level", new_level)

                if new_level == 2 then
                    syschat("Sei diventato PALADINO!")
                    notice_all(pc.get_name() .. " e' diventato PALADINO!")
                elseif new_level == 3 then
                    syschat("Sei diventato GUARDIANO DELLA LUCE!")
                    notice_all(pc.get_name() .. " e' diventato GUARDIANO DELLA LUCE!")
                elseif new_level == 4 then
                    syschat("Sei diventato SIGNORE DELLA PUREZZA!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE DELLA PUREZZA!")
                elseif new_level == 5 then
                    syschat("HAI RAGGIUNTO LA MASSIMA PUREZZA!")
                    notice_all("!!! " .. pc.get_name() .. " HA RAGGIUNTO LA MASSIMA PUREZZA!!!")
                end
            end
        end

        ----------------------------------------------------------------------
        -- LOGIN INIT
        ----------------------------------------------------------------------
        when login begin
            pc.setqf("corruption_points", math.min(math.max(pc.getqf("corruption_points") or 0, 0), 500))
            pc.setqf("pure_points", math.min(math.max(pc.getqf("pure_points") or 0, 0), 500))

            local faction = pc.getqf("faction") or 0
            if faction == 1 then
                pc.setqf("is_corrupted", 1)
                pc.setqf("is_pure", 0)
            elseif faction == 2 then
                pc.setqf("is_pure", 1)
                pc.setqf("is_corrupted", 0)
            end

            loop_timer("check_levels", 600)
        end

        when check_levels.timer begin
            if pc.getqf("faction") == 1 then
                check_corruption_level()
            elseif pc.getqf("faction") == 2 then
                check_purity_level()
            end
        end

        ----------------------------------------------------------------------
        -- CORRUZIONE / PUREZZA PVP (FIXATO)
        ----------------------------------------------------------------------
        when kill with npc.is_pc() begin
            local killer_faction = pc.getqf("faction") or 0
            local victim_vid = npc.get_vid()

            pc.select(victim_vid)
            local victim_faction = pc.getqf("faction") or 0
            pc.select()

            if killer_faction == 1 and victim_faction == 2 then
                pc.setqf("corruption_points",
                    math.min((pc.getqf("corruption_points") or 0) + 15, 500))
                syschat("Hai guadagnato 15 punti corruzione!")
                check_corruption_level()

            elseif killer_faction == 2 and victim_faction == 1 then
                pc.setqf("pure_points",
                    math.min((pc.getqf("pure_points") or 0) + 15, 500))
                syschat("Hai guadagnato 15 punti luce!")
                check_purity_level()
            end
        end

        ----------------------------------------------------------------------
        -- CORRUZIONE PVM
        ----------------------------------------------------------------------
        when 9042.kill begin
            if pc.getqf("faction") == 1 then
                pc.setqf("corruption_points",
                    math.min((pc.getqf("corruption_points") or 0) + 10, 500))
                syschat("Innocente ucciso! +10 corruzione")
                check_corruption_level()
            end
        end

        ----------------------------------------------------------------------
        -- PUREZZA PVM
        ----------------------------------------------------------------------
        when 7557.kill or 9044.kill or 9045.kill begin
            if pc.getqf("faction") == 2 then
                pc.setqf("pure_points",
                    math.min((pc.getqf("pure_points") or 0) + 10, 500))
                syschat("Hai guadagnato 10 punti luce!")
                check_purity_level()
            end
        end

        ----------------------------------------------------------------------
        -- NEGOZIO OSCURO
        ----------------------------------------------------------------------
        when 33009.chat."Gestione Potere Oscuro" begin
            if pc.getqf("faction") ~= 1 then
                say("Non sei corrotto.")
                return
            end

            local corruption = pc.getqf("corruption_points") or 0
            local s = select("Stato", "Negozio", "Chiudi")

            if s == 1 then
                say("Corruzione: "..corruption.."/500")
            elseif s == 2 then
                local c = select(
                    "Elmo Maschio (400)",
                    "Elmo Femmina (400)",
                    "Corazza Maschio (500)",
                    "Corazza Femmina (500)",
                    "Chiudi"
                )

                if c == 1 and corruption >= 400 then pc.give_item2(54114,1)
                elseif c == 2 and corruption >= 400 then pc.give_item2(54115,1)
                elseif c == 3 and corruption >= 500 then pc.give_item2(54111,1)
                elseif c == 4 and corruption >= 500 then pc.give_item2(54112,1)
                else say("Requisiti non rispettati.") end
            end
        end

        ----------------------------------------------------------------------
        -- NEGOZIO LUCE
        ----------------------------------------------------------------------
        when 30123.chat."Gestione Luce" begin
            if pc.getqf("faction") ~= 2 then
                say("Non sei puro.")
                return
            end

            local points = pc.getqf("pure_points") or 0
            local s = select("Stato", "Negozio", "Chiudi")

            if s == 1 then
                say("Punti luce: "..points.."/500")
            elseif s == 2 then
                local c = select(
                    "Elmo Maschio (400)",
                    "Elmo Femmina (400)",
                    "Corazza Maschio (500)",
                    "Corazza Femmina (500)",
                    "Chiudi"
                )

                if c == 1 and points >= 400 then pc.give_item2(31786,1)
                elseif c == 2 and points >= 400 then pc.give_item2(31787,1)
                elseif c == 3 and points >= 500 then pc.give_item2(31784,1)
                elseif c == 4 and points >= 500 then pc.give_item2(31785,1)
                else say("Requisiti non rispettati.") end
            end
        end

    end
end
 
Stato
Discussione chiusa ad ulteriori risposte.
Indietro
Top Bottom