Jump to content

Recommended Posts

Hi guys, I created this system, where when you reach a certain level of corruption you can take from the shop, costume and helmet the only problem is when I return pure (I would like the items to be removed from the inventory) it works if I have the item in the main inventory but if you wear it it does not delete it, how can I solve it?

ty all

quest corruption_system begin
    state start begin
        -- LOGIN
        when login begin
            local corruption = pc.getqf("corruption_points")
            
            if corruption < 0 then
                pc.setqf("corruption_points", 0)
            end
            if corruption > 500 then
                pc.setqf("corruption_points", 500)
            end
            
            -- Timer controllo anti-frode (ogni 10 minuti)
            timer("check_items_fraud", 600)
        end
        
        -- CONTROLLO ANTI-FRODE
        when check_items_fraud.timer begin
            local is_corrupted = pc.getqf("is_corrupted")
            local corruption = pc.getqf("corruption_points")
            
            -- Se NON è corrotto, rimuovi TUTTO
            if is_corrupted == 0 then
                if pc.count_item(41202) > 0 then
                    pc.remove_item(41202, pc.count_item(41202))
                    syschat("COSTUME RIMOSSO: non sei più corrotto!")
                end
                
                if pc.count_item(41203) > 0 then
                    pc.remove_item(41203, pc.count_item(41203))
                    syschat("ELMO RIMOSSO: non sei più corrotto!")
                end
            else
                -- Se è corrotto, controlla requisiti
                if pc.count_item(41202) > 0 and corruption < 400 then
                    pc.remove_item(41202, pc.count_item(41202))
                    syschat("COSTUME RIMOSSO: corruzione sotto 400!")
                end
                
                if pc.count_item(41203) > 0 and corruption < 100 then
                    pc.remove_item(41203, pc.count_item(41203))
                    syschat("ELMO RIMOSSO: corruzione sotto 100!")
                end
            end
            
            -- Ricontrolla tra 10 minuti
            timer("check_items_fraud", 600)
        end
        
        -- ABBRACCIARE L'OSCURITÀ
        when 9700.chat."Abbraccia il Potere Oscuro" begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 1 then
                local corruption = pc.getqf("corruption_points")
                say_title("Maestro Oscuro:")
                say("Hai già abbracciato l'oscurità.")
                say("Corruzione: " .. corruption .. "/500")
                return
            end
            
            say_title("Maestro Oscuro:")
            say("Vuoi abbracciare il Potere Oscuro?")
            say("")
            say_reward("Otterrai:")
            say("- Titoli esclusivi")
            say("- Possibilità di comprare Costume ed Elmo")
            say("")
            
            local s = select("Sì, abbraccia", "No")
            
            if s == 1 then
                pc.setqf("is_corrupted", 1)
                pc.setqf("corruption_points", 15)
                pc.setqf("last_level", 0)
                
                say_title("Maestro Oscuro:")
                say("Benvenuto nell'oscurità!")
                
                notice_all(pc.get_name() .. " ha abbracciato il Potere Oscuro!")
            end
        end
        
        -- UCCIDERE GIOCATORI
        when kill with npc.is_pc() begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 1 then
                local corruption = pc.getqf("corruption_points")
                
                if corruption < 500 then
                    corruption = corruption + 10
                    pc.setqf("corruption_points", corruption)
                    syschat("POTERE OSCURO +10! [" .. corruption .. "/500]")
                    
                    corruption_system.check_level()
                end
            end
        end
        
        -- UCCIDERE NPC INNOCENTI
        when 101.kill begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 1 then
                local corruption = pc.getqf("corruption_points")
                
                if corruption < 500 then
                    corruption = corruption + 5
                    pc.setqf("corruption_points", corruption)
                    syschat("Innocente ucciso! +5 [" .. corruption .. "/500]")
                    
                    corruption_system.check_level()
                end
            end
        end
        
        -- SACRIFICARE OGGETTI
        when 9700.chat."Sacrifica oggetti per potere" begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 0 then
                say_title("Altare Oscuro:")
                say("Solo i corrotti possono usare questo altare.")
                return
            end
            
            local corruption = pc.getqf("corruption_points")
            
            if corruption >= 500 then
                say_title("Altare Oscuro:")
                say("Hai raggiunto il massimo potere!")
                return
            end
            
            say_title("Altare Oscuro:")
            say("Corruzione: " .. corruption .. "/500")
            say("")
            
            local s = select("10 Pietre Anima (+5)", "1 Pietra Drago (+10)", "100M Yang (+15)", "Chiudi")
            
            if s == 1 then
                if pc.count_item(30301) >= 10 then
                    pc.remove_item(30301, 10)
                    corruption = math.min(corruption + 5, 500)
                    pc.setqf("corruption_points", corruption)
                    syschat("Sacrificio accettato! +5")
                    corruption_system.check_level()
                else
                    say("Non hai abbastanza Pietre Anima!")
                end
                
            elseif s == 2 then
                if pc.count_item(30000) >= 1 then
                    pc.remove_item(30000, 1)
                    corruption = math.min(corruption + 10, 500)
                    pc.setqf("corruption_points", corruption)
                    syschat("Sacrificio potente! +10")
                    corruption_system.check_level()
                else
                    say("Non hai la Pietra Drago!")
                end
                
            elseif s == 3 then
                if pc.get_gold() >= 100000000 then
                    pc.change_gold(-100000000)
                    corruption = math.min(corruption + 15, 500)
                    pc.setqf("corruption_points", corruption)
                    syschat("Sacrificio massiccio! +15")
                    corruption_system.check_level()
                else
                    say("Non hai abbastanza Yang!")
                end
            end
        end
        
        -- CONTROLLA STATO
        when 33009.chat."Controlla Potere Oscuro" begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 0 then
                say_title("Stato:")
                say_reward("NON SEI CORROTTO")
                say("")
                say("Parla con il Maestro Oscuro!")
                return
            end
            
            local corruption = pc.getqf("corruption_points")
            
            say_title("Potere Oscuro:")
            say("Corruzione: " .. corruption .. "/500")
            say("")
            
            if corruption >= 500 then
                say_reward("LIVELLO 5 - SIGNORE SUPREMO MAX")
            elseif corruption >= 400 then
                say_reward("LIVELLO 4 - SIGNORE SUPREMO")
            elseif corruption >= 350 then
                say_reward("LIVELLO 3 - SIGNORE DEMONE")
            elseif corruption >= 31 then
                say_reward("LIVELLO 2 - GUERRIERO OSCURO")
            else
                say_reward("LIVELLO 1 - INIZIATO OSCURO")
            end
        end
        
        -- NEGOZIO OSCURO
        when 33009.chat."Negozio Potere Oscuro" begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 0 then
                say_title("Mercante Oscuro:")
                say("Solo i corrotti possono comprare!")
                return
            end
            
            local corruption = pc.getqf("corruption_points")
            
            say_title("Negozio Oscuro:")
            say("Corruzione: " .. corruption .. "/500")
            say("")
            say_item("Costume Supremo - 400 Corruzione", 41202, 0)
            say_item("Elmo Supremo - 100 Corruzione", 41203, 0)
            say("")
            
            local s = select("Costume (400)", "Elmo (100)", "Chiudi")
            
            if s == 1 then
                if corruption >= 400 then
                    if pc.count_item(41202) > 0 then
                        say("Hai già il Costume Supremo!")
                    else
                        pc.give_item2(41202, 1)
                        say_title("Mercante:")
                        say("Ecco il tuo COSTUME SUPREMO!")
                        notice_all(pc.get_name() .. " ha acquistato il COSTUME SUPREMO!")
                    end
                else
                    say("Serve 400 corruzione!")
                    say("Ne hai: " .. corruption)
                end
                
            elseif s == 2 then
                if corruption >= 100 then
                    if pc.count_item(41203) > 0 then
                        say("Hai già l'Elmo Supremo!")
                    else
                        pc.give_item2(41203, 1)
                        say_title("Mercante:")
                        say("Ecco il tuo ELMO SUPREMO!")
                        notice_all(pc.get_name() .. " ha acquistato l'ELMO SUPREMO!")
                    end
                else
                    say("Serve 100 corruzione!")
                    say("Ne hai: " .. corruption)
                end
            end
        end
        
        -- ABBANDONA OSCURITÀ
        when 9700.chat."Abbandona Potere Oscuro (5M Yang)" begin
            local is_corrupted = pc.getqf("is_corrupted")
            
            if is_corrupted == 0 then
                say_title("Sacerdote:")
                say("Sei già puro.")
                return
            end
            
            local corruption = pc.getqf("corruption_points")
            
            say_title("Sacerdote:")
            say("Vuoi abbandonare l'oscurità?")
            say("")
            say("Costa: 5.000.000 Yang")
            say("Perdi tutto (corruzione, titoli, oggetti)")
            say("")
            
            local s = select("Sì", "No")
            
            if s == 1 then
                if pc.get_gold() >= 5000000 then
                    -- PRIMA rimuovi gli oggetti
                    local removed_items = false
                    
                    if pc.count_item(41202) > 0 then
                        pc.remove_item(41202, pc.count_item(41202))
                        removed_items = true
                        syschat("Costume Supremo rimosso!")
                    end
                    
                    if pc.count_item(41203) > 0 then
                        pc.remove_item(41203, pc.count_item(41203))
                        removed_items = true
                        syschat("Elmo Supremo rimosso!")
                    end
                    
                    -- POI resetta tutto
                    pc.change_gold(-5000000)
                    pc.setqf("is_corrupted", 0)
                    pc.setqf("corruption_points", 0)
                    pc.setqf("last_level", 0)
                    pc.remove_title()
                    
                    say_title("Sacerdote:")
                    say("Sei purificato!")
                    if removed_items then
                        say("")
                        say("Costume ed Elmo sono stati rimossi!")
                    end
                    
                    notice_all(pc.get_name() .. " ha abbandonato il Potere Oscuro!")
                else
                    say("Non hai abbastanza Yang!")
                end
            end
        end
        
        -- FUNZIONE CONTROLLA LIVELLO
        function check_level()
            local corruption = pc.getqf("corruption_points")
            local last_level = pc.getqf("last_level")
            local new_level = 0
            
            -- Calcola livello attuale
            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
            
            -- Se è cambiato livello
            if new_level > last_level then
                pc.setqf("last_level", new_level)
                
                -- LIVELLO 2
                if new_level == 2 then
                    pc.set_title("[CORROTTO]")
                    syschat("Sei diventato GUERRIERO OSCURO!")
                    notice_all(pc.get_name() .. " e' diventato GUERRIERO OSCURO! (Livello 2)")
                    
                -- LIVELLO 3
                elseif new_level == 3 then
                    pc.set_title("[DEMONE]")
                    syschat("Sei diventato SIGNORE DEMONE!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE DEMONE! (Livello 3)")
                    
                -- LIVELLO 4
                elseif new_level == 4 then
                    pc.set_title("[SUPREMO]")
                    syschat("Sei diventato SIGNORE SUPREMO!")
                    notice_all(pc.get_name() .. " e' diventato SIGNORE SUPREMO! (Livello 4)")
                    
                -- LIVELLO 5
                elseif new_level == 5 then
                    pc.set_title("[SUPREMO]")
                    syschat("HAI RAGGIUNTO IL POTERE MASSIMO!")
                    notice_all("████ " .. pc.get_name() .. " HA RAGGIUNTO IL MASSIMO POTERE! (Livello 5) ████")
                end
            end
        end
    end
end
Link to comment
https://metin2.dev/topic/34209-problem-quest/
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • Honorable Member

spacer.png

Edited by Metin2 Dev International
Core X - External 2 Internal
  • kekw 3

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
https://metin2.dev/topic/34209-problem-quest/#findComment-173659
Share on other sites

  • Active Member

You need basically new CPP function for that, you can't do it by default

OPENING 27.06.2026 SEKAII : https://sekaii.org/

          NEW METIN 2 STYLE, ROGUE LIKE, PARANGON, LV.120+, BREEDING MOUNT AND MORE

Link to comment
https://metin2.dev/topic/34209-problem-quest/#findComment-173753
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.