Bvural41 1
Bvural41
Fethi Polat 1
Fethi Polat
Mt2Hizmet 1
Mt2Hizmet
Sevdamsın 1
Sevdamsın
Nedved35 1
Nedved35
Hikaye Ekle

GM Letter Quest Sorunu

  • Konuyu başlatan Konuyu başlatan brs77
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 16
  • Görüntüleme Görüntüleme 2K

Ayyıldız2 | 2008 TR Yapısı • 1-99 Orta Emek Destan • Oto Avsız • 10 Temmuz 21:00 HEMEN TIKLA!

arkadaşlar letter olarak gelmesi gereken quest gelmiyor aktif olan letter questinin içine yazınca kullanabiliyorum sadece
mesela aşağıdaki questi eklemek istiyorum Oyunda Gözükmesi Gereken "GM Servis" görevi gözükmüyor

Kod:
quest gmservis begin
    state start begin
        when letter with pc.is_gm() begin
            send_letter("GM Servis")
            end
        when info or button with pc.is_gm() begin
        local sec123 = select("Servis","Bonus ekle","Binek çağır","Dropları aç ","Bug itemi al","Duyuruları başlat","Oyuncu banla","Vazgeç ")
            if sec123 == 1 then
            local s = select("Becerilerimi Perfect yap","İtem ver","Saç Stili ver","Güneş Özütü ve Ay Özütü ver","Giriş eşyası al","NPC çağır","Event başlat veya bitir","Vazgeç ")
                if s == 1 then
                    if pc.get_job() == 0 then
                                    pc.set_skill_level(1,40)
                                    pc.set_skill_level(2,40)
                                    pc.set_skill_level(3,40)
                                    pc.set_skill_level(4,40)
                                    pc.set_skill_level(5,40)
                                    pc.set_skill_level(137,20)
                                    pc.set_skill_level(138,20)
                                    pc.set_skill_level(139,20)
                                    pc.set_skill_level(131,10)
                                    pc.set_skill_level(129,40)
                                    pc.set_skill_level(128,20)
                                    pc.set_skill_level(130,21)
                                    pc.set_skill_level(127,20)
                                    pc.set_skill_level(126,20)
                                    pc.set_skill_level(124,40)
                                    pc.set_skill_level(121,40)
                                    pc.set_skill_level(122,2)
                                    pc.set_skill_level(17,40)
                                    pc.set_skill_level(18,40)
                                    pc.set_skill_level(19,40)
                                    pc.set_skill_level(20,40)
                                    pc.set_skill_level(16,40)
                                    send_letter("Villa")
                                    end
                    if pc.get_job() == 1 then
                                    pc.set_skill_level(46,40)
                                    pc.set_skill_level(47,40)
                                    pc.set_skill_level(48,40)
                                    pc.set_skill_level(49,40)
                                    pc.set_skill_level(50,40)
                                    pc.set_skill_level(137,20)
                                    pc.set_skill_level(138,20)
                                    pc.set_skill_level(139,20)
                                    pc.set_skill_level(140,20)
                                    pc.set_skill_level(131,10)
                                    pc.set_skill_level(130,21)
                                    pc.set_skill_level(129,40)
                                    pc.set_skill_level(128,20)
                                    pc.set_skill_level(127,20)
                                    pc.set_skill_level(126,20)
                                    pc.set_skill_level(124,40)
                                    pc.set_skill_level(121,40)
                                    pc.set_skill_level(122,2)
                                    pc.set_skill_level(49,40)
                                    pc.set_skill_level(50,40)
                                    pc.set_skill_level(48,40)
                                    pc.set_skill_level(47,40)
                                    pc.set_skill_level(46,40)
                                    send_letter("Villa")
                                    end
                    if pc.get_job() == 2 then
                                    pc.set_skill_level(61,40)
                                    pc.set_skill_level(62,40)
                                    pc.set_skill_level(63,40)
                                    pc.set_skill_level(64,40)
                                    pc.set_skill_level(65,40)
                                    pc.set_skill_level(66,40)
                                    pc.set_skill_level(137,20)
                                    pc.set_skill_level(138,20)
                                    pc.set_skill_level(139,20)
                                    pc.set_skill_level(130,21)
                                    pc.set_skill_level(131,10)
                                    pc.set_skill_level(129,40)
                                    pc.set_skill_level(128,20)
                                    pc.set_skill_level(127,20)
                                    pc.set_skill_level(126,20)
                                    pc.set_skill_level(124,40)
                                    pc.set_skill_level(121,40)
                                    pc.set_skill_level(122,2)
                                    pc.set_skill_level(76,40)
                                    pc.set_skill_level(77,40)
                                    pc.set_skill_level(78,40)
                                    pc.set_skill_level(79,40)
                                    pc.set_skill_level(80,40)
                                    pc.set_skill_level(81,40)
                                    send_letter("Villa")
                                    end
                    if pc.get_job() == 3 then
                                    pc.set_skill_level(91,40)
                                    pc.set_skill_level(92,40)
                                    pc.set_skill_level(93,40)
                                    pc.set_skill_level(94,40)
                                    pc.set_skill_level(95,40)
                                    pc.set_skill_level(96,40)
                                    pc.set_skill_level(137,20)
                                    pc.set_skill_level(138,20)
                                    pc.set_skill_level(139,20)
                                    pc.set_skill_level(131,10)
                                    pc.set_skill_level(130,21)
                                    pc.set_skill_level(129,40)
                                    pc.set_skill_level(128,20)
                                    pc.set_skill_level(127,20)
                                    pc.set_skill_level(126,20)
                                    pc.set_skill_level(124,40)
                                    pc.set_skill_level(121,40)
                                    pc.set_skill_level(122,2)
                                    pc.set_skill_level(106,40)
                                    pc.set_skill_level(107,40)
                                    pc.set_skill_level(108,40)
                                    pc.set_skill_level(109,40)
                                    pc.set_skill_level(110,40)
                                    pc.set_skill_level(111,40)
                                    end
                elseif s == 2 then
                    if pc.get_job() == 0 then
                                    pc . give_item2("40002" , 1)
                                    pc . give_item2("40003" , 1)
                                    pc . give_item2("189" , 1)
                                    pc . give_item2("279" , 1)
                                    pc . give_item2("11299" , 1)
                                    pc . give_item2("12019" , 1)
                                    pc . give_item2("14229" , 1)
                                    pc . give_item2("16229" , 1)
                                    pc . give_item2("15419" , 1)
                                    pc . give_item2("17229" , 1)
                                    pc . give_item2("12289" , 1)
                                    pc . give_item2("13149" , 1)
                                    send_letter("Villa")
                                    end
                    if pc.get_job() == 1 then
                                    pc . give_item2("40002" , 1)
                                    pc . give_item2("40003" , 1)
                                    pc . give_item2("1139" , 1)
                                    pc . give_item2("4049" , 1)
                                    pc . give_item2("2179" , 1)
                                    pc . give_item2("2169" , 1)
                                    pc . give_item2("12029" , 1)
                                    pc . give_item2("11499" , 1)
                                    pc . give_item2("14229" , 1)
                                    pc . give_item2("16229" , 1)
                                    pc . give_item2("15419" , 1)
                                    pc . give_item2("17229" , 1)
                                    pc . give_item2("12409" , 1)
                                    pc . give_item2("13149" , 1)
                                    send_letter("Villa")
                                    end
                    if pc.get_job() == 2 then
                                    pc . give_item2("40002" , 1)
                                    pc . give_item2("40003" , 1)
                                    pc . give_item2("12039" , 1)
                                    pc . give_item2("11699" , 1)
                                    pc . give_item2("14229" , 1)
                                    pc . give_item2("16229" , 1)
                                    pc . give_item2("15419" , 1)
                                    pc . give_item2("17229" , 1)
                                    pc . give_item2("12549" , 1)
                                    pc . give_item2("13149" , 1)
                                    pc . give_item2("289" , 1)
                                    pc . give_item2("3129" , 1)
                                    pc . give_item2("279" , 1)
                                    send_letter("Villa")
                                    end
                    if pc.get_job() == 3 then
                                    pc . give_item2("40002" , 1)
                                    pc . give_item2("40003" , 1)
                                    pc . give_item2("12049" , 1)
                                    pc . give_item2("11899" , 1)
                                    pc . give_item2("14229" , 1)
                                    pc . give_item2("16229" , 1)
                                    pc . give_item2("15419" , 1)
                                    pc . give_item2("17229" , 1)
                                    pc . give_item2("12689" , 1)
                                    pc . give_item2("13149" , 1)
                                    pc . give_item2("5129" , 1)
                                    pc . give_item2("7199" , 1)
                                    send_letter("Villa")
                                    end
                elseif s == 3 then
                    if pc.get_job() == 0 then
                        if pc.get_sex() == 1 then
                                    pc . give_item2("75013" , 1)
                                    pc . give_item2("75014" , 1)
                                    pc . give_item2("75015" , 1)
                                    pc . give_item2("75016" , 1)
                                    pc . give_item2("75017" , 1)
                                    pc . give_item2("75018" , 1)
                                    pc . give_item2("75019" , 1)
                                    pc . give_item2("75020" , 1)
                                    send_letter("Villa")
                    else
                                    pc . give_item2("74013" , 1)
                                    pc . give_item2("74014" , 1)
                                    pc . give_item2("74015" , 1)
                                    pc . give_item2("74016" , 1)
                                    pc . give_item2("74017" , 1)
                                    pc . give_item2("74018" , 1)
                                    pc . give_item2("74019" , 1)
                                    pc . give_item2("74020" , 1)
                                    send_letter("Villa")
                                    end
                                end
                    if pc.get_job() == 1 then
                        if pc.get_sex() == 1 then
                                    pc . give_item2("74263" , 1)
                                    pc . give_item2("74264" , 1)
                                    pc . give_item2("74265" , 1)
                                    pc . give_item2("74266" , 1)
                                    pc . give_item2("74267" , 1)
                                    pc . give_item2("74268" , 1)
                                    pc . give_item2("74269" , 1)
                                    pc . give_item2("74270" , 1)
                                    send_letter("Villa")
                        else
                                    pc . give_item2("75213" , 1)
                                    pc . give_item2("75214" , 1)
                                    pc . give_item2("75215" , 1)
                                    pc . give_item2("75216" , 1)
                                    pc . give_item2("75217" , 1)
                                    pc . give_item2("75218" , 1)
                                    pc . give_item2("75219" , 1)
                                    pc . give_item2("75220" , 1)
                                    send_letter("Villa")
                                    end
                                end
                    if pc.get_job() == 2 then
                        if pc.get_sex() == 1 then
                                    pc . give_item2("75413" , 1)
                                    pc . give_item2("75414" , 1)
                                    pc . give_item2("75415" , 1)
                                    pc . give_item2("75416" , 1)
                                    pc . give_item2("75417" , 1)
                                    pc . give_item2("75418" , 1)
                                    pc . give_item2("75419" , 1)
                                    pc . give_item2("75420" , 1)
                                    send_letter("Villa")
                        else
                                    pc . give_item2("74513" , 1)
                                    pc . give_item2("74514" , 1)
                                    pc . give_item2("74515" , 1)
                                    pc . give_item2("74516" , 1)
                                    pc . give_item2("74517" , 1)
                                    pc . give_item2("74518" , 1)
                                    pc . give_item2("74519" , 1)
                                    pc . give_item2("74520" , 1)
                                    send_letter("Villa")
                                    end
                                end
                    if pc.get_job() == 3 then
                        if pc.get_sex() == 1 then
                                    pc . give_item2("74763" , 1)
                                    pc . give_item2("74764" , 1)
                                    pc . give_item2("74765" , 1)
                                    pc . give_item2("74766" , 1)
                                    pc . give_item2("74767" , 1)
                                    pc . give_item2("74768" , 1)
                                    pc . give_item2("74769" , 1)
                                    pc . give_item2("74770" , 1)
                                    send_letter("Villa")
                        else
                                    pc . give_item2("75613" , 1)
                                    pc . give_item2("75614" , 1)
                                    pc . give_item2("75615" , 1)
                                    pc . give_item2("75616" , 1)
                                    pc . give_item2("75617" , 1)
                                    pc . give_item2("75618" , 1)
                                    pc . give_item2("75619" , 1)
                                    pc . give_item2("75620" , 1)
                                    send_letter("Villa")
                                    end
                                end
                elseif s == 4 then
                                    pc . give_item2("72726" , 1)
                                    pc . give_item2("72730" , 1)
                                    send_letter("Villa")
                elseif s == 5 then
                    local ss = select("Kilit Açma Taşı(5 adet)","Zin-Sa-Gui Kale Haritası ","Zin-Bong-In Anahtar","Kan Taşı, Geçiş Bileti, Kıvrık Anahtar","Ruh Kristali Anahtarı ","Küçülen Kafa","Surat Totemi","Vazgeç ")
                        if ss == 1 then
                            pc . give_item2("50084" , 1)
                            pc . give_item2("50084" , 1)
                            pc . give_item2("50084" , 1)
                            pc . give_item2("50084" , 1)
                            pc . give_item2("50084" , 1)
                            send_letter("Villa")
                        elseif ss == 2 then
                            pc . give_item2("30302" , 1)
                            send_letter("Villa")
                        elseif ss == 3 then
                            pc . give_item2("30304" , 1)
                            send_letter("Villa")
                        elseif ss == 4 then
                            pc . give_item2("30190" , 1)
                            pc . give_item2("71095" , 1)
                            pc . give_item2("30179" , 3)                       
                            send_letter("Villa")
                        elseif ss == 5 then
                            pc . give_item2("30311" , 1)
                            send_letter("Villa")
                        elseif ss == 6 then
                            pc . give_item2("30319" , 1)
                            send_letter("Villa")
                        elseif ss == 7 then
                            pc . give_item2("30312" , 1)
                            send_letter("Villa")
                        elseif ss == 8 then
                            return
                            send_letter("Villa")
                        end
                elseif s == 6 then
                    local sss = select("Satıcı, Silahçı, Zırhçı ","Genel Depocu Helen, Olay Yardımcısı ","Malzemeci Glocken, Madenci","Kud Heykeli","Kaplumbağa Kayalığı ","Runik Direği","Bazalt Dikili Taş ","Vazgeç ")
                        if sss == 1 then
                            command("mob 9001")
                            command("mob 9002")
                            command("mob 9003")
                            send_letter("Villa")
                        elseif sss == 2 then
                            command("mob 9010")
                            command("mob 9004")
                            send_letter("Villa")
                        elseif sss == 3 then
                            command("mob 9007")
                            command("mob 9008")
                            send_letter("Villa")
                        elseif sss == 4 then
                            command("mob 30101")
                            send_letter("Villa")
                        elseif sss == 5 then
                            command("mob 30103")
                            send_letter("Villa")
                        elseif sss == 6 then
                            command("mob 30104")
                            send_letter("Villa")
                        elseif sss == 7 then
                            command("mob 30102")
                            send_letter("Villa")
                        elseif sss == 8 then
                            return
                            send_letter("Villa")
                        end
                elseif s == 7 then
                    local event = select("Ramazan Etkinliği","Lonca Savaşları Turnuvası ","Savun ve Yok et ","Kostüm Etkinliği","Ayışığı Etkinliği","Mistik Sandık Etkinliği","Futbol Topu Etkinliği","Kapat")
                    if event == 1 then
                    local event2 = select("Ramazan Etkinliği başlat","Bereket Meyvesi ödülleri","Ramazan etkinliği bitir","Tabak drobu aç ","Hiçbir şey")
                    if event2 == 1 then
                    notice_all("Ramazan ayı etkinliği başladı!")
                    notice_all("Tarihçi'yi ziyaret et, Niyetli Vatandaş'a bir iyilik yap ya da")
                    notice_all("yaratıkları öldürüp simitleri al!")
                    game.set_event_flag("ramazan",1)
                    send_letter("Villa")
                    elseif event2 == 2 then
                    notice_all("Bereket meyvelerini Tarihçi'ye götür!")
                    notice_all("Ödülünü al!")
                    game.set_event_flag("ramazan",2)
                    send_letter("Villa")
                    elseif event2 == 3 then
                    notice_all("Ramazan ayı etkinliği sona erdi.")
                    game.set_event_flag("ramazan",0)
                    send_letter("Villa")
                    elseif event2 == 4 then
                    game.set_event_flag("tabak",1)
                    server_timer("tabak",60*60*6)
                    notice_all("Bağış Tabağı düşürmek için Metin Taşlarını ve patronları yok et!")
                    notice_all("Kalan Süre: 6 saat")
                    send_letter("Villa")
                    return
                    else
                    send_letter("Villa")
                    return
                    end
                    elseif event == 2 then
                    local event3 = select("Turnuva kayıtlarını aç ","Turnuva kayıtlarını kapat","Hiçbir şey")
                    if event3 == 1 then
                    notice_all("Lonca Savaşları Turnuvası kayıtları açıldı!")
                    notice_all("Turnuvaya katılmak için Savaş Sorumlusu ile konuş.")
                    game.set_event_flag("turnuva",1)
                    send_letter("Villa")
                    elseif event3 == 2 then
                    notice_all("Lonca Savaşları Turnuvası kayıtları kapandı.")
                    notice_all("Turnuva zamanı ve lonca eşleşmeleri forumdan duyurulacaktır.")
                    game.set_event_flag("turnuva",0)
                    send_letter("Villa")
                    elseif event3 == 3 then
                    return
                    send_letter("Villa")
                    end
                    elseif event == 3 then
                    local event4 = select("Savun Yok et aç ","Savun Yok et kapat","Hiçbir şey")
                    if event4 == 1 then
                        send_letter("Villa")
                        say_reward("Etkinliğin yapılacağı haritayı seç.")
                        say("")
                        local o = select("Yongbi Çölü ", "Sohan Dağı ", "Vadi", "Alev Diyarı ", "Vazgeç ")   
                        if o == 1 then
                        say_title("Savun ve Yok et")
                        say("")
                        say("Harita : Çöl")
                        say_reward("Başlatmak istiyor musun?")
                        local w = select("Evet", "Hayır") 
                            if w == 1 then
                            game.set_event_flag("defend_and_destroy_red", 5 )
                            game.set_event_flag("defend_and_destroy_yellow", 5 )
                            game.set_event_flag("defend_and_destroy_blue", 5 )
                            game.set_event_flag("defend_and_destroy", 1 )
                            regen_in_map(63, "data/dungeon/defend_and_destroy_wueste.txt")
                            notice_all("Savun ve Yok et etkinliği başladı.")
                            notice_all("Etkinlik haritası: Yongbi Çölü ")
                            notice_all("Bilgi almak ve kuralları öğrenmek için Savaş Sorumlusu'na git.")
                            elseif w == 2 then
                            return
                            end
                        elseif o == 2 then
                        say_title("Savun Ve Yok et")
                        say("")
                        say("Harita : Sohan Dağı ")
                        say_reward("Başlatmak istiyor musun?")
                        local e = select("Evet", "Hayır") 
                            if e == 1 then
                            game.set_event_flag("defend_and_destroy_red", 5 )
                            game.set_event_flag("defend_and_destroy_yellow", 5 )
                            game.set_event_flag("defend_and_destroy_blue", 5 )
                            game.set_event_flag("defend_and_destroy", 1 )
                            regen_in_map(61, "data/dungeon/defend_and_destroy_ice.txt")
                            notice_all("Savun ve Yok et etkinliği başladı.")
                            notice_all("Etkinlik haritası: Sohan Dağı ")
                            notice_all("Bilgi almak ve kuralları öğrenmek için Savaş Sorumlusu'na git.")
                            elseif e == 2 then
                            return
                            end
                        elseif o == 3 then
                        say_title("Savun ve Yok et")
                        say("")
                        say("Harita : Seungryong Vadisi")
                        say_reward("Başlatmak istiyor musun?")
                        local t = select("Evet", "Hayır")   
                            if t == 1 then
                            game.set_event_flag("defend_and_destroy_red", 5 )
                            game.set_event_flag("defend_and_destroy_yellow", 5 )
                            game.set_event_flag("defend_and_destroy_blue", 5 )
                            game.set_event_flag("defend_and_destroy", 1 )
                            regen_in_map(64, "data/dungeon/defend_and_destroy_ork.txt")
                            notice_all("Savun ve Yok et etkinliği başladı.")
                            notice_all("Etkinlik haritası: Seungryong Vadisi")
                            notice_all("Bilgi almak ve kuralları öğrenmek için Savaş Sorumlusu'na git.")
                            elseif t == 2 then
                            return
                            end
                        elseif o == 4 then
                        say_title("Savun ve Yok et")
                        say("")
                        say("Harita : Doyyumhwan")
                        say_reward("Başlatmak istiyor musun?")
                        local f = select("Evet", "Hayır") 
                            if f == 1 then
                            game.set_event_flag("defend_and_destroy_red", 5 )
                            game.set_event_flag("defend_and_destroy_yellow", 5 )
                            game.set_event_flag("defend_and_destroy_blue", 5 )
                            game.set_event_flag("defend_and_destroy", 1 )
                            regen_in_map(62, "data/dungeon/defend_and_destroy_fire.txt")
                            notice_all("Savun ve Yok et etkinliği başladı.")
                            notice_all("Etkinlik haritası: Doyyumhwan")
                            notice_all("Bilgi almak ve kuralları öğrenmek için Savaş Sorumlusu'na git.")
                            elseif f == 2 then
                            return
                            end
                        elseif o == 5 then
                        return
                        end
                    elseif event4 == 2 then
                    notice_all("Savun ve Yok et etkinliği sona erdi.")
                    game.set_event_flag("defend_and_destroy", 0 )
                    send_letter("Villa")
                    elseif event4 == 3 then
                    return
                    send_letter("Villa")
                    end
                    elseif event == 4 then
                    local event5 = select("Kostüm drop aç ","Hiçbir şey")
                    if event5 == 1 then
                    clear_server_timer("kostum_kapat")
                    notice_all("Metin Taşlarını yok et ve Olimpiyat Kostümü kazan!")
                    notice_all("Kalan Süre: 6 saat")
                    game.set_event_flag("dressup",1)
                    server_timer("kostum_kapat",60*60*6)
                    send_letter("Villa")
                    elseif event5 == 2 then           
                    return
                    send_letter("Villa")
                    end
                    elseif event == 5 then
                    local panpa = select("Ayışığı etkinliği başlat","Ayışığı etkinliği bitir","Vazgeç ")
                    if panpa == 1 then
                    say("Kaç saat açılacak?")
                    local aysaat = tonumber(input(""))
                    say("Emin misin?")
                    local aye = select("Evet","Hayır")
                        if aye == 2 then
                        send_letter("Villa")
                        return
                        else                   
                        game.set_event_flag("ayisigi",1)
                        notice_all("Ayışığı Define Sandığı etkinliği başladı!")
                        notice_all("Kalan Süre: "..aysaat.." saat")
                        server_timer("ayisik",aysaat*60*60)
                        send_letter("Villa")
                        return
                        end
                    elseif panpa == 2 then
                    game.set_event_flag("ayisigi",0)
                    clear_server_timer("ayisik")
                    notice_all("Ayışığı Define Sandığı etkinliği sona erdi.")
                    send_letter("Villa")
                    elseif panpa == 3 then
                    return
                    send_letter("Villa")
                    end
                    elseif event == 6 then
                    local panpa2 = select("Mistik Sandık droplarını aç ","Anahtar droplarını aç ","Etkinliği bitir","Vazgeç ")
                    if panpa2 == 1 then
                    say("Kaç saat açılacak?")
                    local missaat = tonumber(input(""))
                    say("Emin misin?")
                    local mise = select("Evet","Hayır")
                        if mise == 2 then
                        send_letter("Villa")
                        return
                        else                   
                        game.set_event_flag("esrarengiz_sandik",1)
                        notice_all("Mistik Sandık etkinliği başladı! Ayrıntılı bilgi: board.metintwo.org")
                        notice_all("Kalan Süre: "..missaat.." saat")
                        server_timer("mistik1",missaat*60*60)
                        send_letter("Villa")
                        return
                        end
                    elseif panpa2 == 2 then
                    game.set_event_flag("esrarengiz_sandik",2)
                    notice_all("Mistik Sandıklarını açmak için gerekli olan anahtarları ")
                    notice_all("elde etmek için düşman krallıkların oyuncularını yen!")
                    send_letter("Villa")
                    elseif panpa2 == 3 then
                    notice_all("Mistik Sandık etkinlği sona erdi.")
                    clear_server_timer("mistik1")
                    send_letter("Villa")
                    elseif panpa2 == 4 then
                    send_letter("Villa")
                    return
                    end
                    elseif event == 7 then
                    local panpa5 = select("Futbol Topu etkinliği başlat","Futbol Topu etkinliği bitir","Hiçbir şey")
                    if panpa5 == 1 then
                    say("Kaç saat açılacak?")
                    local futsaat = tonumber(input(""))
                    say("Emin misin?")
                    local fute = select("Evet","Hayır")
                        if fute == 2 then
                        send_letter("Villa")
                        return
                        else                   
                        game.set_event_flag("futboltopu",1)
                        notice_all("Futbol Topu etkinliği başladı!")
                        notice_all("Kalan Süre: "..futsaat.." saat")
                        server_timer("futboltopu",futsaat*60*60)
                        send_letter("Villa")
                        return
                        end
                    elseif panpa5 == 2 then
                    game.set_event_flag("futboltopu",0)
                    notice_all("Futbol Topu etkinliği sona erdi.")
                    clear_server_timer("futboltopu")
                    send_letter("Villa")
                    elseif panpa5 == 3 then
                    send_letter("Villa")
                    return
                    end
                    elseif event == 8 then
                    send_letter("Villa")
                    return
                    end
                elseif s == 8 then
                    send_letter("Villa")
                    return
                end
            elseif sec123 == 2 then
            local ass = select("Hareket Hızı (500)","Saldırı Hızı (200)","Büyü Hızı (1000)","Saldırı Değeri","Max. HP ve HP Üretimi","Yarı İnsan ","Defans","Hiçbiri")
            if ass == 1 then
            chat("Karakterine 7 gün için 500 Hareket Hızı ekledin.")
            affect.add_collect(apply.MOV_SPEED, 500, 60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 2 then
            chat("Karakterine 7 gün için 500 Saldırı Hızı ekledin.")
            affect.add_collect(apply.ATT_SPEED, 200, 60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 3 then
            chat("Karakterine 7 gün için 1000 Büyü Hızı ekledin.")
            affect.add_collect(apply.CAST_SPEED, 1000, 60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 4 then
            chat("Karakterine 7 gün için 2000 Saldırı Değeri ekledin.")
            affect.add_collect(apply.ATT_BONUS,2000,60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 5 then
            chat("Karakterine 7 gün için 20000 HP ve %5000 Hp Üretimi ekledin.")
            affect.add_collect(apply.HP_REGEN, 5000, 60*60*24*7)
            affect.add_collect(apply.MAX_HP, 20000, 60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 6 then
            chat("Karakterine 7 gün için %500 Yarı İnsan ekledin.")
            affect.add_collect(apply.ATTBONUS_HUMAN, 500, 60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 7 then
            chat("Karakterine 7 gün için 500 Defans ekledin.")
            affect.add_collect(apply.DEF_BONUS, 500, 60*60*24*7)
            affect.add_collect(apply.IMMUNE_STUN, 1, 60*60*24*365) ----1 yıl sersemlik -----
            elseif ass == 8 then
            return
            end
        elseif sec123 == 3 then
            local gns = select("Domuzlar","Kurtlar","Kaplanlar","Aslanlar","Geyikler","Arap Atı ","Kapat")
        if gns == 1 then
        say_title("Birini seç. ")
            local gnss = select("Yaban Domuzu","Savaş Yaban Domuzu","Yavru Yaban Domuzu","Vahşi Yaban Domuzu","Cesur Yaban Domuzu","Kapat")
            if gnss == 1 then
                pc.mount(20110, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnss == 2 then
                pc.mount(20115, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnss == 3 then
                pc.mount(20201, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnss == 4 then
                pc.mount(20205, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnss == 5 then
                pc.mount(20209, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnss == 6 then
                return
                
                end
        elseif gns == 2 then
        say_title("Birini seç. ")
            local gnsss = select("Kurt","Kızgın Kurt","Yavru Kurt","Vahşi Kurt","Cesur Kurt","Kapat")
            if gnsss == 1 then
                pc.mount(20111, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsss == 2 then
                pc.mount(20116, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsss == 3 then
                pc.mount(20202, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsss == 4 then
                pc.mount(20206, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsss == 5 then
                pc.mount(20210, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsss == 6 then
                return   
                end
        elseif gns == 3 then
        say_title("Birini seç. ")
            local gnssss = select("Kaplan","Vahşi Kaplan","Yavru Kaplan","Cesur Kaplan","Kral Kaplanları ","Kapat")
            if gnssss == 1 then
                pc.mount(20112, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssss == 2 then
                pc.mount(20117, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssss == 3 then
                pc.mount(20203, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssss == 4 then
                pc.mount(20211, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssss == 5 then
            say_title("Birini seç. ")
                local gnssssa = select("Mavi","Kırmızı ","Altın","Yeşil","Gri","Beyaz","Kapat")
                if gnssssa == 1 then
                    pc.mount(20120, 1800)
                    
                    chat("Binek çağırıldı!")
                elseif gnssssa == 2 then
                    pc.mount(20121, 1800)
                    chat("Binek çağırıldı!")
                    
                elseif gnssssa == 3 then
                    pc.mount(20122, 1800)
                    chat("Binek çağırıldı!")
                    
                elseif gnssssa == 4 then
                    pc.mount(20123, 1800)
                    chat("Binek çağırıldı!")
                    
                elseif gnssssa == 5 then
                    pc.mount(20124, 1800)
                    chat("Binek çağırıldı!")
                    
                elseif gnssssa == 6 then
                    pc.mount(20125, 1800)
                    chat("Binek çağırıldı!")
                    
                elseif gnssssa == 7 then
                    return
                    
                    end
            elseif gnssss == 6 then
                
                return
                end
        elseif gns == 4 then
        say_title("Birini seç. ")
            local gnsssss = select("Aslan","Beyaz Aslan","Yavru Aslan","Vahşi Aslan","Cesur Aslan","Kapat")
            if gnsssss == 1 then
                pc.mount(20113, 1800)
                
                chat("Binek çağırıldı!")
            elseif gnsssss == 2 then
                pc.mount(20118, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsssss == 3 then
                pc.mount(20204, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsssss == 4 then
                pc.mount(20208, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsssss == 5 then
                pc.mount(20212, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnsssss == 6 then
                
                return
                end
        elseif gns == 5 then
        say_title("Birini seç. ")
            local gnssssss = select("Yavru Ren Geyiği(e)","Vahşi Ren Geyiği(e)","Cesur Ren Geyiği(e)","Yavru Ren Geyiği(d)","Vahşi Ren Geyiği(d)","Cesur Ren Geyiği(d)","Kapat")
            if gnssssss == 1 then
                pc.mount(20213, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssssss == 2 then
                pc.mount(20214, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssssss == 3 then
                pc.mount(20215, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssssss == 4 then
                pc.mount(20216, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssssss == 5 then
                pc.mount(20217, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssssss == 6 then
                pc.mount(20218, 1800)
                chat("Binek çağırıldı!")
                
            elseif gnssssss == 7 then
                return
                end
        elseif gns == 6 then
                pc.mount(20119, 1800)
                chat("Binek çağırıldı!")
                
        elseif gns == 7 then
            return
            
            end
        elseif sec123 == 4 then
        __give_empire_priv(0, 1, 250, 60*60*24*7)
        __give_empire_priv(0, 2, 250, 60*60*24*7)
        __give_empire_priv(0, 4, 1000, 60*60*24*7)
        game.set_event_flag("gizemli_sandik",1)
        elseif sec123 == 5 then
        pc.give_item2("89001",1)
        elseif sec123 == 6 then
        clear_server_timer("auto_notice")
        server_loop_timer("auto_notice",1)
        chat("Duyurular zamanı gelince başlayacak. Parşömen dropları zamanı gelince açılacak.")
        elseif sec123 == 7 then
        say_title("Oyuncu banla")
        say("")
        say("Banlanacak oyuncunun adını aşağıdaki kutuya")
        say("yaz.")
        say("")
        local oyuncu = input()
        say_title("Oyuncu banla onay")
        say("")
        say(""..oyuncu.." adlı oyuncuyu banlayacaksın.")
        say("")
        say_reward("Onaylıyor musun?")
        say("")
        local onay = select("Onayla","Vazgeç ")
            if onay == 2 then
            return
            else
            local yonetici = pc.get_name()
            local opp_vid2 = find_pc_by_name(yonetici)
            local opp_vid = find_pc_by_name(oyuncu)
                if opp_vid == 0 then
                say_title("Oyuncu banla")
                say("")
                say("Böyle bir oyuncu yok.")
                say("")
                elseif opp_vid == pc.get_vid() then
                say_title("Oyuncu banla")
                say("")
                say("Kendini banlayamazsın.")
                say("")
                else
                local banlancak = pc.select(opp_vid)
                pc.select(banlancak)
                    if not pc.is_near_vid(opp_vid, 50) then
                    say_title("Oyuncu banla")
                    say("")
                    say("Banlayacağın oyuncu bize yaklaşmalı.")
                    say("")
                    else
                    pc.select(opp_vid)
                    local hesapid = pc.get_account_id()
                    mysql_query10("UPDATE account.account set status = 'BLOCK' where id= "..hesapid.."") ---- Şifre ve ip girecek yerler yanda
                    command("quit")
                    pc.select(opp_vid2)
                    syschat(""..oyuncu.." banlandı.")
                    end
                end
            end
            else
            send_letter("Villa")
            return
                end
                send_letter("Villa")
                end
            
            when kostum_kapat.server_timer begin
                notice_all("Kostüm etkinliği sona erdi!")
                game.set_event_flag("dressup",0)
                clear_server_timer("kostum_kapat")
                end
                
            when ayisik.server_timer begin
                game.set_event_flag("ayisigi",0)
                notice_all("Ayışığı Define Sandığı etkinliği sona erdi.")
                clear_server_timer("ayisik")
                end
            when mistik1.server_timer begin
            game.set_event_flag("esrarengiz_sandik",2)
                    notice_all("Mistik Sandıklarını açmak için gerekli olan anahtarları ")
                    notice_all("elde etmek için düşman krallıkların oyuncularını yen!")
                    notice_all("Kalan Süre: 3 saat")
                    server_timer("mistik2",10800)
                    clear_server_timer("mistik1")
                end
            when mistik2.server_timer begin
            game.set_event_flag("esrarengiz_sandik",0)
            notice_all("Mistik Sandık etkinliği sona erdi.")
            clear_server_timer("mistik2")
                end
            when futboltopu.server_timer begin
            game.set_event_flag("futboltopu",0)
            notice_all("Futbol Topu etkinliği sona erdi.")
            clear_server_timer("futboltopu")
            end
            
            when tabak.server_timer begin
            game.set_event_flag("tabak",0)
            notice_all("Bağış Tabağı etkinliği sona erdi.")
            clear_server_timer("tabak")
            end
            
        when auto_notice.server_timer begin
        local time = os.date("%X")
        local day = os.date("%w")
            if day == "6" and time == "00:00:01" then
            game.set_event_flag("yagma",1)
            end
            if day == "1" and time == "00:00:01" then
            game.set_event_flag("yagma",0)
            end
            if time == "19:00:00" then
            notice_all("Binek Hayvanını ele geçir!")
            game.set_event_flag("gizemli_sandik",0)
            game.set_event_flag("parsomen",1)
            end
            if time == "05:30:00" then
            __give_empire_priv(0, 1, 250, 60*60*24*7)
            __give_empire_priv(0, 2, 250, 60*60*24*7)
            __give_empire_priv(0, 4, 1000, 60*60*24*7)
            end
            if time == "21:00:00" then
            notice_all("Bineğinizi bulmak için yarın tekrar deneyin!")
            game.set_event_flag("gizemli_sandik",1)
            game.set_event_flag("parsomen",0)
            end
            if time == "00:00:00" or time == "04:00:00" or time == "08:00:00" or time == "12:00:00" or time == "16:00:00" or time == "20:00:00" then
            notice_all("Eşya alışverişi yaparken dikkatli olun!")
            os.execute("cd /usr/game && sh yedekle2.sh &")
            end
            if time == "00:00:05" or time == "04:00:05" or time == "08:00:05" or time == "12:00:05" or time == "16:00:05" or time == "20:00:05" then
            notice_all("Sahte hesaplara kanmayın! ")
            end
            if time == "00:00:10" or time == "04:00:10" or time == "08:00:10" or time == "12:00:10" or time == "16:00:10" or time == "20:00:10" then
            notice_all("Hesap bilgilerinizi kimseyle paylaşmayın!")
            end
            if time == "01:00:00" or time == "05:00:00" or time == "09:00:00" or time == "13:00:00" or time == "17:00:00" or time == "21:00:20" then
            notice_all("Nesne marketimizi ziyaret ettiniz mi?")
            os.execute("cd /usr/game && sh yedekle2.sh &")
            end
            if time == "01:00:05" or time == "05:00:05" or time == "09:00:05" or time == "13:00:05" or time == "17:00:05" or time == "21:00:25" then
            notice_all("Muhteşem eşyalar sizleri bekliyor!")
            end
            if time == "01:00:10" or time == "05:00:10" or time == "09:00:10" or time == "13:00:10" or time == "17:00:10" or time == "21:00:30" then
            notice_all("Sitemize girip nesne market resmine tıklayın!")
            end
            if time == "02:00:00" or time == "06:00:00" or time == "10:00:00" or time == "14:00:00" or time == "18:00:00" or time == "22:00:00" then
            notice_all("MetinTwo resmi facebook sayfamız sizlerle!")
            os.execute("cd /usr/game && sh yedekle2.sh &")
            end
            if time == "02:00:05" or time == "06:00:05" or time == "10:00:05" or time == "14:00:05" or time == "18:00:05" or time == "22:00:05" then
            notice_all("http://www.facebook.com/metintwofficial ")
            end
            if time == "02:00:10" or time == "06:00:10" or time == "10:00:10" or time == "14:00:10" or time == "18:00:10" or time == "22:00:10" then
            notice_all("Sayfamızın hayranı ol, paylaşımları kaçırma! ")
            end
            if time == "03:00:00" or time == "07:00:00" or time == "11:00:00" or time == "15:00:00" or time == "19:00:20" or time == "23:00:00" then
            notice_all("MetinTwo resmi forumumuz sizlerle!")
            os.execute("cd /usr/game && sh yedekle2.sh &")
            end
            if time == "03:00:05" or time == "07:00:05" or time == "11:00:05" or time == "15:00:05" or time == "19:00:25" or time == "23:00:05" then
            notice_all("http://board.metintwo.org")
            end
            if time == "03:00:10" or time == "07:00:10" or time == "11:00:10" or time == "15:00:10" or time == "19:00:30" or time == "23:00:10" then
            notice_all("Forumumuza üye ol, güncellemeleri yakından takip et!")
            end
            
            if time == "00:15:00" or time == "01:15:00" or time == "02:15:00" or time == "03:15:00" or time == "04:15:00" or time == "05:15:00" or time == "06:15:00" or time == "07:15:00" or time == "08:15:00" or time == "09:15:00" or time == "10:15:00" or time == "11:15:00" or time == "12:15:00" or time == "13:15:00" or time == "14:15:00" or time == "15:15:00" or time == "16:15:00" or time == "17:15:00" or time == "18:15:00" or time == "19:15:00" or time == "20:15:00" or time == "21:15:00" or time == "22:15:00" or time == "23:15:00" then
            notice_all("Oyunu sorunsuz oynayabilmek için lütfen ek packimizi indirin.")
            end
            
            if time == "00:30:00" or time == "01:30:00" or time == "02:30:00" or time == "03:30:00" or time == "04:30:00" or time == "05:30:00" or time == "06:30:00" or time == "07:30:00" or time == "08:30:00" or time == "09:30:00" or time == "10:30:00" or time == "11:30:00" or time == "12:30:00" or time == "13:30:00" or time == "14:30:00" or time == "15:30:00" or time == "16:30:00" or time == "17:30:00" or time == "18:30:00" or time == "19:30:00" or time == "20:30:00" or time == "21:30:00" or time == "22:30:00" or time == "23:30:00" then
            os.execute("cd /usr/game && sh yedekle2.sh &")
            end
            
            if time == "00:15:05" or time == "01:15:05" or time == "02:15:05" or time == "03:15:05" or time == "04:15:05" or time == "05:15:05" or time == "06:15:05" or time == "07:15:05" or time == "08:15:05" or time == "09:15:05" or time == "10:15:05" or time == "11:15:05" or time == "12:15:05" or time == "13:15:05" or time == "14:15:05" or time == "15:15:05" or time == "16:15:05" or time == "17:15:05" or time == "18:15:05" or time == "19:15:05" or time == "20:15:05" or time == "21:15:05" or time == "22:15:05" or time == "23:15:05" then
            notice_all("Özellikle yeni haritalarda bugda kalmamak için ve")
            end
            
            if time == "00:15:10" or time == "01:15:10" or time == "02:15:10" or time == "03:15:10" or time == "04:15:10" or time == "05:15:10" or time == "06:15:10" or time == "07:15:10" or time == "08:15:10" or time == "09:15:10" or time == "10:15:10" or time == "11:15:10" or time == "12:15:10" or time == "13:15:10" or time == "14:15:10" or time == "15:15:10" or time == "16:15:10" or time == "17:15:10" or time == "18:15:10" or time == "19:15:10" or time == "20:15:10" or time == "21:15:10" or time == "22:15:10" or time == "23:15:10" then
            notice_all("Kostümleri görebilmek için bu uyarımızı dikkate alın!")
            end
        end
            
        when login with pc.is_gm() begin
        chat("MAP İNDEX: "..pc.get_map_index().."")
        chat("CH 1 Ejderha Odası Şifresi: "..game.get_event_flag("ejder_sifresi1").."")
        chat("CH 2 Ejderha Odası Şifresi: "..game.get_event_flag("ejder_sifresi2").."")
        chat("CH 3 Ejderha Odası Şifresi: "..game.get_event_flag("ejder_sifresi3").."")
        chat("CH 4 Ejderha Odası Şifresi: "..game.get_event_flag("ejder_sifresi4").."")
        end
    end
end
 
Çözüm
Kod:
dofile('locale/turkey/quest/questing.lua')
CONFIRM_NO = 0
CONFIRM_YES = 1
CONFIRM_OK = 1
CONFIRM_TIMEOUT = 2

MALE = 0
FEMALE = 1

item3 = {}

newline = "[ENTER]"

function notice_multiline( str , func )
    local p = 0
    local i = 0
    while true do
        i = string.find( str, "%[ENTER%]", i+1 )
        if i == nil then
            if string.len(str) > p then
                func( string.sub( str, p, string.len(str) ) )
            end
            break
        end
        func( string.sub( str, p, i-1 ) )
        p = i + 7
    end
end

function get_biolog_extra_info(mission, extra1)

    local analiza = false        -- Jezeli false to biolog zaczyna sie od badan (30 lv.), jezeli true biolog zaczyna sie od analiz (4 lv.)...
questlib yolla

Kod:
dofile('locale/turkey/quest/questing.lua') 
CONFIRM_NO = 0
CONFIRM_YES = 1
CONFIRM_OK = 1
CONFIRM_TIMEOUT = 2

MALE = 0
FEMALE = 1

item3 = {}

newline = "[ENTER]"

function notice_multiline( str , func )
    local p = 0
    local i = 0
    while true do
        i = string.find( str, "%[ENTER%]", i+1 )
        if i == nil then
            if string.len(str) > p then
                func( string.sub( str, p, string.len(str) ) )
            end
            break
        end
        func( string.sub( str, p, i-1 ) )
        p = i + 7
    end
end

function get_biolog_extra_info(mission, extra1)

    local analiza = false        -- Jezeli false to biolog zaczyna sie od badan (30 lv.), jezeli true biolog zaczyna sie od analiz (4 lv.)
    local drop = true            -- ANALIZA Jezeli false to przedmioty dropia dopuki nie skonczy danej misji, jezeli true to gracz moze miec w EQ tyle sztuk przedmiotu ile musi jeszcze oddac
    local drop2 = false            -- BADANIA Jezeli false to przedmioty dropia dopuki nie skonczy danej misji, jezeli true to gracz moze miec w EQ tyle sztuk przedmiotu ile musi jeszcze oddac
    local reward_in_btn = true        -- ANALIZA Jezeli true to nagrode moze zdobyc poprzez gui, jezeli false to po nagrode trzeba lecieæ do Biologa/Beak-Go
    local beakgo_reward = true        -- BADANIA Jezeli true to trzeba zapierdalac do Beak-Go zeby odebrac nagrode z badan, jezeli false to nagrode dostaniemy po ukonczeniu misji (button lub rozmowa z biologiem)
    -- ALL INFO END

    local info = {
        [1] = {
            ['poziom_misji'] = 4,
            ['id1'] = 50701,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {173},
            ['nagroda_yang'] = 10000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [2] = {
            ['poziom_misji'] = 7,
            ['id1'] = 50702,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {175},
            ['nagroda_yang'] = 15000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [3] = {
            ['poziom_misji'] = 10,
            ['id1'] = 50703,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {177},
            ['nagroda_yang'] = 20000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [4] = {
            ['poziom_misji'] = 15,
            ['id1'] = 50704,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {181},
            ['nagroda_yang'] = 25000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [5] = {
            ['poziom_misji'] = 20,
            ['id1'] = 50705,
            ['cid1'] = 10,
            ['luck'] = 100,
            ['mob_id1'] = {182},
            ['nagroda_yang'] = 30000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [6] = {
            ['poziom_misji'] = 25,
            ['id1'] = 50706,
            ['cid1'] = 10,
            ['luck'] = 100,
            ['mob_id1'] = {183},
            ['nagroda_yang'] = 40000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [7] = {
            ['poziom_misji'] = 30,
            ['id1'] = 30006,
            ['cid1'] = 10,
            ['chance_id1'] = 50,
            ['id2'] = 30220,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {636, 656, 601, 602},
            ['mob_id2'] = {631, 632, 633, 634, 635, 636, 637},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50109},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+10 Hareket Hýzý ",
            ['nagroda_bonus_id'] = {apply.MOV_SPEED},
            ['nagroda_bonus_wartosc'] = {10}
        },
        [8] = {
            ['poziom_misji'] = 40,
            ['id1'] = 30047,
            ['cid1'] = 15,
            ['chance_id1'] = 50,
            ['id2'] = 30221,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {706, 756},
            ['mob_id2'] = {731, 732, 733, 734, 735, 736, 737, 701, 702, 703, 704, 705, 706, 707},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50110},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+5 Saldýrý Hýzý ",
            ['nagroda_bonus_id'] = {apply.ATT_SPEED},
            ['nagroda_bonus_wartosc'] = {5}
        },
        [9] = {
            ['poziom_misji'] = 50,
            ['id1'] = 30015,
            ['cid1'] = 15,
            ['chance_id1'] = 50,
            ['id2'] = 30222,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {1001},
            ['mob_id2'] = {1001, 1002, 1003, 1004},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50111},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+60 Savunma ",
            ['nagroda_bonus_id'] = {apply.DEF_GRADE_BONUS},
            ['nagroda_bonus_wartosc'] = {60}
        },
        [10] = {
            ['poziom_misji'] = 60,
            ['id1'] = 30050,
            ['cid1'] = 20,
            ['chance_id1'] = 50,
            ['id2'] = 30223,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {1107, 1137},
            ['mob_id2'] = {1101, 1102, 1103, 1104, 1105, 1106, 1107},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50112},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+50 Saldýrý Deðeri ",
            ['nagroda_bonus_id'] = {apply.ATT_GRADE_BONUS},
            ['nagroda_bonus_wartosc'] = {50}
        },
        [11] = {
            ['poziom_misji'] = 70,
            ['id1'] = 30165,
            ['cid1'] = 25,
            ['chance_id1'] = 50,
            ['id2'] = 30224,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {2301, 2302, 2303, 2304, 2305, 2311, 2312, 2313, 2314, 2315},
            ['mob_id2'] = {2301, 2302, 2303, 2304, 2305, 2311, 2312, 2313, 2314, 2315},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50113},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+10% Saldýrýlara Karþý Savunma[ENTER]+11% Hareket Hýzý ",
            ['nagroda_bonus_id'] = {POINT_DEF_BONUS, apply.MOV_SPEED},
            ['nagroda_bonus_wartosc'] = {10, 11}
        },
        [12] = {
            ['poziom_misji'] = 80,
            ['id1'] = 30166,
            ['cid1'] = 30,
            ['chance_id1'] = 50,
            ['id2'] = 30225,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {1401, 1402, 1403, 1601, 1602, 1603},
            ['mob_id2'] = {1401, 1402, 1403, 1601, 1602, 1603},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50114},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+6% Saldýrý Hýzý ve [ENTER]+10% Saldýrý Deðeri ",
            ['nagroda_bonus_id'] = {apply.ATT_SPEED, POINT_ATT_BONUS},
            ['nagroda_bonus_wartosc'] = {6, 10}
        },
        [13] = {
            ['poziom_misji'] = 85,
            ['id1'] = 30167,
            ['cid1'] = 40,
            ['chance_id1'] = 50,
            ['id2'] = 30226,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {2311, 2312, 2313, 2314, 2315},
            ['mob_id2'] = {2311, 2312, 2313, 2314, 2315},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50115},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+10% Yarý insan saldýrý hasarý ",
            ['nagroda_bonus_id'] = {apply.ATTBONUS_HUMAN},
            ['nagroda_bonus_wartosc'] = {10}
        },
        [14] = {
            ['poziom_misji'] = 90,
            ['id1'] = 30168,
            ['cid1'] = 50,
            ['chance_id1'] = 1000,        -- tu musi byc 1000, drop z kazdego bossa
            ['id2'] = 30227,
            ['chance_id2'] = 1000,        -- tu musi byc 1000, drop z kazdego bossa
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {691, 792, 791, 1093, 1304, 2091, 2191, 2206, 1901, 3090, 3290, 3590},
            ['mob_id2'] = {1093, 1304, 1901, 3090, 3290, 3590},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50114, 50114},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+8% Yarý insan saldýrý hasarý ",
            ['nagroda_bonus_id'] = {apply.ATTBONUS_HUMAN},
            ['nagroda_bonus_wartosc'] = {8}
        }
    }

    -- info[1]['poziom_misji']

    -- TU JU¯ NIC NIE RUSZAJ!
    if mission == 0 then
        if extra1 == 1 then
            return analiza
        elseif extra1 == 2 then
            if analiza then        -- Jezeli misje zaczynaja sie od analiz
                return info[1]['poziom_misji']
            else
                return info[7]['poziom_misji']
            end
        elseif extra1 == 3 then
            return drop
        elseif extra1 == 4 then
            return drop2
        elseif extra1 == 5 then
            return reward_in_btn
        elseif extra1 == 6 then
            return beakgo_reward
        end
    elseif mission >= 1 and mission <= 14 then
        if extra1 == 1 then
            return info[mission]['poziom_misji']
        elseif extra1 == 2 then
            return info[mission]['id1']
        elseif extra1 == 3 then
            return info[mission]['cid1']
        elseif extra1 == 4 then
            return info[mission]['id2']
        elseif extra1 == 5 then
            return info[mission]['luck']
        elseif extra1 == 6 then
            return info[mission]['wait_time']
        elseif extra1 == 7 then
            return info[mission]['mob_id1']
        elseif extra1 == 8 then
            return info[mission]['mob_id2']
        elseif extra1 == 9 then
            return info[mission]['nagroda_yang']
        elseif extra1 == 10 then
            return info[mission]['nagroda_exp']
        elseif extra1 == 11 then
            return info[mission]['nagroda_itemy']
        elseif extra1 == 12 then
            if mission < 7 then return 0 end
            return info[mission]['nagroda_tekst']
        elseif extra1 == 13 then
            if mission < 7 then return 0 end
            return info[mission]['nagroda_bonus_id']
        elseif extra1 == 14 then
            if mission < 7 then return 0 end
            return info[mission]['nagroda_bonus_wartosc']
        elseif extra1 == 15 then
            if mission < 7 then return 1000 end
            return info[mission]['chance_id1']
        elseif extra1 == 16 then
            if mission < 7 then return 1000 end
            return info[mission]['chance_id2']
        end
    end
end

function SET_ACTUAL_BIOLOG_MISSION(misja)
    pc.setqf("misja_biolog", misja)
end

function GET_ACTUAL_BIOLOG_MISSION()
    return pc.getqf("misja_biolog")
end

function give_biolog_item(mission, opcja)
    -- 1 -> Oddawanie normalne, klikniecie na biologa            ANALIZA
    -- 2 -> Oddawanie poprzez button                            ANALIZA
    -- 3 -> Oddanie poprzez klikniecie na biologa                BADANIA
    -- 4 -> Oddanie poprzez button                                BADANIA
    -- 5 -> Oddanie kamienia, poprzez klikniecie na biologa        BADANIA
    -- 6 -> Oddanie kamienia, poprzez button                    BADANIA
    if opcja == 1 then
        say_title(mob_name(npc.get_race())..":[ENTER]")
        if pc.getqf("oddane") >= get_biolog_extra_info(mission, 3) then
            say_green("Gerekli sayýda ürünü zaten aldýnýz.")
            say()
            say_title("Ödülün:")
            biolog_nagroda(mission, false)
            cmdchat("bstatus 0")
            pc.setqf("oddane", 0)
            pc.setqf("czas_ponownie", 0)
            return 1
        end
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            say("Kazandýðýný görüyorum "..item_name(get_biolog_extra_info(mission, 2)).."!")
            say("Bir bakmama izin ver...")
            say()
            wait()
            say_title(mob_name(npc.get_race())..":[ENTER]")
            --say("[DELAY value;300]. . .[/DELAY]")
            if number(1, 100) > get_biolog_extra_info(mission, 5) then
                say_red("Özür dilerim!")
                say("Bu ürün benim araþtýrmam")
                say("için uygun deðil.")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            say("Tebrikler.")
            say("Baþarýyla teslim edildi.")
            pc.remove_item(get_biolog_extra_info(mission, 2), 1)
            say()
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                say_title("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                say("Gerekli sayýda nesneyi zaten aldýnýz.")
                say_title("Ödülün:")
                biolog_nagroda(mission, false)
                cmdchat("bstatus 0")
                pc.setqf("oddane", 0)
                pc.setqf("czas_ponownie", 0)
                return 1
            end
            say()
        else
            say("Bunu topladýðýn zaman bana dön")
            say(item_name(get_biolog_extra_info(mission, 2))..".")
            say_item(item_name(get_biolog_extra_info(mission, 2)), get_biolog_extra_info(mission, 2), item_name(get_biolog_extra_info(mission, 2)))
            say("Bu nesneyi aþaðýdaki canavarlardan toplayabilirsin.")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
            say()
        end
    elseif opcja == 2 then
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            if pc.getqf("oddane") >= get_biolog_extra_info(mission, 3) and get_biolog_extra_info(0, 5) == false then
                return chat("Zaten tüm öðeleri verdiniz, ödülü almak için Biyolog'a gidin.")
            end
            if number(1, 100) > get_biolog_extra_info(mission, 5) and pc.getqf("oddane") < get_biolog_extra_info(mission, 3) then
                chat("Bu amaç biyolog araþtýrmasý için uygun deðildir.")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                chat("Bu nesne çok iyi kalitedeydi!!")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                chat("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") >= get_biolog_extra_info(mission, 3) then
                if pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                    chat("Bu nesne çok iyi kalitedeydi!!")
                    pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                end
                chat("Gerekli sayýda nesneyi zaten aldýnýz.")
                if get_biolog_extra_info(0, 5) then
                    --chat("Ödülün:")
                    set_biolog_info_gui(mission, 0, 0, 0)
                    biolog_nagroda(mission, true)
                    cmdchat("bstatus 0")
                    pc.setqf("oddane", 0)
                    pc.setqf("czas_ponownie", 0)
                    return 1
                else
                    set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
                    chat("Ödülü toplamak için biyologa gidin!")
                    return 0
                end
            end
        else
            chat("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 2)))
            chat("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    chat("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
        end
    elseif opcja == 3 then
        say_title(mob_name(npc.get_race())..":[ENTER]")
        if pc.getqf("czas_ponownie")-get_time() > 0 and not pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            say("Öðeyi henüz veremezsiniz.")
            say("Dolmasý gereken süre: "..minuty.." dakika "..sekundy.." saniye")
            return
        elseif pc.getqf("czas_ponownie")-get_time() > 0 and pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            say("Öðeyi verebilirsin, çünkü sen GM'sin! ")
            say("Normalde beklemek zorunda kalacaksýn:: "..minuty.."m. "..sekundy.."s.")
        end
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            say("Kazandýðýný görüyorum "..item_name(get_biolog_extra_info(mission, 2)).."!")
            say("Bir bakmama izin ver...")
            say()
            wait()
            say_title(mob_name(npc.get_race())..":[ENTER]")
            --say("[DELAY value;300]. . .[/DELAY]")
            if number(1, 100) > get_biolog_extra_info(mission, 5) then
                say_red("Özür dilerim!")
                say("Bu ürün benim araþtýrmam")
                say("için uygun deðil.")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            say_green("Tebrikler.")
            say("Baþarýyla teslim edildi.")
            pc.remove_item(get_biolog_extra_info(mission, 2), 1)
            say()
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                say_title("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                pc.setqf("czas_ponownie", get_time()+get_biolog_extra_info(mission, 6))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                wait()
                say_title(mob_name(npc.get_race())..":[ENTER]")
                say_size(300, 400)
                say_green("Gerekli miktarý zaten kazandýnýz.")
                say()
                say("Araþtýrmamý bitirmek için")
                say("bir daha öðeye ihtiyacý var ...")
                say_item(item_name(get_biolog_extra_info(mission, 4)), get_biolog_extra_info(mission, 4), item_name(get_biolog_extra_info(mission, 4)))
                say("Bunu elde etmek için savaþacaðýn canavarlar:")
                for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                    if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                        say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                        break
                    end
                    if i == table.getn(get_biolog_extra_info(mission, 8)) then
                        say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                    else
                        say_reward("- "..mob_name(get_mob_id(mission, i, 1))..",")
                    end
                end
                say()
                cmdchat("bstatus 1")
                pc.setqf("oddane", 0)
                pc.setqf("czas_ponownie", 0)
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 1)
                return 1
            end
            say()
        else
            say("Bunu topladýðýn zaman bana dön")
            say(item_name(get_biolog_extra_info(mission, 2))..".")
            say_item(item_name(get_biolog_extra_info(mission, 2)), get_biolog_extra_info(mission, 2), item_name(get_biolog_extra_info(mission, 2)))
            say("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
            say()
        end
    elseif opcja == 4 then
        if pc.getqf("czas_ponownie")-get_time() > 0 and not pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            chat("Öðeyi henüz veremezsiniz.")
            chat("Dolmasý gereken zaman: "..minuty.." dakika "..sekundy.." saniye")
            return
        elseif pc.getqf("czas_ponownie")-get_time() > 0 and pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            chat("Öðeyi verebilirsin, çünkü sen GM'sin! ")
            chat("Normalde beklemek zorunda kalacaksýn:: "..minuty.." dakika "..sekundy.." saniye")
        end
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            if number(1, 100) > get_biolog_extra_info(mission, 5) then
                chat("Bu ürün benim araþtýrmamdo badañ biologa!")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            chat("Baþarýyla teslim edildi.")
            pc.remove_item(get_biolog_extra_info(mission, 2), 1)
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                chat("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                pc.setqf("czas_ponownie", get_time()+get_biolog_extra_info(mission, 6))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                syschat("Gerekli miktarý zaten kazandýnýz.")
                chat("Araþtýrmayý tamamlamak için biyologun ")
                chat("bir daha öðeye ihtiyacý var ...")
                chat(item_name(get_biolog_extra_info(mission, 4)))
                chat("Bunu elde etmek için savaþacaðýn canavarlar:")
                for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                    if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                        chat("- "..mob_name(get_mob_id(mission, i, 1)))
                        break
                    end
                    if i == table.getn(get_biolog_extra_info(mission, 8)) then
                        chat("- "..mob_name(get_mob_id(mission, i, 1)))
                    else
                        chat("- "..mob_name(get_mob_id(mission, i, 1))..",")
                    end
                end
                cmdchat("bstatus 1")
                pc.setqf("oddane", 0)
                pc.setqf("czas_ponownie", 0)
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 1)
                return 1
            end
        else
            chat("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 2))..".")
            chat("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    chat("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
        end
    elseif opcja == 5 then
        say_title(mob_name(npc.get_race())..":[ENTER]")
        if pc.count_item(get_biolog_extra_info(mission, 4)) < 1 then
            say_red("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 4))..".")
            say()
            say_item(item_name(get_biolog_extra_info(mission, 4)), get_biolog_extra_info(mission, 4), item_name(get_biolog_extra_info(mission, 4)))
            say()
            say_title("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 8)) then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                else
                    say_reward("- "..mob_name(get_mob_id(mission, i, 1))..",")
                end
            end
            say()
        else
            say_green("Harika, buldun!")
            pc.remove_item(get_biolog_extra_info(mission, 4), 1)
            say("Çok teþekkür ederim!")
            say("Sýký çalýþmanýz karþýlýðýnda")
            say("bir ödül alacaksýnýz.")
            if get_biolog_extra_info(0, 6) then
                say("Ödül için bu görevliyi bul,")
                say_zloto("Beak-Go.")
                say()
                return 1
            else
                biolog_nagroda(mission, false)
                return 2
            end
        end
    elseif opcja == 6 then
        if pc.count_item(get_biolog_extra_info(mission, 4)) < 1 then
            chat("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 4))..".")
            chat("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                    syschat("- "..mob_name(get_mob_id(mission, i, 1)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 8)) then
                    syschat("- "..mob_name(get_mob_id(mission, i, 1)))
                else
                    syschat("- "..mob_name(get_mob_id(mission, i, 1))..",")
                end
            end
        else
            pc.remove_item(get_biolog_extra_info(mission, 4), 1)
            chat("Taþ verdin..")
            if get_biolog_extra_info(0, 6) then
                chat("Ödülden sonra Beak-Go'ya gidin.")
                return 1
            else
                biolog_nagroda(mission, true)
                return 2
            end
        end
    end
    return 0
end

function biolog_nagroda(mission, is_btn)
    -- Odbior nagrody od biologa lub od Beak-Go
    -- Yang, exp, przedmioty dla danej postaci, przedmioty dla wszystkich, bonusy
    if is_btn then
        if get_biolog_extra_info(mission, 9) > 0 then
            --chat(get_biolog_extra_info(mission, 9).." Yang")
            pc.change_money(get_biolog_extra_info(mission, 9))
        end
        if get_biolog_extra_info(mission, 10) > 0 then
            chat(get_biolog_extra_info(mission, 10).." Tecrübe")
            pc.give_exp2(get_biolog_extra_info(mission, 10))
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[pc.get_job()]) do
            if get_biolog_extra_info(mission, 11)[pc.get_job()][1] == 0 then break end
            --chat("- "..item_name(get_biolog_extra_info(mission, 11)[pc.get_job()][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[pc.get_job()][i], 1)
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[4]) do
            if get_biolog_extra_info(mission, 11)[4][1] == 0 then break end
            --chat("- "..item_name(get_biolog_extra_info(mission, 11)[4][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[4][i], 1)
        end
        if type(get_biolog_extra_info(mission, 13)) == "table" then
            chat(get_biolog_extra_info(mission, 12))
            for i = 1, table.getn(get_biolog_extra_info(mission, 13)) do
                affect.add_collect(get_biolog_extra_info(mission, 13)[i], get_biolog_extra_info(mission, 14)[i], 60*60*24*365*60)
            end
        end
    else
        if get_biolog_extra_info(mission, 9) > 0 then
            say_reward(get_biolog_extra_info(mission, 9).." Yang")
            pc.change_money(get_biolog_extra_info(mission, 9))
        end
        if get_biolog_extra_info(mission, 10) > 0 then
            say_reward(get_biolog_extra_info(mission, 10).." Tecrübe")
            pc.give_exp2(get_biolog_extra_info(mission, 10))
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[pc.get_job()]) do
            if get_biolog_extra_info(mission, 11)[pc.get_job()][1] == 0 then break end
            say_reward("- "..item_name(get_biolog_extra_info(mission, 11)[pc.get_job()][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[pc.get_job()][i], 1)
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[4]) do
            if get_biolog_extra_info(mission, 11)[4][1] == 0 then break end
            say_reward("- "..item_name(get_biolog_extra_info(mission, 11)[4][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[4][i], 1)
        end
        if type(get_biolog_extra_info(mission, 13)) == "table" then
            say_reward(get_biolog_extra_info(mission, 12))
            for i = 1, table.getn(get_biolog_extra_info(mission, 13)) do
                affect.add_collect(get_biolog_extra_info(mission, 13)[i], get_biolog_extra_info(mission, 14)[i], 60*60*24*365*60)
            end
        end
    end
end

function get_mob_id(mission, ktory, submission)
    local rekord = 7
    if submission == 1 then rekord = 8 end
    if type(get_biolog_extra_info(mission, rekord)) == "table" then
        if ktory <= 0 or ktory > table.getn(get_biolog_extra_info(mission, rekord)) then ktory = 1 end
        return get_biolog_extra_info(mission, rekord)[ktory]
    else
        return get_biolog_extra_info(mission, rekord)
    end
end

function is_biolog_mission_mob(mission, vnum, submission)
    local rekord = 7
    if submission == 1 then rekord = 8 end
    if type(get_biolog_extra_info(mission, rekord)) == "table" then
        for i = 1, table.getn(get_biolog_extra_info(mission, rekord)) do
            if get_biolog_extra_info(mission, rekord)[i] == vnum then
                return true
            end
        end
    else
        if vnum == get_biolog_extra_info(mission, rekord) then
            return true
        end
    end
    return false
end

function set_biolog_info_gui(mission, ile_oddalem, ile_jeszcze_czasu, submission)
    cmdchat("bstatus 1")
    if submission == 1 then
        cmdchat("btext txt1 "..ile_oddalem.."/1")
    else
        cmdchat("btext txt1 "..ile_oddalem.."/"..get_biolog_extra_info(mission, 3))
    end
    cmdchat("btext txt2 "..get_biolog_extra_info(mission, 5).."%")
    if ile_jeszcze_czasu < 0 then ile_jeszcze_czasu = 0 end
    cmdchat("btext txt3 "..ile_jeszcze_czasu)
    if mission >= 1 and mission <= 6 then
        cmdchat("btext name Biyolog_Analizi_"..mission)
    else
        cmdchat("btext name Biyolog_Araþtýrmasý_"..mission)
    end
    local rekord = 7
    if submission == 1 then rekord = 8 end
    local opis = ""
    for i = 1, table.getn(get_biolog_extra_info(mission, rekord)) do
        if table.getn(get_biolog_extra_info(mission, rekord)) == 1 then
            opis = "Bunlarý yok et!_"..mob_name(get_mob_id(mission, i, submission))
            break
        end
        if i == 1 then
            opis = "Bunlarý yok et!_"..mob_name(get_mob_id(mission, i, submission))
        else
            opis = opis..","..mob_name(get_mob_id(mission, i, submission))
        end
    end
    opis = string.sub(string.gsub(opis.." ", " ", "_"), 0, string.len(string.gsub(opis.." ", " ", "_")))
    if submission == 1 then        -- jezeli ma przyniesc kamien
        cmdchat("bitem "..get_biolog_extra_info(mission, 4))
    else
        cmdchat("bitem "..get_biolog_extra_info(mission, 2))
    end
end

function biolog_inputek(inputeczek)
    cmdchat("getBiologinputbegin")
    local ret = input(cmdchat(inputeczek))
    cmdchat("getBiologinputend")
    return ret
end

function get_today_count(questname, flag_name)
    local today = math.floor(get_global_time() / 86400)
    local today_flag = flag_name.."_today"
    local today_count_flag = flag_name.."_today_count"
    local last_day = pc.getf(questname, today_flag)
    if last_day == today then
        return pc.getf(questname, today_count_flag)
    else
        return 0
    end
end
-- "$flag_name"_today unix_timestamp % 86400
-- "$flag_name"_count count
function inc_today_count(questname, flag_name, count)
    local today = math.floor(get_global_time() / 86400)
    local today_flag = flag_name.."_today"
    local today_count_flag = flag_name.."_today_count"
    local last_day = pc.getqf(questname, today_flag)
    if last_day == today then
        pc.setf(questname, today_count_flag, pc.getf(questname, today_count_flag) + 1)
    else
        pc.setf(questname, today_flag, today)
        pc.setf(questname, today_count_flag, 1)
    end
end

-- This function will return true always in window os,
--  but not in freebsd.
-- (In window os, RAND_MAX = 0x7FFF = 32767.)
function drop_gamble_with_flag(drop_flag)
        local dp, range = pc.get_killee_drop_pct()
        dp = 40000 * dp / game.get_event_flag(drop_flag)
        if dp < 0 or range < 0 then
            return false
        end
        return dp >= number(1, range)
end

function split(str, delim, maxNb)
    if str == nil then return str end
    if string.find(str, delim) == nil then return { str } end
    if maxNb == nil or maxNb < 1 then maxNb = 0 end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end
    return result
end

mysql_query = function(query)
    local version = 55
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    if version == 51 then
        os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi)
    elseif version == 55 then
        os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi)
    else
        return 0
    end
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber(b) or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber(b) or b or 'NULL'
    end) end
    out.__lines = t[1]
    return out
end

function item3.get_attr(var)
 return item.get_attr_type(var),item.get_attr_value(var)
end

guildstorage_path = "locale/turkey/quest/sancak/sistemler/"

function getinput(par)
    cmdchat("getinputbegin")
    local ret = input(cmdchat(par))
    cmdchat("getinputend")
    return ret
end

--quest.create = function(f) return coroutine.create(f) end
--quest.process = function(co,args) return coroutine.resume(co, args) end
setstate = q.setstate
newstate = q.setstate

q.set_clock = function(name, value) q.set_clock_name(name) q.set_clock_value(value) end
q.set_counter = function(name, value) q.set_counter_name(name) q.set_counter_value(value) end
c_item_name = function(vnum) return ("[ITEM value;"..vnum.."]") end
c_mob_name = function(vnum) return ("[MOB value;"..vnum.."]") end

-- d.set_folder = function (path) raw_script("[SET_PATH path;"..path.."]") end
-- d.set_folder = function (path) path.show_cinematic("[SET_PATH path;"..path.."]") end
-- party.run_cinematic = function (path) party.show_cinematic("[RUN_CINEMATIC value;"..path.."]") end

newline = "[ENTER]"
function color256(r, g, b) return "[COLOR r;"..(r/255.0).."|g;"..(g/255.0).."|b;"..(b/255.0).."]" end
function color(r,g,b) return "[COLOR r;"..r.."|g;"..g.."|b;"..b.."]" end
function delay(v) return "[DELAY value;"..v.."]" end
function setcolor(r,g,b) raw_script(color(r,g,b)) end
function setdelay(v) raw_script(delay(v)) end
function resetcolor(r,g,b) raw_script("[/COLOR]") end
function resetdelay(v) raw_script("[/DELAY]") end
function say_blue(name) say(color256(0, 0, 255)..name..color256(0, 0, 255)) end
function say_red(name) say(color256(255, 0, 0)..name..color256(255, 0, 0)) end
function say_green(name) say(color256(0, 238, 0)..name..color256(0, 238, 0)) end
function say_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end
function say_black(name) say(color256(0, 0, 0)..name..color256(0, 0, 0)) end
function say_white(name) say(color256(255, 255, 255)..name..color256(255, 255, 255)) end
function say_yellow(name) say(color256(255, 255, 0)..name..color256(255, 255, 0)) end
function say_blue2(name) say(color256(0, 206, 209)..name..color256(0, 206, 209)) end
function chat_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end

function say_light_yellow(name) say(color256(255,255,128)..name..color256(196, 196, 196)) end
function say_orange(name) say(color256(255,191,24)..name..color256(196, 196, 196)) end
function say_light_blue(name) say(color256(130, 192, 255)..name..color256(196, 196, 196)) end

-- minimap? ???? ??
function addmapsignal(x,y) raw_script("[ADDMAPSIGNAL x;"..x.."|y;"..y.."]") end

-- minimap ????? ?? ???
function clearmapsignal() raw_script("[CLEARMAPSIGNAL]") end

-- ??????? ??? ??? ?? ??? ???.
function setbgimage(src) raw_script("[BGIMAGE src;") raw_script(src) raw_script("]") end

-- ???? ???? ????.
function addimage(x,y,src) raw_script("[IMAGE x;"..x.."|y;"..y) raw_script("|src;") raw_script(src) raw_script("]") end

function makequestbutton(name)
    raw_script("[QUESTBUTTON idx;")
    raw_script(""..q.getcurrentquestindex())
    raw_script("|name;")
    raw_script(name) raw_script("]")
end

function make_quest_button_ex(name, icon_type, icon_name)
    test_chat(icon_type)
    test_chat(icon_name)
    raw_script("[QUESTBUTTON idx;")
    raw_script(""..q.getcurrentquestindex())
    raw_script("|name;")
    raw_script(name)
    raw_script("|icon_type;")
    raw_script(icon_type)
    raw_script("|icon_name;")
    raw_script(icon_name)
    raw_script("]")
end

function make_quest_button(name) makequestbutton(name) end

function send_letter_ex(name, icon_type, icon_name) make_quest_button_ex(name, icon_type, icon_name) set_skin(NOWINDOW) q.set_title(name) q.start() end

function send_letter(name) makequestbutton(name) set_skin(NOWINDOW) q.set_title(name) q.start() end
function clear_letter() q.done() end
function say_title(name) say(color256(255, 230, 186)..name..color256(196, 196, 196)) end
function say_reward(name) say(color256(255, 200, 200)..name..color256(196, 196, 196)) end
function say_blue(name) say(color256(0, 0, 255)..name..color256(0, 0, 255)) end
function say_red(name) say(color256(255, 0, 0)..name..color256(255, 0, 0)) end
function say_green(name) say(color256(0, 238, 0)..name..color256(0, 238, 0)) end
function say_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end
function say_black(name) say(color256(0, 0, 0)..name..color256(0, 0, 0)) end
function say_white(name) say(color256(255, 255, 255)..name..color256(255, 255, 255)) end
function say_yellow(name) say(color256(255, 255, 0)..name..color256(255, 255, 0)) end
function say_blue2(name) say(color256(0, 206, 209)..name..color256(0, 206, 209)) end
function chat_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end

function say_light_yellow(name) say(color256(255,255,128)..name..color256(196, 196, 196)) end
function say_yellow(name) say(color256(255,255,53)..name..color256(196, 196, 196)) end
function say_orange(name) say(color256(255,191,24)..name..color256(196, 196, 196)) end
function say_light_blue(name) say(color256(130, 192, 255)..name..color256(196, 196, 196)) end
function say_red(name) say(color256(139, 35, 35)..name..color256(196, 196, 196)) end

function say_kingdom_red(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end
function say_kingdom_yellow(name) say(color256(255, 215, 0)..name..color256(196, 196, 196)) end
function say_kingdom_blue(name) say(color256(16, 78, 139)..name..color256(196, 196, 196)) end

function say_alert(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end

function say_gm(name) say(color256(238, 201, 0)..name..color256(196, 196, 196)) end
function say_gm_title(name) say(color256(238, 118, 0)..name..color256(196, 196, 196)) end

function say_help_title(name) say(color256(238, 118, 0)..name..color256(196, 196, 196)) end
function say_help(name) say(color256(139, 35, 35)..name..color256(196, 196, 196)) end
function say_help_red(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end

function say_event_title(name) say(color256(238, 118, 0)..name..color256(196, 196, 196)) end
function say_event(name) say(color256(139, 35, 35)..name..color256(196, 196, 196)) end
function say_event_red(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end
function say_pc_name() say(pc.get_name()..":") end
function say_size(width, height) say("[WINDOW_SIZE width;"..width.."|height;"..height.."]") end
function setmapcenterposition(x,y)
    raw_script("[SETCMAPPOS x;")
    raw_script(x.."|y;")
    raw_script(y.."]")
end
function say_item(name, vnum, desc)
    say("[INSERT_IMAGE image_type;item|idx;"..vnum.."|title;"..name.."|desc;"..desc.."|index;".. 0 .."|total;".. 1 .."]")
end
function say_item_vnum(vnum)
    say_item(item_name(vnum), vnum, "")
end

function pc_is_novice()
    if pc.get_skill_group()==0 then
        return true
    else
        return false
    end
end
function pc_get_exp_bonus(exp, text)
    say_reward(text)
    pc.give_exp2(exp)
    set_quest_state("levelup", "run")
end
function pc_get_village_map_index(index)
    return village_map[pc.get_empire()][index]
end

village_map = {
    {1, 3},
    {21, 23},
    {41, 43},
}

function npc_is_same_empire()
    if pc.get_empire()==npc.empire then
        return true
    else
        return false
    end
end

function npc_get_skill_teacher_race(pc_empire, pc_job, sub_job)
    if 1==sub_job then
        if 0==pc_job then
            return WARRIOR1_NPC_LIST[pc_empire]
        elseif 1==pc_job then
            return ASSASSIN1_NPC_LIST[pc_empire]
        elseif 2==pc_job then
            return SURA1_NPC_LIST[pc_empire]
        elseif 3==pc_job then
            return SHAMAN1_NPC_LIST[pc_empire]
        end   
    elseif 2==sub_job then
        if 0==pc_job then
            return WARRIOR2_NPC_LIST[pc_empire]
        elseif 1==pc_job then
            return ASSASSIN2_NPC_LIST[pc_empire]
        elseif 2==pc_job then
            return SURA2_NPC_LIST[pc_empire]
        elseif 3==pc_job then
            return SHAMAN2_NPC_LIST[pc_empire]
        end   
    end

    return 0
end


function pc_find_square_guard_vid()
    if pc.get_empire()==1 then
        return find_npc_by_vnum(11000)
    elseif pc.get_empire()==2 then
        return find_npc_by_vnum(11002)
    elseif pc.get_empire()==3 then
        return find_npc_by_vnum(11004)
    end
    return 0
end

function pc_find_skill_teacher_vid(sub_job)
    local vnum=npc_get_skill_teacher_race(pc.get_empire(), pc.get_job(), sub_job)
    return find_npc_by_vnum(vnum)
end

function pc_find_square_guard_vid()
    local pc_empire=pc.get_empire()
    if pc_empire==1 then
        return find_npc_by_vnum(11000)
    elseif pc_empire==2 then
        return find_npc_by_vnum(11002)
    elseif pc_empire==3 then
        return find_npc_by_vnum(11004)
    end
end

function npc_is_same_job()
    local pc_job=pc.get_job()
    local npc_vnum=npc.get_race()

    -- test_chat("pc.job:"..pc.get_job())
    -- test_chat("npc_race:"..npc.get_race())
    -- test_chat("pc.skill_group:"..pc.get_skill_group())
    if pc_job==0 then
        if table_is_in(WARRIOR1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(WARRIOR2_NPC_LIST, npc_vnum) then return true end
    elseif pc_job==1 then
        if table_is_in(ASSASSIN1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(ASSASSIN2_NPC_LIST, npc_vnum) then return true end
    elseif pc_job==2 then
        if table_is_in(SURA1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(SURA2_NPC_LIST, npc_vnum) then return true end
    elseif pc_job==3 then
        if table_is_in(SHAMAN1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(SHAMAN2_NPC_LIST, npc_vnum) then return true end
    end

    return false
end

function npc_get_job()
    local npc_vnum=npc.get_race()

    if table_is_in(WARRIOR1_NPC_LIST, npc_vnum) then return COND_WARRIOR_1 end
    if table_is_in(WARRIOR2_NPC_LIST, npc_vnum) then return COND_WARRIOR_2 end
    if table_is_in(ASSASSIN1_NPC_LIST, npc_vnum) then return COND_ASSASSIN_1 end
    if table_is_in(ASSASSIN2_NPC_LIST, npc_vnum) then return COND_ASSASSIN_2 end
    if table_is_in(SURA1_NPC_LIST, npc_vnum) then return COND_SURA_1 end
    if table_is_in(SURA2_NPC_LIST, npc_vnum) then return COND_SURA_2 end
    if table_is_in(SHAMAN1_NPC_LIST, npc_vnum) then return COND_SHAMAN_1 end
    if table_is_in(SHAMAN2_NPC_LIST, npc_vnum) then return COND_SHAMAN_2 end
    return 0

end

function time_min_to_sec(value)
    return 60*value
end

function time_hour_to_sec(value)
    return 3600*value
end

function next_time_set(value, test_value)
    local nextTime=get_time()+value
    if is_test_server() then
        nextTime=get_time()+test_value
    end
    pc.setqf("__NEXT_TIME__", nextTime)
end

function next_time_is_now(value)
    if get_time()>=pc.getqf("__NEXT_TIME__") then
        return true
    else
        return false
    end
end

function table_get_random_item(self)
    return self[number(1, table.getn(self))]
end

function table_is_in(self, test)
    for i = 1, table.getn(self) do
        if self[i]==test then
            return true
        end
    end
    return false
end


function giveup_quest_menu(title)
    local s=select("????", "????")
    if 2==s then
    say(title.." ???? ???")
    say("?????????")
    local s=select("?, ?????", "????")
    if 1==s then
        say(title.."???? ??????")
        restart_quest()
    end
    end
end

function restart_quest()
    set_state("start")
    q.done()
end

function complete_quest()
    set_state("__COMPLETE__")
    q.done()
end

function giveup_quest()
    set_state("__GIVEUP__")
    q.done()
end

function complete_quest_state(state_name)
    set_state(state_name)
    q.done()
end

function test_chat(log)
    if is_test_server() then
        chat(log)
    end
end

function bool_to_str(is)
    if is then
        return "true"
    else
        return "false"
    end
end

WARRIOR1_NPC_LIST     = {20300, 20320, 20340, }
WARRIOR2_NPC_LIST     = {20301, 20321, 20341, }
ASSASSIN1_NPC_LIST     = {20302, 20322, 20342, }
ASSASSIN2_NPC_LIST     = {20303, 20323, 20343, }
SURA1_NPC_LIST         = {20304, 20324, 20344, }
SURA2_NPC_LIST         = {20305, 20325, 20345, }
SHAMAN1_NPC_LIST     = {20306, 20326, 20346, }
SHAMAN2_NPC_LIST     = {20307, 20327, 20347, }

function skill_group_dialog(e, j, g) -- e = ??, j = ??, g = ??
    e = 1 -- XXX ???? ???? ??? ??? ?????
    

    -- ?? ????? ?? ??? ??
    if pc.job != j then
        say(locale.skill_group.dialog[e][pc.job][3])
    elseif pc.get_skill_group() == 0 then
        if pc.level < 5 then
            say(locale.skill_group.dialog[e][j][g][1])
            return
        end
        say(locale.skill_group.dialog[e][j][g][2])
        local answer = select(locale.yes, locale.no)

        if answer == 1 then
            --say(locale.skill_group.dialog[e][j][g][2])
            pc.set_skill_group(g)
        else
            --say(locale.skill_group.dialog[e][j][g][3])
        end
    --elseif pc.get_skill_group() == g then
        --say(locale.skill_group.dialog[e][j][g][4])
    --else
        --say(locale.skill_group.dialog[e][j][g][5])
    end
end

function show_horse_menu()
    if horse.is_mine() then           
        say(locale.horse_menu.menu)

        local s = 0
        if horse.is_dead() then
            s = select(locale.horse_menu.revive, locale.horse_menu.ride, locale.horse_menu.unsummon, locale.horse_menu.show_state ,locale.horse_menu.close)
        else
            s = select(locale.horse_menu.feed, locale.horse_menu.ride, locale.horse_menu.unsummon,  locale.horse_menu.show_state ,locale.horse_menu.close)
        end

        if s==1 then
            if horse.is_dead() then
                horse.revive()
            else
                local food = horse.get_grade() + 50054 - 1
                if pc.countitem(food) > 0 then
                pc.removeitem(food, 1)
                horse.feed()
                else
                say(locale.need_item_prefix..item_name(food)..locale.need_item_postfix);
                end
            end
        elseif s==2 then
            horse.ride()
        elseif s==3 then
            horse.unsummon()
        elseif s==4 then
            say("?? ????: "..horse.get_health_pct().."%")
            say("?? ???@?: "..horse.get_stamina_pct().."%")
            say("")
        elseif s==5 then                                                     
            -- do nothing
        end
    end
end

npc_index_table = {
    ['race'] = npc.getrace,
    ['empire'] = npc.get_empire,
}

pc_index_table = {
    ['weapon']        = pc.getweapon,
    ['level']        = pc.get_level,
    ['hp']        = pc.gethp,
    ['maxhp']        = pc.getmaxhp,
    ['sp']        = pc.getsp,
    ['maxsp']        = pc.getmaxsp,
    ['exp']        = pc.get_exp,
    ['nextexp']        = pc.get_next_exp,
    ['job']        = pc.get_job,
    ['money']        = pc.getmoney,
    ['gold']         = pc.getmoney,
    ['name']         = pc.getname,
    ['playtime']     = pc.getplaytime,
    ['leadership']     = pc.getleadership,
    ['empire']         = pc.getempire,
    ['skillgroup']     = pc.get_skill_group,
    ['x']         = pc.getx,
    ['y']         = pc.gety,
    ['local_x']     = pc.get_local_x,
    ['local_y']     = pc.get_local_y,
}

item_index_table = {
    ['vnum']        = item.get_vnum,
    ['name']        = item.get_name,
    ['size']        = item.get_size,
    ['count']        = item.get_count,
    ['type']        = item.get_type,
    ['sub_type']    = item.get_sub_type,
    ['refine_vnum']    = item.get_refine_vnum,
    ['level']        = item.get_level,
}

guild_war_bet_price_table =
{
    10000,
    30000,
    50000,
    100000
}

function npc_index(t,i)
    local npit = npc_index_table
    if npit[i] then
    return npit[i]()
    else
    return rawget(t,i)
    end
end

function pc_index(t,i)
    local pit = pc_index_table
    if pit[i] then
    return pit[i]()
    else
    return rawget(t,i)
    end
end

function item_index(t, i)
    local iit = item_index_table
    if iit[i] then
    return iit[i]()
    else
    return rawget(t, i)
    end
end

setmetatable(pc,{__index=pc_index})
setmetatable(npc,{__index=npc_index})
setmetatable(item,{__index=item_index})

--coroutine? ??? ??? ??
function select(...)
    return q.yield('select', arg)
end

function select_table(table)
    return q.yield('select', table)
end

-- coroutine? ??? ?? ?? ????
function wait()
    q.yield('wait')
end

function input()
    return q.yield('input')
end

function confirm(vid, msg, timeout)
    return q.yield('confirm', vid, msg, timeout)
end

function select_item()
    setskin(NOWINDOW)
    return q.yield('select_item')
end

--?? ?? ??? ??? ??
NOWINDOW = 0
NORMAL = 1
CINEMATIC = 2
SCROLL = 3

WARRIOR = 0
ASSASSIN = 1
SURA = 2
SHAMAN = 3

COND_WARRIOR_0 = 8
COND_WARRIOR_1 = 16
COND_WARRIOR_2 = 32
COND_WARRIOR = 56

COND_ASSASSIN_0 = 64
COND_ASSASSIN_1 = 128
COND_ASSASSIN_2 = 256
COND_ASSASSIN = 448

COND_SURA_0 = 512
COND_SURA_1 = 1024
COND_SURA_2 = 2048
COND_SURA = 3584

COND_SHAMAN_0 = 4096
COND_SHAMAN_1 = 8192
COND_SHAMAN_2 = 16384
COND_SHAMAN = 28672

PART_MAIN = 0
PART_HAIR = 3

GUILD_CREATE_ITEM_VNUM = 70101

QUEST_SCROLL_TYPE_KILL_MOB = 1
QUEST_SCROLL_TYPE_KILL_ANOTHER_EMPIRE = 2

apply = {
    ["MAX_HP"]        = 1,
    ["MAX_SP"]        = 2,
    ["CON"]            = 3,
    ["INT"]            = 4,
    ["STR"]            = 5,
    ["DEX"]            = 6,
    ["ATT_SPEED"]        = 7,
    ["MOV_SPEED"]        = 8,
    ["CAST_SPEED"]        = 9,
    ["HP_REGEN"]        = 10,
    ["SP_REGEN"]        = 11,
    ["POISON_PCT"]        = 12,
    ["STUN_PCT"]        = 13,
    ["SLOW_PCT"]        = 14,
    ["CRITICAL_PCT"]    = 15,
    ["PENETRATE_PCT"]    = 16,
    ["ATTBONUS_HUMAN"]    = 17,
    ["ATTBONUS_ANIMAL"]    = 18,
    ["ATTBONUS_ORC"]    = 19,
    ["ATTBONUS_MILGYO"]    = 20,
    ["ATTBONUS_UNDEAD"]    = 21,
    ["ATTBONUS_DEVIL"]    = 22,
    ["STEAL_HP"]        = 23,
    ["STEAL_SP"]        = 24,
    ["MANA_BURN_PCT"]    = 25,
    ["DAMAGE_SP_RECOVER"]    = 26,
    ["BLOCK"]        = 27,
    ["DODGE"]        = 28,
    ["RESIST_SWORD"]    = 29,
    ["RESIST_TWOHAND"]    = 30,
    ["RESIST_DAGGER"]    = 31,
    ["RESIST_BELL"]        = 32,
    ["RESIST_FAN"]        = 33,
    ["RESIST_BOW"]        = 34,
    ["RESIST_FIRE"]        = 35,
    ["RESIST_ELEC"]        = 36,
    ["RESIST_MAGIC"]    = 37,
    ["RESIST_WIND"]        = 38,
    ["REFLECT_MELEE"]    = 39,
    ["REFLECT_CURSE"]    = 40,
    ["POISON_REDUCE"]    = 41,
    ["KILL_SP_RECOVER"]    = 42,
    ["EXP_DOUBLE_BONUS"]    = 43,
    ["GOLD_DOUBLE_BONUS"]    = 44,
    ["ITEM_DROP_BONUS"]    = 45,
    ["POTION_BONUS"]    = 46,
    ["KILL_HP_RECOVER"]    = 47,
    ["IMMUNE_STUN"]        = 48,
    ["IMMUNE_SLOW"]        = 49,
    ["IMMUNE_FALL"]        = 50,
    ["SKILL"]        = 51,
    ["BOW_DISTANCE"]    = 52,
    ["ATT_GRADE_BONUS"]    = 53,
    ["DEF_GRADE_BONUS"]    = 54,
    ["MAGIC_ATT_GRADE"]    = 55,
    ["MAGIC_DEF_GRADE"]    = 56,
    ["CURSE_PCT"]        = 57,
    ["MAX_STAMINA"]        = 58,
    ["ATTBONUS_WARRIOR"]    = 59,
    ["ATTBONUS_ASSASSIN"]    = 60,
    ["ATTBONUS_SURA"]    = 61,
    ["ATTBONUS_SHAMAN"]    = 62,
    ["ATTBONUS_MONSTER"]    = 63,
}

-- ??? ??? -_-
special = {}

special.fortune_telling =
{
--  { prob    ??    item    money    remove money
    { 1,    0,    20,    20,    0    }, -- 10
    { 499,    0,    10,    10,    0    }, -- 5
    { 2500,    0,    5,    5,    0    }, -- 1
    { 5000,    0,    0,    0,    0    },
    { 1500,    0,    -5,    -5,    20000    },
    { 499,    0,    -10,    -10,    20000    },
    { 1,    0,    -20,    -20,    20000    },
}

special.questscroll_reward =
{
    {1,    1500,    3000,    30027,    0,    0    },
    {2,    1500,    3000,    30028,    0,    0    },
    {3,    1000,    2000,    30034,    30018,    0    },
    {4,    1000,    2000,    30034,    30011,    0    },
    {5,    1000,    2000,    30011,    30034,    0    },
    {6,    1000,    2000,    27400,    0,    0    },
    {7,    2000,    4000,    30023,    30003,    0    },
    {8,    2000,    4000,    30005,    30033,    0    },
    {9,    2000,    8000,    30033,    30005,    0    },
    {10,    4000,    8000,    30021,    30033,    30045},
    {11,    4000,    8000,    30045,    30022,    30046},
    {12,    5000,    12000,    30047,    30045,    30055},
    {13,    5000,    12000,    30051,    30017,    30058},
    {14,    5000,    12000,    30051,    30007,    30041},
    {15,    5000,    15000,    30091,    30017,    30018},
    {16,    3500,    6500,    30021,    30033,    0    },
    {17,    4000,    9000,    30051,    30033,    0    },
    {18,    4500,    10000,    30056,    30057,    30058},
    {19,    4500,    10000,    30059,    30058,    30041},
    {20,    5000,    15000,    0,    0,    0    },
}

special.active_skill_list = {
    {
        { 1, 2, 3, 4, 5, 6},
        { 16, 17, 18, 19, 20, 21},
    },
    {
        {31, 32, 33, 34, 35, 36},
        {46, 47, 48, 49, 50, 51},
    },
    {
        {61, 62, 63, 64, 65, 66},
        {76, 77, 78, 79, 80, 81},
    },
    {
        {91, 92, 93, 94, 95, 96},
        {106, 107, 108, 109, 110, 111},
    },
}

special.skill_reset_cost = {
    2000,
    2000,
    2000,
    2000,
    2000,
    2000,
    4000,
    6000,
    8000,
    10000,
    14000,
    18000,
    22000,
    28000,
    34000,
    41000,
    50000,
    59000,
    70000,
    90000,
    101000,
    109000,
    114000,
    120000,
    131000,
    141000,
    157000,
    176000,
    188000,
    200000,
    225000,
    270000,
    314000,
    348000,
    393000,
    427000,
    470000,
    504000,
    554000,
    600000,
    758000,
    936000,
    1103000,
    1276000,
    1407000,
    1568000,
    1704000,
    1860000,
    2080000,
    2300000,
    2700000,
    3100000,
    3500000,
    3900000,
    4300000,
    4800000,
    5300000,
    5800000,
    6400000,
    7000000,
    8000000,
    9000000,
    10000000,
    11000000,
    12000000,
    13000000,
    14000000,
    15000000,
    16000000,
    17000000,
}

special.levelup_img =
{
    [101] = "dog.tga",
    [102] = "wolf.tga",
    [103] = "wolf.tga",
    [104] = "wolf.tga",
    [105] = "wolf.tga",
    [105] = "wolf.tga",
    [106] = "wolf.tga",
    [107] = "wolf.tga",
    [108] = "wild_boar.tga",
    [109] = "wild_boar.tga",
    [110] = "bear.tga",
    [111] = "bear.tga",
    [112] = "bear.tga",
    [113] = "bear.tga",
    [114] = "tiger.tga",
    [115] = "tiger.tga",

    [301] = "bak_inf.tga",
    [302] = "bak_gung.tga",
    [303] = "bak_gen1.tga",
    [304] = "bak_gen2.tga",

    [401] = "huk_inf.tga",
    [402] = "huk_dol.tga",
    [403] = "huk_gen1.tga",
    [404] = "huk_gen2.tga",

    [501] = "o_inf.tga",
    [502] = "o_jol.tga",
    [503] = "o_gung.tga",
    [504] = "o_jang.tga",

    [601] = "ung_inf.tga",
    [602] = "ung_chuk.tga",
    [603] = "ung_tu.tga",
}

special.levelup_quest = {
    -- monster kill  monster   kill
    --    vnum        qty.         vnum        qty.     exp percent
{    0    ,    0    ,    0    ,    0    ,    0    }    ,    --    lev    1
{    101    ,    10    ,    102    ,    5    ,    10    }    ,    --    lev    2
{    101    ,    20    ,    102    ,    10    ,    10    }    ,    --    lev    3
{    102    ,    15    ,    103    ,    5    ,    10    }    ,    --    lev    4
{    103    ,    10    ,    104    ,    10    ,    10    }    ,    --    lev    5
{    104    ,    20    ,    108    ,    10    ,    10    }    ,    --    lev    6
{    108    ,    10    ,    105    ,    5    ,    10    }    ,    --    lev    7
{    108    ,    20    ,    105    ,    10    ,    10    }    ,    --    lev    8
{    105    ,    15    ,    109    ,    5    ,    10    }    ,    --    lev    9
{    105    ,    20    ,    109    ,    10    ,    10    }    ,    --    lev    10
{    109    ,    10    ,    110    ,    5    ,    10    }    ,    --    lev    11
{    110    ,    15    ,    106    ,    10    ,    10    }    ,    --    lev    12
{    106    ,    20    ,    111    ,    5    ,    10    }    ,    --    lev    13
{    111    ,    15    ,    107    ,    5    ,    10    }    ,    --    lev    14
{    111    ,    20    ,    107    ,    10    ,    10    }    ,    --    lev    15
{    107    ,    15    ,    114    ,    5    ,    10    }    ,    --    lev    16
{    107    ,    20    ,    114    ,    10    ,    10    }    ,    --    lev    17
{    114    ,    10    ,    112    ,    10    ,    10    }    ,    --    lev    18
{    112    ,    20    ,    113    ,    10    ,    10    }    ,    --    lev    19
{    113    ,    20    ,    302    ,    15    ,    10    }    ,    --    lev    20
{    302    ,    20    ,    115    ,    10    ,    "2-10"    }    ,    --    lev    21
{    115    ,    25    ,    304    ,    10    ,    "2-10"    }    ,    --    lev    22
{    304    ,    20    ,    401    ,    40    ,    "2-10"    }    ,    --    lev    23
{    401    ,    60    ,    402    ,    80    ,    "2-10"    }    ,    --    lev    24
{    501    ,    80    ,    404    ,    20    ,    "2-10"    }    ,    --    lev    25
{    502    ,    80    ,    406    ,    20    ,    "2-10"    }    ,    --    lev    26
{    406    ,    30    ,    504    ,    20    ,    "2-10"    }    ,    --    lev    27
{    631    ,    35    ,    504    ,    30    ,    "2-10"    }    ,    --    lev    28
{    631    ,    40    ,    632    ,    30    ,    "2-10"    }    ,    --    lev    29
{    632    ,    40    ,    2102    ,    30    ,    "2-10"    }    ,    --    lev    30
{    632    ,    50    ,    2102    ,    45    ,    "2-5"    }    ,    --    lev    31
{    633    ,    45    ,    2001    ,    40    ,    "2-5"    }    ,    --    lev    32
{    701    ,    35    ,    2103    ,    30    ,    "2-5"    }    ,    --    lev    33
{    701    ,    40    ,    2103    ,    40    ,    "2-5"    }    ,    --    lev    34
{    702    ,    40    ,    2002    ,    30    ,    "2-5"    }    ,    --    lev    35
{    704    ,    20    ,    2106    ,    20    ,    "2-5"    }    ,    --    lev    36
{    733    ,    30    ,    2003    ,    20    ,    "2-5"    }    ,    --    lev    37
{    734    ,    40    ,    2004    ,    20    ,    "2-5"    }    ,    --    lev    38
{    706    ,    40    ,    2005    ,    30    ,    "2-5"    }    ,    --    lev    39
{    707    ,    40    ,    2108    ,    20    ,    "2-5"    }    ,    --    lev    40
{    901    ,    40    ,    5123    ,    25    ,    "2-5"    }    ,    --    lev    41
{    902    ,    30    ,    5123    ,    30    ,    "2-5"    }    ,    --    lev    42
{    902    ,    40    ,    2031    ,    35    ,    "2-5"    }    ,    --    lev    43
{    903    ,    40    ,    2031    ,    40    ,    "2-5"    }    ,    --    lev    44
{    731    ,    50    ,    2032    ,    45    ,    "2-5"    }    ,    --    lev    45
{    732    ,    30    ,    5124    ,    30    ,    "2-5"    }    ,    --    lev    46
{    903    ,    35    ,    5125    ,    30    ,    "2-5"    }    ,    --    lev    47
{    904    ,    40    ,    5125    ,    35    ,    "2-5"    }    ,    --    lev    48
{    733    ,    40    ,    2033    ,    45    ,    "2-5"    }    ,    --    lev    49
{    734    ,    40    ,    5126    ,    20    ,    "2-5"    }    ,    --    lev    50
{    735    ,    50    ,    5126    ,    30    ,    "1-4"    }    ,    --    lev    51
{    904    ,    45    ,    2034    ,    45    ,    "1-4"    }    ,    --    lev    52
{    904    ,    50    ,    2034    ,    50    ,    "1-4"    }    ,    --    lev    53
{    736    ,    40    ,    1001    ,    30    ,    "1-4"    }    ,    --    lev    54
{    737    ,    40    ,    1301    ,    35    ,    "1-4"    }    ,    --    lev    55
{    905    ,    50    ,    1002    ,    30    ,    "1-4"    }    ,    --    lev    56
{    905    ,    60    ,    1002    ,    40    ,    "1-4"    }    ,    --    lev    57
{    906    ,    45    ,    1303    ,    40    ,    "1-4"    }    ,    --    lev    58
{    906    ,    50    ,    1303    ,    45    ,    "1-4"    }    ,    --    lev    59
{    907    ,    45    ,    1003    ,    40    ,    "1-4"    }    ,    --    lev    60

}

special.levelup_reward1 =
{
    -- warrior assassin  sura  shaman
    {     0,        0,      0,      0 },
    { 11200,    11400,  11600,  11800 }, -- ??
    { 12200,    12340,  12480,  12620 }, -- ??
    { 13000,    13000,  13000,  13000 }  -- ??
}

-- levelup_reward1 ??? ???? ??? ???? ??
-- ???? ???? ???? ??.
special.levelup_reward3 = {
    -- pct   item #  item count
    {   33,  27002,  10 }, -- 25%
    {   67,  27005,  10 }, -- 25%
  --{   75,  27101,   5 }, -- 25%
    {  100,  27114,   5 }, -- 25%
}

special.levelup_reward_gold21 =
{
    { 10000,    20 },
    { 20000,    50 },
    { 40000,    25 },
    { 80000,    3 },
    { 100000,    2 },
}
special.levelup_reward_gold31 =
{
    { 20000,    20 },
    { 40000,    40 },
    { 60000,    25 },
    { 80000,    10 },
    { 100000,    5 },
}
special.levelup_reward_gold41 =
{
    { 40000,    20 },
    { 60000,    40 },
    { 80000,    25 },
    { 100000,    10 },
    { 150000,    5 },
}
special.levelup_reward_gold51 =
{
    { 60000,    20 },
    { 80000,    40 },
    { 100000,    25 },
    { 150000,    10 },
    { 200000,    5 },
}

special.levelup_reward_exp21 =
{
    { 2,    9 },
    { 3,    14 },
    { 4,    39 },
    { 6,    24 },
    { 8,    9 },
    { 10,    4 },
}

special.levelup_reward_exp31 =
{
    { 2,    10 },
    { 2.5,    15 },
    { 3,    40 },
    { 3.5,    25 },
    { 4,    8 },
    { 4.5,    5 },
    { 5,    2 },
}
special.levelup_reward_exp41 =
{
    { 2,    10 },
    { 2.5,    15 },
    { 3,    40 },
    { 3.5,    25 },
    { 4,    8 },
    { 4.5,    5 },
    { 5,    2 },
}
special.levelup_reward_exp51 =
{
    { 1,    10 },
    { 1.5,    15 },
    { 2,    40 },
    { 2.5,    25 },
    { 3,    8 },
    { 3.5,    5 },
    { 4,    2 },
}

special.levelup_reward_item_21 =
{
    -- no couple ring
    { { 27002, 10 }, { 27005, 10 }, { 27114, 10 } }, -- lev 21
    { 15080, 15100, 15120, 15140 }, -- lev 22
    { 16080, 16100, 16120, 16140 }, -- lev 23
    { 17080, 17100, 17120, 17140 }, -- lev 24
    { { 27002, 10 }, { 27005, 10 }, { 27114, 10 } }, -- lev 25
    { { 27003, 20 }, { 27006, 20 }, { 27114, 10 } }, -- over lev 25

    -- with couple ring
    -- { { 27002, 10 }, { 27005, 10 }, { 27114, 10 }, { 70301, 1 } }, -- lev 21
    -- { 15080, 15100, 15120, 15140, 70301 }, -- lev 22
    -- { 16080, 16100, 16120, 16140, 70301 }, -- lev 23
    -- { 17080, 17100, 17120, 17140, 70301 }, -- lev 24
    -- { { 27002, 10 }, { 27005, 10 }, { 27114, 10 }, { 70301, 1 } }, -- lev 25
    -- { { 27003, 20 }, { 27006, 20 }, { 27114, 10 } }, -- over lev 25
}

special.warp_to_pos = {
-- ???
    {
    { 402100, 673900 },
    { 270400, 739900 },
    { 321300, 808000 },
    },
--????
    {
--A 5994 7563
--B 5978 6222
--C 7307 6898
    { 599400, 756300 },
    { 597800, 622200 },
    { 730700, 689800 },
    },
--????
    {
--A 2178 6272
    { 217800, 627200 },
--B 2219 5027
    { 221900, 502700 },
--C 3440 5025
    { 344000, 502500 },
    },
--???
    {
--A 4342 2906
    { 434200, 290600 },
--B 3752 1749
    { 375200, 174900 },
--C 4918 1736
    { 491800, 173600 },
    },
}

special.devil_tower =
{
    --{ 123, 608 },
    { 2048+126, 6656+384 },
    { 2048+134, 6656+147 },
    { 2048+369, 6656+629 },
    { 2048+369, 6656+401 },
    { 2048+374, 6656+167 },
    { 2048+579, 6656+616 },
    { 2048+578, 6656+392 },
    { 2048+575, 6656+148 },
}

special.lvq_map = {
    { -- "A1" 1
        {},
    
        { { 440, 565 }, { 460, 771 }, { 668, 800 },},
        { { 440, 565 }, { 460, 771 }, { 668, 800 },},
        { { 440, 565 }, { 460, 771 }, { 668, 800 },},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{853,557}, {845,780}, {910,956},},
        {{853,557}, {845,780}, {910,956},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        
        {{224,395}, {137,894}, {206,830}, {266,1067},},
        {{224,395}, {137,894}, {206,830}, {266,1067},},
        {{224,395}, {137,894}, {206,830}, {266,1067},},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        
        {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}},
        
        {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}},
    },


    { -- "A2" 2
        {},
        
        {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }},
        
        {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }},
        
        {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}},
        
        {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}},
        
        {{640,1437}},
        {{640,1437}},
        {{640,1437}},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{193,772}, {390,402}, {768,600}, {1075,789}, {1338,813},},
        {{193,772}, {390,402}, {768,600}, {1075,789}, {1338,813},},
    },



    { -- "A3" 3
        {},

        {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }},
        {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }},

        {{ 948,804 }},
        {{ 948,804 }},
        {{ 948,804 }},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{200,277}, {130,646}, {211,638}, {291,851},},
        {{200,277}, {130,646}, {211,638}, {291,851},},
        {{200,277}, {130,646}, {211,638}, {291,851},},
        {{100,150}},
        {{100,150}},
        {{100,150}},
        {{100,150}},
        {{100,150}},
        {{100,150}},
    },

    {}, -- 4
    {}, -- 5
    {}, -- 6
    {}, -- 7
    {}, -- 8
    {}, -- 9
    {}, -- 10
    {}, -- 11
    {}, -- 12
    {}, -- 13
    {}, -- 14
    {}, -- 15
    {}, -- 16
    {}, -- 17
    {}, -- 18
    {}, -- 19
    {}, -- 20

    { -- "B1" 21
        {},
        
        {{412,635}, {629,428}, {829,586},},
        {{412,635}, {629,428}, {829,586},},
        {{412,635}, {629,428}, {829,586},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},

        {{329,643}, {632,349}, {905,556},},
        {{866,822}, {706,224}, {247,722},},
        {{866,822}, {706,224}, {247,722},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
    
        {{496,1089}, {890,1043},},
        {{496,1089}, {890,1043},},
        {{496,1089}, {890,1043},},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
    
        {{876,1127}}, {{876,1127}}, {{876,1127}}, {{876,1127}}, {{876,1127}},    {{876,1127}},    {{876,1127}},    {{876,1127}},    {{876,1127}}, {{876,1127}},
        {{876,1127}}, {{876,1127}}, {{876,1127}}, {{908,87}},    {{908,87}},        {{908,87}},        {{908,87}},        {{908,87}},        {{908,87}},
    },

    { -- "B2" 22
        {},

        {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }},
        {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }},
        {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}},
        {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}},

        {{746,1438}},
        {{746,1438}},
        {{746,1438}},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{787,235}, {1209,382}, {1350,571}, {1240,852}, {1254,1126}, {1078,1285}, {727,1360},},
        {{787,235}, {1209,382}, {1350,571}, {1240,852}, {1254,1126}, {1078,1285}, {727,1360},},
    },


    { -- "B3" 23
        {},
        
        {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }},
        {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }},

         {{ 106,88 }},
        {{ 106,88 }},
        {{ 106,88 }},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{816,721}, {489,823},},
        {{816,721}, {489,823},},
        {{816,721}, {489,823},},
        {{772,140}},
        {{772,140}},
        {{772,140}},
        {{772,140}},
        {{772,140}},
        {{772,140}},
    },

    {}, -- 24
    {}, -- 25
    {}, -- 26
    {}, -- 27
    {}, -- 28
    {}, -- 29
    {}, -- 30
    {}, -- 31
    {}, -- 32
    {}, -- 33
    {}, -- 34
    {}, -- 35
    {}, -- 36
    {}, -- 37
    {}, -- 38
    {}, -- 39
    {}, -- 40

    { -- "C1" 41
        {},

        {{385,446}, {169,592}, {211,692}, {632,681},},
        {{385,446}, {169,592}, {211,692}, {632,681},},
        {{385,446}, {169,592}, {211,692}, {632,681},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        
        {{385,374}, {227,815}, {664,771},},
        {{169,362}, {368,304}, {626,409}, {187,882}, {571,858},},
        {{169,362}, {368,304}, {626,409}, {187,882}, {571,858},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        
        {{452,160}, {536,1034}, {184,1044},},
        {{452,160}, {536,1034}, {184,1044},},
        {{452,160}, {536,1034}, {184,1044},},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        
        {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}},
        {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}},
    },

    { -- "C2" 42
        {},

        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
    
        {{1409,139}},
        {{1409,139}},
        {{1409,139}},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{192,211}, {247,600}, {249,882}, {987,981}, {1018,1288}, {1303,1174},},
        {{192,211}, {247,600}, {249,882}, {987,981}, {1018,1288}, {1303,1174},},
    },

    { -- "C3" 43
        {},

        {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}},
        {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}},
    
        {{901,151}},
        {{901,151}},
        {{901,151}},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{635,856}, {324,855},},
        {{635,856}, {324,855},},
        {{635,856}, {324,855},},
        {{136,899}},
        {{136,899}},
        {{136,899}},
        {{136,899}},
        {{136,899}},
        {{136,899}},
    },

    {}, -- 44
    {}, -- 45
    {}, -- 46
    {}, -- 47
    {}, -- 48
    {}, -- 49
    {}, -- 50
    {}, -- 51
    {}, -- 52
    {}, -- 53
    {}, -- 54
    {}, -- 55
    {}, -- 56
    {}, -- 57
    {}, -- 58
    {}, -- 59
    {}, -- 60
}

function BuildSkillList(job, group)
    local skill_vnum_list = {}
    local skill_name_list = {}

    if pc.get_skill_group() != 0 then
        local skill_list = special.active_skill_list[job+1][group]
                
        table.foreachi( skill_list,
            function(i, t)
                local lev = pc.get_skill_level(t)

                if lev > 0 then
                    local name = locale.GM_SKILL_NAME_DICT[t]

                    if name != nil then
                        table.insert(skill_vnum_list, t)
                        table.insert(skill_name_list, name)
                    end
                end
            end
        )
    end

    table.insert(skill_vnum_list, 0)
    table.insert(skill_name_list, "??")

    return { skill_vnum_list, skill_name_list }
end

PREMIUM_EXP             = 0
PREMIUM_ITEM            = 1
PREMIUM_SAFEBOX         = 2
PREMIUM_AUTOLOOT        = 3
PREMIUM_FISH_MIND       = 4
PREMIUM_MARRIAGE_FAST   = 5
PREMIUM_GOLD            = 6

-- point type start
POINT_NONE                 = 0
POINT_LEVEL                = 1
POINT_VOICE                = 2
POINT_EXP                  = 3
POINT_NEXT_EXP             = 4
POINT_HP                   = 5
POINT_MAX_HP               = 6
POINT_SP                   = 7
POINT_MAX_SP               = 8 
POINT_STAMINA              = 9  --????
POINT_MAX_STAMINA          = 10 --?? ????

POINT_GOLD                 = 11
POINT_ST                   = 12 --??
POINT_HT                   = 13 --??
POINT_DX                   = 14 --???
POINT_IQ                   = 15 --???
POINT_DEF_GRADE            = 16
POINT_ATT_SPEED            = 17 --????
POINT_ATT_GRADE            = 18 --??? MAX
POINT_MOV_SPEED            = 19 --????
POINT_CLIENT_DEF_GRADE        = 20 --????
POINT_CASTING_SPEED        = 21 --???? (?????*100) / (100 + ??) = ?? ??? ??
POINT_MAGIC_ATT_GRADE      = 22 --?????
POINT_MAGIC_DEF_GRADE      = 23 --?????
POINT_EMPIRE_POINT         = 24 --????
POINT_LEVEL_STEP           = 25 --? ????? ??.. (1 2 3 ? ? ?? 4 ?? ?? ?)
POINT_STAT                 = 26 --??? ?? ? ?? ??
POINT_SUB_SKILL            = 27 --?? ?? ???
POINT_SKILL                = 28 --??? ?? ???
POINT_WEAPON_MIN            = 29 --?? ?? ???
POINT_WEAPON_MAX            = 30 --?? ?? ???
POINT_PLAYTIME             = 31 --?????
POINT_HP_REGEN             = 32 --HP ???
POINT_SP_REGEN             = 33 --SP ???

POINT_BOW_DISTANCE         = 34 --? ???? ??? (meter)

POINT_HP_RECOVERY          = 35 --?? ?? ???
POINT_SP_RECOVERY          = 36 --??? ?? ???

POINT_POISON_PCT           = 37 --? ??
POINT_STUN_PCT             = 38 --?? ??
POINT_SLOW_PCT             = 39 --??? ??
POINT_CRITICAL_PCT         = 40 --???? ??
POINT_PENETRATE_PCT        = 41 --???? ??
POINT_CURSE_PCT            = 42 --?? ??

POINT_ATTBONUS_HUMAN       = 43 --???? ??
POINT_ATTBONUS_ANIMAL      = 44 --???? ??? % ??
POINT_ATTBONUS_ORC         = 45 --???? ??? % ??
POINT_ATTBONUS_MILGYO      = 46 --???? ??? % ??
POINT_ATTBONUS_UNDEAD      = 47 --???? ??? % ??
POINT_ATTBONUS_DEVIL       = 48 --??(??)?? ??? % ??
POINT_ATTBONUS_INSECT      = 49 --???
POINT_ATTBONUS_FIRE        = 50 --???
POINT_ATTBONUS_ICE         = 51 --???
POINT_ATTBONUS_DESERT      = 52 --???
POINT_ATTBONUS_MONSTER     = 53 --?? ????? ??
POINT_ATTBONUS_WARRIOR     = 54 --???? ??
POINT_ATTBONUS_ASSASSIN    = 55 --???? ??
POINT_ATTBONUS_SURA        = 56 --???? ??
POINT_ATTBONUS_SHAMAN        = 57 --???? ??

-- ADD_TRENT_MONSTER
POINT_ATTBONUS_TREE         = 58 --???? ?? 20050729.myevan UNUSED5
-- END_OF_ADD_TRENT_MONSTER
POINT_RESIST_WARRIOR        = 59 --???? ??
POINT_RESIST_ASSASSIN        = 60 --???? ??
POINT_RESIST_SURA            = 61 --???? ??
POINT_RESIST_SHAMAN        = 62 --???? ??

POINT_STEAL_HP             = 63 --??? ??
POINT_STEAL_SP             = 64 --??? ??

POINT_MANA_BURN_PCT        = 65 --?? ?

--/ ??? ??? =/

POINT_DAMAGE_SP_RECOVER    = 66 --???? ? ??? ?? ??

POINT_BLOCK                = 67 --???
POINT_DODGE                = 68 --???

POINT_RESIST_SWORD         = 69
POINT_RESIST_TWOHAND       = 70
POINT_RESIST_DAGGER        = 71
POINT_RESIST_BELL          = 72
POINT_RESIST_FAN           = 73
POINT_RESIST_BOW           = 74  --??   ??   : ??? ??
POINT_RESIST_FIRE          = 75  --??   ??   : ????? ?? ??? ??
POINT_RESIST_ELEC          = 76  --??   ??   : ????? ?? ??? ??
POINT_RESIST_MAGIC         = 77  --??   ??   : ????? ?? ??? ??
POINT_RESIST_WIND          = 78  --??   ??   : ????? ?? ??? ??

POINT_REFLECT_MELEE        = 79 --?? ??

--/ ?? ??? =/
POINT_REFLECT_CURSE        = 80 --?? ??
POINT_POISON_REDUCE        = 81 --???? ??

--/ ? ??? =/
POINT_KILL_SP_RECOVER        = 82 --? ??? MP ??
POINT_EXP_DOUBLE_BONUS        = 83
POINT_GOLD_DOUBLE_BONUS        = 84
POINT_ITEM_DROP_BONUS        = 85

--/ ?? ?? =/
POINT_POTION_BONUS            = 86
POINT_KILL_HP_RECOVERY        = 87

POINT_IMMUNE_STUN            = 88
POINT_IMMUNE_SLOW            = 89
POINT_IMMUNE_FALL            = 90
--========

POINT_PARTY_ATTACKER_BONUS        = 91
POINT_PARTY_TANKER_BONUS        = 92

POINT_ATT_BONUS            = 93
POINT_DEF_BONUS            = 94

POINT_ATT_GRADE_BONUS        = 95
POINT_DEF_GRADE_BONUS        = 96
POINT_MAGIC_ATT_GRADE_BONUS    = 97
POINT_MAGIC_DEF_GRADE_BONUS    = 98

POINT_RESIST_NORMAL_DAMAGE        = 99

POINT_HIT_HP_RECOVERY        = 100
POINT_HIT_SP_RECOVERY         = 101
POINT_MANASHIELD            = 102 --???? ??? ?? ???? ?? ??

POINT_PARTY_BUFFER_BONUS        = 103
POINT_PARTY_SKILL_MASTER_BONUS    = 104

POINT_HP_RECOVER_CONTINUE        = 105
POINT_SP_RECOVER_CONTINUE        = 106

POINT_STEAL_GOLD            = 107
POINT_POLYMORPH            = 108 --??? ??? ??
POINT_MOUNT                = 109 --???? ??? ??

POINT_PARTY_HASTE_BONUS        = 110
POINT_PARTY_DEFENDER_BONUS        = 111
POINT_STAT_RESET_COUNT        = 112 --?? ?? ??? ?? ?? ?? ??? (1? 1??? ????)

POINT_HORSE_SKILL            = 113

POINT_MALL_ATTBONUS        = 114 --??? +x%
POINT_MALL_DEFBONUS        = 115 --??? +x%
POINT_MALL_EXPBONUS        = 116 --??? +x%
POINT_MALL_ITEMBONUS        = 117 --??? ??? x/10?
POINT_MALL_GOLDBONUS        = 118 --? ??? x/10?

POINT_MAX_HP_PCT            = 119 --????? +x%
POINT_MAX_SP_PCT            = 120 --????? +x%

POINT_SKILL_DAMAGE_BONUS        = 121 --?? ??? *(100+x)%
POINT_NORMAL_HIT_DAMAGE_BONUS    = 122 --?? ??? *(100+x)%

-- DEFEND_BONUS_ATTRIBUTES
POINT_SKILL_DEFEND_BONUS        = 123 --?? ?? ???
POINT_NORMAL_HIT_DEFEND_BONUS    = 124 --?? ?? ???
-- END_OF_DEFEND_BONUS_ATTRIBUTES

-- PC_BANG_ITEM_ADD
POINT_PC_BANG_EXP_BONUS        = 125 --PC? ?? ??? ???
POINT_PC_BANG_DROP_BONUS        = 126 --PC? ?? ??? ???
-- END_PC_BANG_ITEM_ADD
-- POINT_MAX_NUM = 128    common/length.h
-- point type start

function setvarchar(name, var)
    local laenge = string.len (var)
    local setchar = 0
    local save_name = 0
    local letter = 0
    while laenge > setchar do
        setchar = setchar + 1
        letter = string.sub (var, setchar, setchar)
        letter = string.byte(letter, 1)
        save_name = ""..name.."_char_"..setchar..""
        pc.setqf(save_name, letter)
    end
    local save_laenge=""..name.."laenge"
    pc.setqf(save_laenge, laenge)
end

function getvarchar(name)
    local save_laenge = ""..name.."laenge"
    local laenge = pc.getqf(save_laenge)
    local save_name = 0
    local var = ""
    local letter = 0
    local getchar = 0
    while laenge > getchar do
        getchar = getchar + 1
        save_name = ""..name.."_char_"..getchar..""
        letter = pc.getqf(save_name)
        if letter!=0 then
            letter = string.char(letter)
        else
            letter = ""
        end
        var = ""..var..""..letter..""
    end
    return var
end

function delvarchar(name)
    local save_laenge = ""..name.."laenge"
    local laenge = pc.getqf(save_laenge)
    local getchar = 0
    while laenge > getchar do
        getchar = getchar + 1
        local save_name = ""..name.."_char_"..getchar..""
        pc.delqf(save_name)
    end
    pc.delqf(save_laenge)
end

function global_setvarchar(name, var)
    local laenge = string.len (var)
    local setchar = 0
    local save_name = 0
    local letter = 0
    while laenge > setchar do
        setchar = setchar + 1
        letter = string.sub (var, setchar, setchar)
        letter = string.byte(letter)
        if letter==91 or letter==93 then
            letter=32
        end
        save_name = ""..name.."_char_"..setchar..""
        game.set_event_flag(save_name, letter)
    end
    local save_laenge=""..name.."laenge"
    game.set_event_flag(save_laenge, laenge)
end

function global_getvarchar(name)
    local save_laenge = ""..name.."laenge"
    local laenge = game.get_event_flag(save_laenge)
    local save_name = 0
    local var = ""
    local letter = 0
    local getchar = 0
    while laenge > getchar do
        getchar = getchar + 1
        save_name = ""..name.."_char_"..getchar..""
        letter = game.get_event_flag(save_name)
        if letter!=0 then
            letter = string.char(letter)
        else
            letter = ""
        end
        
        var = ""..var..""..letter..""
    end
    return var
end

function actual_time()
    return os.date()
end

function actual_timestamp()
    return os.time()
end

function search_time(h,m,s)
    local out = {}
    out.h = os.date("%H")+h
    out.m = os.date("%M")+m
    out.s = os.date("%S")+s
    while out.h >= 24 do
        out.h = out.h - 24
    end
    while out.m >= 60 do
        out.m = out.m - 60
    end
    while out.s >= 60 do
        out.s = out.s - 60
    end
    if out.h < 10 then
        out.h = "0"..out.h
    end
    if out.m < 10 then
        out.m = "0"..out.m
    end
    if out.s < 10 then
        out.s = "0"..out.s
    end
    return out
end

function SendAchievement(Achievement, new_points, count)
    local Achievement = string.gsub(Achievement, " ", "_")
    if count != nil then
        if count != 1 then
            Achievement = Achievement.."#"..count
        end
    end
    cmdchat("achievement "..Achievement.."%"..new_points.."")
end

 function setenergy(typ,value,timez)
 pc.setqf("energy_value",value)
 pc.setqf("energy_typ",typ)
 pc.setqf("energy_date",timez)
end

function setenergytime(timez)
 pc.setqf("energy_date",timez)
end
function getenergytyp()
 return pc.getqf("energy_typ")
end

function getenergyvalue()
 return pc.getqf("energy_value")
end
function getenergytime()
 return pc.getqf("energy_date")
end 

function costume_system_create()
    os.execute("mysql -u root player --execute=\"INSERT INTO costume_system(pid) VALUES ('".. pc.get_player_id() .."')\"")
end

function costume_system_read(type_v)
    local mysql_read = (mysql_query("SELECT "..type_v.." as result_value from player.costume_system where pid = ('".. pc.get_player_id() .."')") or {["result_value"] = 0})
    return mysql_read.result_value[1]
end

function costume_system_update(type_s, value)
    if type_s == "part_main_old" then
        if value < 41002 then
            os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
        end

    elseif type_s == "part_hair_old" then
        os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
    end
end


TORNEO_READ            = 0
TORNEO_PLUS            = 1
TORNEO_NEW            = 3
TORNEO_NEXT            = 4

TORNEO_MEMBER        = 1
TORNEO_REGISTRED    = 2
TORNEO_START        = 3
TORNEO_FINISH        = 4
TORNEO_STAGE        = 5
TORNEO_ROUND        = 6

function torneo_open_regi()
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo_stage_*"
    os.execute("cd "..TORNEO_PATH.." && rm -rf "..TORNEO_FILE)
    game.set_event_flag("torneo_close", 0)
end

function torneo_round(number)
    local stage = { 8,16,24,32,40,48,56,64 }
    local x = 1
    while true do
        if stage[x] == nil then break end
        if number <= stage[x] then
            return x
        end
        x = x + 1
    end
end

function torneo_tool(linea, stage, round, modo)
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo_stage_"..stage.."_round_"..round..".txt"
    local x = 1
    local file
    local newRound
    local result
    if modo == 0 then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            local line = file:read("*l")
            if line == nil then
                break
            end
            local text = string.gsub(line, "\n", "")
            if x == linea then
                io.close(file)
                return text
            end
            x = x + 1
        end
        io.close(file)
    elseif modo == 1 then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "a+")
        file:write(linea.."\n")
        io.close(file)
    elseif modo == 2 then
        if round <= 2 then
            newRound = 1
        elseif round <= 4 then
            newRound = 2
        elseif round <= 6 then
            newRound = 3
        elseif round <= 8 then
            newRound = 4
        end
        local TORNEO_NEWFILE = "torneo_stage_"..stage.."_round_"..newRound..".txt"
        file = io.open(TORNEO_PATH..TORNEO_NEWFILE, "a+")
        file:write(linea.."\n")
        io.close(file)
        return newRound
    end
end

function torneo_data(linea, modo)
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo.txt"
    local x = 1
    local file = ""
    if modo == TORNEO_READ then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            local line = file:read("*l")
            if line == nil then
                break
            end
            local text = string.gsub(line, "\n", "")
            if x == linea then
                io.close(file)
                return text
            end
            x = x + 1
        end
        io.close(file)
    elseif modo == TORNEO_PLUS then
        local linee = {}
        local x = 1
        local y = 1
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            linee[x] = file:read("*l")
            if linee[x] == nil then
                break
            end
            x = x + 1
        end
        io.close(file)
        os.rename(TORNEO_PATH..TORNEO_FILE, TORNEO_PATH..TORNEO_FILE..".BAK")
        local update = io.open(TORNEO_PATH..TORNEO_FILE, "a+")
        while true do
            if linee[y] == nil then break end
            if y == linea then
                local newPoint = tonumber(linee[y]) + 1
                update:write(newPoint.."\n")
            else
                update:write(linee[y].."\n")
            end
            io.flush()
            y = y + 1
        end
        io.close(update)
    elseif modo == TORNEO_NEXT then
        local linee = {}
        local x = 1
        local y = 1
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            linee[x] = file:read("*l")
            if linee[x] == nil then
                break
            end
            x = x + 1
        end
        io.close(file)
        local newMember = tonumber(linee[1])/2
        local newFinish = 0
        local newStage = tonumber(linee[5])+1
        local newRound = 1
        local newStart = tonumber(linee[3])+1
        local update = io.open(TORNEO_PATH..TORNEO_FILE, "w+")
        update:write(newMember.."\n"..linee[2].."\n"..newStart.."\n"..newFinish.."\n"..newStage.."\n"..newRound.."\n")
        io.close(update)
    elseif modo == TORNEO_NEW then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "w+")
        file:write(linea.."\n0\n0\n0\n1\n1\n")
        io.close(file)
    end
end

function torneo_opp(posizione, stage, round)
    local member = {}
    local x = 1
    local sfidanti = tonumber(torneo_member(stage, round))/2
    while true do
        member[x] = torneo_tool(x, stage, round, 0)
        if member[x] == nil then break end
        x = x + 1
    end
    local opps = sfidanti + posizione
    local chll = posizione - sfidanti
    if posizione <= sfidanti then
        return member[opps]
    else
        return member[chll]
    end
end

function torneo_member(stage, round)
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo_stage_"..stage.."_round_"..round..".txt"
    local x = 1
    local file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
    while true do
        local line = file:read("*l")
        if line == nil then break end
        x = x + 1
    end
    io.close(file)
    local result = x - 1
    return result
end       

function torneo_number(name, stage, round)
    local player = {}
    local x = 1
    while true do
        player[x] = torneo_tool(x, stage, round, 0)
        if player[x] == name then break end
        x = x + 1
    end
    return x
end

function say_color(color,text)
if color=="blue" then
say(color256(0, 0, 255)..text..color256(196, 196, 196))
elseif color == "green" then
say(color256(0, 255, 0)..text..color256(196, 196, 196))
elseif color == "red" then
say(color256(255, 0, 0)..text..color256(196, 196, 196))
elseif color == "yellow" then
say(color256(255, 255, 0)..text..color256(196, 196, 196))
elseif color == "white" then
say(color256(255, 255, 255)..text..color256(196, 196, 196))
elseif color == "black" then
say(color256(0, 0, 0)..text..color256(196, 196, 196))
elseif color == "cyan" then
say(color256(0, 255, 255)..text..color256(196, 196, 196))
elseif color == "pink" then
say(color256(255, 0, 255)..text..color256(196, 196, 196))
elseif color == "orange" then
say(color256(255, 145, 0)..text..color256(196, 196, 196))
elseif color == "purple" then
say(color256(100, 0, 255)..text..color256(196, 196, 196))
else
say(color256(196, 196, 196)..text..color256(196, 196, 196))
end
end

PetExpTable = {
    [1] = 300, [2] = 600, [3] = 900,
    [4] = 1200, [5] = 1500, [6] = 1800,
    [7] = 2100, [8] = 2400, [9] = 2700,
    [10] = 3000, [11] = 3300, [12] = 3600,
    [13] = 3900, [14] = 4200, [15] = 4500,
    [16] = 4800, [17] = 5100, [18] = 5400,
    [19] = 5700, [20] = 6000, [21] = 6300,
    [22] = 6600, [23] = 6900, [24] = 7200,
    [25] = 7500, [26] = 7800, [27] = 8100,
    [28] = 8400, [29] = 8700, [30] = 9000,
    [31] = 9300, [32] = 9600, [33] = 9900,
    [34] = 10200, [35] = 10500, [36] = 10800,
    [37] = 11100, [38] = 11400, [39] = 11700,
    [40] = 12000, [41] = 12300, [42] = 12600,
    [43] = 12900, [44] = 13200, [45] = 13500,
    [46] = 13800, [47] = 14100, [48] = 14400,
    [49] = 14700, [50] = 15000,    [51] = 15300,
    [52] = 15600, [53] = 15900, [54] = 16200,
    [55] = 16500, [56] = 16800, [57] = 17100,
    [58] = 17400, [59] = 17700, [60] = 18000,
    [61] = 18300, [62] = 18600, [63] = 18900,
    [64] = 19200, [65] = 19500, [66] = 19800,
    [67] = 20100, [68] = 20400, [69] = 20700,
    [70] = 21000, [71] = 21300, [72] = 21600,
    [73] = 21900, [74] = 22200, [75] = 22500,
    [76] = 22800, [77] = 23100, [78] = 23400,
    [79] = 23700, [80] = 24000,    [81] = 24300,
    [82] = 24600, [83] = 24900, [84] = 25200,
    [85] = 25500, [86] = 25800, [87] = 26100,
    [88] = 26400, [89] = 26700, [90] = 27000,
    [91] = 27300, [92] = 27600, [93] = 27900,
    [94] = 28200, [95] = 28500, [96] = 28800,
    [97] = 29100, [98] = 29400, [99] = 29700,
    [100] = 30000, [101] = 30300, [102] = 30600,
    [103] = 30900, [104] = 31200, [105] = 31500,
    [106] = 31800, [107] = 32100, [108] = 32400,
    [109] = 32700, [110] = 33000, [111] = 33300,
    [112] = 33600, [113] = 33900, [114] = 34200,
    [115] = 34500, [116] = 34800, [117] = 35100,
    [118] = 35400, [119] = 35700, [120] = 36000,
    [121] = 36300, [122] = 36600, [123] = 36900,
    [124] = 37200, [125] = 37500, [126] = 37800,
    [127] = 38100, [128] = 38400, [129] = 38700,
    [130] = 39000, [131] = 39300, [132] = 39600,
    [133] = 39900, [134] = 40200, [135] = 40500,
    [136] = 40800, [137] = 41100, [138] = 41400,
    [139] = 41700, [140] = 42000, [141] = 42300,
    [142] = 42600, [143] = 42900, [144] = 43200,
    [145] = 43500, [146] = 43800, [147] = 44100,
    [148] = 44400, [149] = 44700, [150] = 45000,
}


PetBonus = {
    { "Ofansif", { "Saldiri Degeri","Buyulu Saldiri Degeri", }, { "Savascilara Karsi Guclu","Ninjalara Karsi Guclu","Suralara Karsi Guclu","Samanlara Karsi Guclu","Canavarlara Karsi Guclui", }, { "Kritik Vurus Sansi","Delici Vurus Sansi", }, { "Sersemletme Sansi","Zehirleme Sansi","Yavaslatma Sansi", }, },
    { "Defansif", { "Savunma","Buyu Savunmasi", }, { "Kilic Savunmasi","?ftel Savunmasi","Bicak Savunmasi","Can Savunmasi","Yelpaze Savunmasi","Ok Savunmasi","Buyuye Karsi Dayanikllik", }, { "Max HP","Max SP", }, { "HP Uretimi","SP Uretimi", }, },
    { 1, { 53,55, }, { 59,60,61,62,63, }, { 15,16, }, { 13,12,14, }, },
    { 2, { 54,56, }, { 29,30,31,32,33,34,37, }, { 1,2, }, { 10,11, }, },
}


PetArray = {
    {53001, "atesankasi", "Ates Ankasi", 30068, PetExpTable, { 3,1,3,1, }, },
    {53002, "buzankasi", "Buz Ankasi", 30068, PetExpTable, { 3,3,1,1, }, },
    {53003, "rengeyigi", " Ren Geyigi", 30068, PetExpTable, { 3,1,1,3, }, },
    {53005, "gencazrail", "Genc Azrail", 30068, PetExpTable, { 2,1,3,2, }, },
    {53006, "genckurt", " Genc Kurt", 30068, PetExpTable, { 1,3,1,3, }, },
    {53007, "gencaslan", " Genc Aslan", 30068, PetExpTable, { 1,1,3,3, }, },
    {53008, "gencdomuz", "Genc Domuz", 30068, PetExpTable, { 1,3,3,1, }, },
    {53009, "genckaplan", "Genc Kaplan", 30068, PetExpTable, { 2,3,2,1, }, },
}


PET_NAME                 = 1
PET_LEVEL                = 2
PET_EXP                    = 3


PET_TYPE                = 1
PET_BON1                = 2
PET_BON2                = 3
PET_BON3                = 4
PET_BON4                = 5


PET_SUMMON                = 0
PET_UNSUMMON            = 1


PET_READ                = 0
PET_WRITE                = 1


PET_DATA                = 0
PET_BONUS                = 1


function inizializza(i)
    say_title(" Evcil Hayvan ")
    say("")
    say(" Merhaba , ?ce Evcil Hayvan?a ?im Vermelisin ")
    local scelta = select(" Tamam "," Daha Sonra ")
    if scelta == 2 then
        return -1
    end
    say_title(" Evcil Hayvan ")
    say("")
    say(" Evcil Hayvan?a Hangi ?mi Vermek ?tiyorsun? ")
    say("")
    say_reward(" ?im: ")
    local PetName = tostring(input())
    if PetName == "" then
        say_title(" Evcil Hayvan ")
        say("")
        say_reward(" Bo? B?akamazs?! ")
        return -1
    end
    local DATA_PATH = "locale/turkey/quest/object/pet/"
    local LOCAL_PATH = pc.get_name().."/"
    local PET_FILE = PetArray[i][2]..".txt"
    local PET_BONUS_FILE = PetArray[i][2].."_bonus.txt"
    if pc.getqf("local_path2") != 1 then
        os.execute("cd "..DATA_PATH.." && mkdir "..LOCAL_PATH.." && chmod 777 "..LOCAL_PATH)
        pc.setqf("local_path2", 1)
    end
    local file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE , "w")
    file:write(PetName.."\n1\n0\n") --nome livello exp
    io.close(file)
    local bonus = io.open(DATA_PATH..LOCAL_PATH..PET_BONUS_FILE , "w")
    bonus:write("0\n0\n0\n0\n0\n")   
    io.close(bonus)
    os.execute("cd "..DATA_PATH..LOCAL_PATH.." && chmod 777 *.txt")
    return 0
end


function GetGrade(i)
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local x = 0
    local y = 0
    local Grade = 1
    while true do
        x = x + 1
        y = y + 1
        if y == 10 then
            Grade = Grade + 1
            y = 0
        end
        if x == PetLevel then
            return Grade
        end
    end
end
    
function evoca(i, stato)
    local bonus = { 3,4,5,6, }
    local status = PetArray[i][6]
    local PetGrade = tonumber(GetGrade(i))
    local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ)
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local horse_level = horse.get_level()
    local apply = 0
    local level = 21 + i
    if stato == PET_SUMMON then
        local z = 1
        while true do
            if bonus[z] == nil then break end
            apply = PetGrade*status[z]
            affect.add_collect(bonus[z], apply, 60*60*8)
            z = z + 1
        end
        horse.set_level(level)
        horse.set_name(PetName)
        horse.summon()
        chat(" Evcil Hayvan????rd?. ")
        horse.set_level(horse_level)
    else
        local z = 1
        while true do
            if bonus[z] == nil then break end
            apply = PetGrade*status[z]
            affect.remove_collect(bonus[z], apply, 60*60*8)
            z = z + 1
        end
        horse.set_level(level)
        horse.unsummon()
        chat(" Evcil Hayvan??G?derdin. ")
        horse.set_level(horse_level)
    end
end


function PetInfo(x)
    while true do
        say_title(" Evcil Hayvan ")
        say("")
        say(" 4 Tane "..PetBonus[x][1].." Teknik Vard?")
        say(" A?a?daki Kategorilerden Bunlara Ula?abilirsin. ")
        local y = 0
        if x == 1 then
            y = select( " Sald??Teknikleri "," Sava? Teknikleri "," Vuru? Teknikleri "," ??c? Teknikler "," Geri D? ")
        else
            y = select( " Savunma Teknikleri "," Korunma Teknikleri "," Ya?am Teknikleri "," Yenileyici Teknikler "," Geri D? ")
        end
        if y == 5 then
            break
        end
        while true do
            say_title(" Evcil Hayvan ")
            say("Informazioni abilita':")
            say("")
            say("Con l'apprendimento di questa tecnica potrai")
            say("incrementare il valore "..PetBonus[x][1])
            say("Tecniche disponibili:")
            say("")
            local z = 1
            while true do
                if PetBonus[x][y+1][z] == nil then break end
                say_reward(PetBonus[x][y+1][z])
                z = z + 1
            end
            local b = select(" Geri D? ")
            if b == 1 then
                break
            end
        end
    end
end


function PetSet(i, t)
    say_title(" Evcil Hayvan ")
    say("")
    say(" "..PetBonus[t][1].." Tekni?mi Se?ek ?tiyorsun? ")
    say("")
    local conferma = select(" Evet "," Hay? ")
    if conferma == 2 then
        return
    end
    say_title(" Evcil Hayvan ")
    say("")
    say(" Yeni Beceriler Geli?tirip Hayvan??G?lendire- ")
    say(" bilirsin."..PetBonus[t][1].." Tekni? Se?ek ?tedi?ne ")
    say(" Eminmisin? E?r Tekni?ni Se?ikten Sonra ")
    say(" Be?nmezsen Yetene? De??ebilirsin. ")
    local k = select(" Evet "," Hay? ")
    if k == 2 then
        return
    end
    local w = 2
    local bonus = {}
    local bon = {}
    while true do
        if PetBonus[t][w] == nil then break end
        say_title(" Evcil Hayvan ")
        say(" Yetenek Se?e : ")
        say("")
        say_reward(" Yaln? Birini Se?bilirsin Dikkatli Se?m Yap ")
        say("")
        local x = select_table( PetBonus[t][w] )
        bonus[w-1] = x
        bon[w-1] = PetBonus[t][w][x]
        w = w + 1
    end
    say_title(" Evcil Hayvan ")
    say("")
    say(" Yetenek Se?min ? ?kilde :")
    say("")
    say(" Yetenek 1:  "..bon[1])
    say(" Yetenek 2:  "..bon[2])
    say(" Yetenek 3:  "..bon[3])
    say(" Yetenek 4:  "..bon[4])
    say("")
    say_reward(" Onayl?ormusun? ")
    say("")
    local c = select(" Evet "," Hay? ")
    if c == 2 then
        return
    end
    data_tool(i, t.."\n"..bonus[1].."\n"..bonus[2].."\n"..bonus[3].."\n"..bonus[4].."\n", PET_BONUS, PET_WRITE)
end


function PetMenuAbi(i)
    local check = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ))
    local status = PetArray[i][6]
    local PetGrade = tonumber(GetGrade(i))
    local PetType = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ))
    local bon1 = tonumber(data_tool(i, PET_BON1, PET_BONUS, PET_READ))
    local bon2 = tonumber(data_tool(i, PET_BON2, PET_BONUS, PET_READ))
    local bon3 = tonumber(data_tool(i, PET_BON3, PET_BONUS, PET_READ))
    local bon4 = tonumber(data_tool(i, PET_BON4, PET_BONUS, PET_READ))
    if check == 0 then
        while true do
            say_title(" Evcil Hayvan ")
            say(" Merhaba,")
            say(" Burada Evcil Hayvaninin Yetene?ni Se?bilirsin. ")
            say(" Konu Hakk?da Bilgin Yoksa Bilgi Kismindan, ")
            say(" Bakabilirsin. ")
            local z = select( "Ofansif","Defans","Bilgi","Kapat")
            if z == 1 then
                PetSet(i, z)
                return
            elseif z == 2 then
                PetSet(i, z)
                return
            elseif z == 3 then
                while true do
                    say_title(" Evcil Hayvan ")
                    say("")
                    say(" 4 Farkli Yetenek S???Vard?, ")
                    say(" Sald??Stiline Ba??Olarak. ")
                    say("")
                    local x = select( "Ofansif Stil","Defansif Stil"," Geri D? ")
                    if x == 1 then
                        PetInfo(x)
                    elseif x == 2 then
                        PetInfo(x)
                    elseif x == 3 then
                        break
                    end
                end
            elseif z == 4 then
                break
            end
        end
    else
        say_title(" Evcil Hayvan ")
        say("")
        say_reward(" Ne Yapmak ?tiyorsun? ")
        say("")
        local y = select(" Mevcut Yetenekler "," Yetenek S??la "," Geri D? ")
        if y == 1 then
            local point = {}
            local p = 1
            while true do
                if status[p] == nil then break end
                point[p] = status[p]*PetGrade
                p = p + 1
            end
            say_title(" Evcil Hayvan ")
            say(" Mevcut ?ellikleri: ")
            say("")
            say_reward(" Statlar? ")
            say("VIT:  +"..point[1])
            say("INT:  +"..point[2])
            say("STR:  +"..point[3])
            say("DEX:  +"..point[4])
            say("")
            say_reward(" Yetenekleri: ")
            say(PetBonus[PetType][2][bon1]..":  +"..PetGrade)
            say(PetBonus[PetType][3][bon2]..":  +"..PetGrade)
            say(PetBonus[PetType][4][bon3]..":  +"..PetGrade)
            say(PetBonus[PetType][5][bon4]..":  +"..PetGrade)
        elseif y == 2 then
            say_title(" Evcil Hayvan ")
            say(" Yetene?ni S??lamak ?tedi?nden Eminmisin?")
            say(" E?r ?leysen Se?ek ?tedi?n Yetene? Se?")
            local j = select(" Ofansif Stil "," Defansif Stil "," Geri D? ")
            if j == 1 then
                PetSet(i, j)
            elseif j == 2 then
                PetSet(i, j)
            else
                return
            end
        elseif y == 3 then
            return
        end
    end
end


function show_pet_menu(i)
    local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ)
    local PetRace = PetArray[i][3]
    local PetFood = PetArray[i][4]
    local PetGrade = tonumber(GetGrade(i))
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local PetExp = tonumber(data_tool(i, PET_EXP, PET_DATA, PET_READ))
    local PetNextExp = PetArray[i][5][PetLevel]
    while true do
        say_title(" Evcil Hayvan ")
        say("")
        say(" Ne Yapmak ?tiyorsun? ")
        say("")
        local s = select(" Pet ?ellikleri ", " Peti Besle ", " Pet Yetenekleri ", " Di?r ", " Kapat " )
        if s == 4 then
            say_title(" Evcil Hayvan ")
            say("")
            say(" Ne Yapmak ?tiyorsun? ")
            say("")
            local z = select( " ?im Ver ", " G?der ", " Geri D? ", " Kapat " )
            if z == 1 then
                say_title(" Evcil Hayvan ")
                say("")
                say(" Evcil Hayvan?a Hangi ?mi Vermek ?tiyorsun? ")
                say("")
                say_reward("?im :")
                local PetNewName = tostring(input())
                if PetNewName == "" then
                    say_title(" Evcil Hayvan ")
                    say("")
                    say_reward(" Bo? B?akamazs?! ")
                    return
                end
                if PetNewName == nome then
                    say_title(" Evcil Hayvan ")
                    say("")
                    say_reward(" Ayn??mi Veremezsin! ")
                    return
                end
                data_tool(i, PetNewName.."\n"..PetLevel.."\n"..PetExp.."\n", PET_DATA, PET_WRITE)
                evoca(i, PET_UNSUMMON)
                evoca(i, PET_SUMMON)
                return
            elseif z == 2 then
                evoca(i, PET_UNSUMMON)
                return
            elseif z == 3 then
            elseif z == 4 then
                break
            end
        elseif s == 1 then
            say_title(" Evcil Hayvan ")
            say("")
            say(" ?im: "..PetName.." ")
            say(" S??: "..PetRace.." ")
            say(" Level: "..PetLevel.." ")
            say(" Yetenek Seviyesi: "..PetGrade.." ")
            say(" Exp: "..PetExp.." / "..PetNextExp.." ")
            say(" Sa??: "..horse.get_health_pct().."% ")
            say(" Dayan?l??: "..horse.get_stamina_pct().."% ")
            say(" Yeme?: "..item_name(PetFood).." ")
            return
        elseif s == 2 then
            if pc.countitem(PetFood) > 0 then
                say_title(" Evcil Hayvan ")
                say("")
                say(" Evcil Hayvan? Art? Karn?Tok ")
                pc.removeitem(PetFood, 1)
                horse.feed()
                return
            else
                say_title(" Evcil Hayvan ")
                say("")
                say(" Evcil Hayvan? Beslemek ?in "..item_name(PetFood).." Adl?")
                say(" Yeme? Sahip Olmal??. ")
                say("")
                return
            end
        elseif s == 3 then
            if PetLevel >= 10 then
                PetMenuAbi(i)
                return
            else
                say_title(" Evcil Hayvan ")
                say("")
                say_reward(" Yetenekler 10 Level ?t?Evcil Hayvanlar ?indir ")
                return
            end
        elseif s == 5 then
            break
        end
    end
end


function PetGiveExp(i, Point)
    local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ)
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local PetExp = tonumber(data_tool(i, PET_EXP, PET_DATA, PET_READ))
    local PetNextExp = PetArray[i][5][PetLevel]
    if PetLevel == 150 then
        return
    end
    local PetNewExp = PetExp + Point
    while true do
        if PetNewExp < PetNextExp then break end
        PetNewExp = PetNewExp - PetNextExp
        PetLevel = PetLevel + 1
    end
    data_tool(i, PetName.."\n"..PetLevel.."\n"..PetNewExp.."\n", PET_DATA, PET_WRITE)
end


function data_tool(i, linea, tipo, modo)
    local DATA_PATH = "locale/turkey/quest/object/pet//"
    local LOCAL_PATH = pc.get_name().."/"
    local x = 1
    local file = ""
    local PET_FILE = ""
    local PET_BACKUP = ""
    if tipo == PET_DATA then
        PET_FILE = PetArray[i][2]..".txt"
        PET_BACKUP = PetArray[i][2]..".bak"
    elseif tipo == PET_BONUS then
        PET_FILE = PetArray[i][2].."_bonus.txt"
        PET_BACKUP = PetArray[i][2].."_bonus.bak"
    end
    if modo == PET_READ then
        file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE, "r")
        while true do
            local line = file:read("*l")
            if line == nil then
                break
            end
            text = string.gsub(line, "\n", "")
            if x == linea then
                io.close(file)
                return text
            end
            x = x + 1
        end
        io.close(file)
    elseif modo == PET_WRITE then
        os.execute("cd "..DATA_PATH..LOCAL_PATH.." && mv "..PET_FILE.." "..PET_BACKUP)
        file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE, "w")
        file:write(linea)
        io.close(file)
        os.execute("cd "..DATA_PATH..LOCAL_PATH.." && chmod 777 "..PET_FILE)
    end
end

get_mob_level =
    {
        [2051] = 65,
        [2052] = 67,
        [2053] = 69,
        [2054] = 71,
        [2055] = 73,
        [11116] = 90,
        [2061] = 60,
        [2062] = 62,
        [2063] = 64,
        [2064] = 66,
        [2065] = 68,
        [2071] = 70,
        [2072] = 72,
        [2073] = 74,
        [2074] = 76,
        [2075] = 78,
        [2076] = 78,
        [11117] = 90,
        [2091] = 60,
        [2092] = 79,
        [2093] = 65,
        [2094] = 72,
        [2095] = 70,
        [2101] = 19,
        [2102] = 37,
        [2103] = 39,
        [2104] = 44,
        [2105] = 47,
        [2106] = 48,
        [2107] = 51,
        [2108] = 54,
        [5131] = 22,
        [2401] = 87,
        [5132] = 25,
        [2402] = 89,
        [5133] = 27,
        [2131] = 60,
        [2132] = 62,
        [2133] = 64,
        [2134] = 66,
        [2135] = 68,
        [101] = 1,
        [102] = 3,
        [103] = 4,
        [2152] = 37,
        [105] = 9,
        [106] = 13,
        [107] = 16,
        [108] = 7,
        [109] = 10,
        [110] = 12,
        [111] = 15,
        [112] = 19,
        [113] = 21,
        [114] = 18,
        [115] = 24,
        [5141] = 35,
        [131] = 8,
        [132] = 9,
        [133] = 11,
        [134] = 14,
        [135] = 18,
        [136] = 21,
        [137] = 12,
        [138] = 15,
        [139] = 17,
        [140] = 20,
        [141] = 24,
        [142] = 26,
        [143] = 24,
        [144] = 29,
        [151] = 9,
        [152] = 16,
        [153] = 10,
        [154] = 21,
        [2203] = 70,
        [2204] = 71,
        [2205] = 72,
        [2206] = 73,
        [2207] = 78,
        [171] = 1,
        [172] = 3,
        [173] = 4,
        [174] = 6,
        [175] = 9,
        [2224] = 71,
        [177] = 16,
        [178] = 7,
        [179] = 10,
        [180] = 12,
        [181] = 15,
        [182] = 19,
        [183] = 21,
        [184] = 18,
        [185] = 24,
        [2234] = 71,
        [2235] = 72,
        [191] = 30,
        [192] = 31,
        [193] = 33,
        [194] = 35,
        [5153] = 49,
        [5157] = 54,
        [2291] = 75,
        [2292] = 99,
        [2293] = 99,
        [5161] = 30,
        [2301] = 65,
        [2302] = 67,
        [2303] = 69,
        [2304] = 70,
        [2305] = 71,
        [2306] = 84,
        [2307] = 86,
        [2311] = 74,
        [2312] = 76,
        [2313] = 77,
        [2314] = 80,
        [2315] = 82,
        [301] = 18,
        [302] = 20,
        [303] = 25,
        [304] = 25,
        [8501] = 35,
        [8502] = 30,
        [8503] = 25,
        [8504] = 5,
        [8505] = 10,
        [8506] = 12,
        [8507] = 15,
        [8508] = 20,
        [8509] = 25,
        [8510] = 21,
        [8511] = 11,
        [331] = 18,
        [332] = 20,
        [333] = 25,
        [334] = 25,
        [351] = 18,
        [352] = 20,
        [353] = 25,
        [354] = 25,
        [2403] = 89,
        [2404] = 90,
        [2411] = 91,
        [2412] = 93,
        [2413] = 95,
        [2414] = 97,
        [2451] = 84,
        [5127] = 54,
        [2452] = 86,
        [2431] = 80,
        [2432] = 82,
        [2433] = 82,
        [2434] = 83,
        [2454] = 90,
        [391] = 23,
        [392] = 26,
        [393] = 28,
        [394] = 31,
        [395] = 23,
        [396] = 26,
        [397] = 28,
        [398] = 31,
        [401] = 26,
        [402] = 27,
        [403] = 29,
        [404] = 30,
        [405] = 33,
        [406] = 35,
        [8600] = 73,
        [8601] = 86,
        [8602] = 73,
        [8603] = 86,
        [8604] = 73,
        [8605] = 86,
        [8606] = 73,
        [8607] = 86,
        [8608] = 73,
        [8609] = 86,
        [8610] = 73,
        [8611] = 86,
        [8612] = 73,
        [8613] = 86,
        [8614] = 73,
        [8615] = 86,
        [8616] = 86,
        [11108] = 70,
        [431] = 31,
        [432] = 33,
        [433] = 35,
        [434] = 36,
        [435] = 38,
        [436] = 40,
        [2491] = 93,
        [2492] = 95,
        [2493] = 97,
        [2494] = 88,
        [2495] = 90,
        [451] = 26,
        [452] = 27,
        [453] = 29,
        [454] = 30,
        [455] = 33,
        [456] = 35,
        [2505] = 83,
        [2506] = 84,
        [2507] = 85,
        [2508] = 79,
        [2509] = 80,
        [2510] = 81,
        [2511] = 82,
        [2512] = 83,
        [2513] = 84,
        [2514] = 86,
        [1175] = 65,
        [491] = 32,
        [492] = 37,
        [493] = 39,
        [494] = 45,
        [2543] = 81,
        [2544] = 82,
        [2545] = 83,
        [2546] = 84,
        [2547] = 86,
        [501] = 29,
        [502] = 32,
        [503] = 35,
        [504] = 36,
        [531] = 35,
        [532] = 37,
        [533] = 40,
        [534] = 42,
        [2591] = 89,
        [2592] = 89,
        [2593] = 89,
        [2594] = 89,
        [2595] = 89,
        [2596] = 89,
        [2597] = 91,
        [2598] = 91,
        [551] = 29,
        [552] = 32,
        [553] = 35,
        [554] = 36,
        [2482] = 92,
        [2483] = 94,
        [2484] = 96,
        [5134] = 29,
        [591] = 42,
        [595] = 42,
        [601] = 26,
        [602] = 29,
        [603] = 31,
        [604] = 33,
        [2151] = 19,
        [104] = 6,
        [631] = 34,
        [632] = 36,
        [633] = 39,
        [634] = 40,
        [635] = 44,
        [636] = 46,
        [637] = 49,
        [2155] = 47,
        [2156] = 48,
        [651] = 34,
        [652] = 36,
        [653] = 39,
        [654] = 40,
        [2157] = 51,
        [656] = 46,
        [657] = 49,
        [2158] = 54,
        [2501] = 79,
        [2502] = 80,
        [2503] = 81,
        [5001] = 10,
        [2504] = 82,
        [691] = 50,
        [692] = 55,
        [693] = 60,
        [701] = 35,
        [702] = 38,
        [703] = 41,
        [704] = 44,
        [705] = 48,
        [706] = 49,
        [707] = 51,
        [731] = 52,
        [732] = 53,
        [733] = 54,
        [734] = 54,
        [735] = 55,
        [736] = 56,
        [737] = 57,
        [751] = 35,
        [752] = 38,
        [753] = 41,
        [754] = 44,
        [755] = 48,
        [756] = 49,
        [757] = 51,
        [771] = 52,
        [772] = 53,
        [773] = 54,
        [774] = 54,
        [775] = 55,
        [776] = 56,
        [777] = 57,
        [7050] = 35,
        [2481] = 91,
        [791] = 54,
        [792] = 62,
        [793] = 64,
        [794] = 72,
        [795] = 54,
        [796] = 62,
        [7051] = 31,
        [7001] = 52,
        [7002] = 53,
        [2191] = 67,
        [7004] = 54,
        [7005] = 55,
        [7006] = 56,
        [7007] = 56,
        [7008] = 52,
        [2192] = 72,
        [7010] = 54,
        [11107] = 70,
        [7012] = 52,
        [7013] = 53,
        [7014] = 54,
        [7015] = 54,
        [7016] = 55,
        [7017] = 56,
        [7018] = 56,
        [7019] = 59,
        [7020] = 59,
        [7021] = 60,
        [7022] = 61,
        [7023] = 62,
        [7024] = 64,
        [7025] = 66,
        [7026] = 67,
        [7027] = 70,
        [7028] = 72,
        [7029] = 35,
        [7030] = 31,
        [7031] = 33,
        [7032] = 35,
        [7033] = 36,
        [7034] = 38,
        [7035] = 40,
        [7036] = 52,
        [7037] = 53,
        [7038] = 54,
        [7039] = 54,
        [7040] = 55,
        [7041] = 56,
        [7042] = 57,
        [7043] = 81,
        [7044] = 81,
        [901] = 49,
        [902] = 51,
        [903] = 53,
        [904] = 55,
        [905] = 58,
        [906] = 58,
        [907] = 59,
        [5004] = 80,
        [5005] = 85,
        [7054] = 36,
        [2541] = 79,
        [7056] = 40,
        [7057] = 52,
        [7058] = 53,
        [7059] = 54,
        [7060] = 54,
        [2542] = 80,
        [7062] = 56,
        [2201] = 69,
        [7064] = 81,
        [7065] = 81,
        [7066] = 82,
        [7067] = 83,
        [7068] = 83,
        [2202] = 69,
        [7070] = 85,
        [7071] = 33,
        [7072] = 35,
        [7073] = 36,
        [7074] = 38,
        [155] = 24,
        [932] = 51,
        [933] = 53,
        [934] = 55,
        [935] = 58,
        [936] = 58,
        [937] = 59,
        [7082] = 83,
        [7083] = 83,
        [7084] = 84,
        [7085] = 85,
        [7086] = 35,
        [7087] = 36,
        [7088] = 38,
        [7089] = 40,
        [7090] = 54,
        [7091] = 55,
        [7092] = 56,
        [7093] = 57,
        [7094] = 83,
        [7095] = 83,
        [7096] = 84,
        [7097] = 85,
        [991] = 59,
        [992] = 60,
        [993] = 61,
        [1001] = 57,
        [1002] = 58,
        [1003] = 59,
        [1004] = 60,
        [5101] = 22,
        [5102] = 25,
        [5103] = 27,
        [5104] = 29,
        [5111] = 35,
        [5112] = 37,
        [5113] = 39,
        [5114] = 40,
        [5115] = 41,
        [5116] = 42,
        [5121] = 45,
        [5122] = 47,
        [5123] = 49,
        [5124] = 52,
        [5125] = 53,
        [5126] = 54,
        [1031] = 67,
        [1032] = 69,
        [1033] = 70,
        [1034] = 71,
        [1035] = 72,
        [1036] = 73,
        [1037] = 71,
        [1038] = 72,
        [1039] = 73,
        [1040] = 74,
        [1041] = 75,
        [2222] = 69,
        [5142] = 37,
        [5143] = 39,
        [5144] = 40,
        [5145] = 41,
        [5146] = 42,
        [2223] = 70,
        [11109] = 70,
        [5151] = 45,
        [5152] = 47,
        [176] = 13,
        [5154] = 52,
        [5155] = 53,
        [5156] = 54,
        [1061] = 67,
        [1062] = 69,
        [1063] = 70,
        [1064] = 71,
        [1065] = 72,
        [1066] = 73,
        [1067] = 71,
        [1068] = 72,
        [1069] = 73,
        [1070] = 74,
        [1071] = 75,
        [2227] = 90,
        [1091] = 75,
        [1092] = 75,
        [1093] = 78,
        [1094] = 75,
        [1095] = 82,
        [1096] = 75,
        [2231] = 69,
        [1101] = 62,
        [1102] = 63,
        [1103] = 64,
        [1104] = 64,
        [1105] = 65,
        [1106] = 66,
        [1107] = 66,
        [2233] = 70,
        [1131] = 81,
        [1132] = 81,
        [1133] = 82,
        [1134] = 83,
        [1135] = 83,
        [1136] = 84,
        [1137] = 85,
        [1151] = 52,
        [1152] = 53,
        [1153] = 54,
        [1154] = 54,
        [1155] = 55,
        [1156] = 56,
        [1157] = 56,
        [2221] = 69,
        [1171] = 62,
        [1172] = 63,
        [1173] = 64,
        [1174] = 64,
        [2153] = 39,
        [1176] = 66,
        [1177] = 66,
        [1191] = 70,
        [1192] = 70,
        [11110] = 70,
        [2154] = 44,
        [11505] = 100,
        [11506] = 100,
        [11507] = 100,
        [11508] = 100,
        [11509] = 100,
        [11510] = 100,
        [2225] = 72,
        [1301] = 57,
        [1302] = 59,
        [1303] = 58,
        [1304] = 75,
        [1305] = 61,
        [1306] = 75,
        [1307] = 80,
        [1308] = 40,
        [1309] = 65,
        [1310] = 95,
        [7045] = 82,
        [7046] = 83,
        [2226] = 60,
        [7047] = 83,
        [7048] = 84,
        [1331] = 57,
        [1332] = 59,
        [1333] = 58,
        [1334] = 75,
        [1335] = 61,
        [5002] = 75,
        [5003] = 1,
        [7052] = 33,
        [11111] = 70,
        [7053] = 35,
        [7055] = 38,
        [1401] = 66,
        [1402] = 73,
        [1403] = 77,
        [7061] = 55,
        [7003] = 54,
        [7063] = 57,
        [5162] = 43,
        [7069] = 84,
        [5163] = 55,
        [931] = 49,
        [7076] = 54,
        [2232] = 69,
        [1501] = 69,
        [1502] = 72,
        [1503] = 76,
        [7078] = 55,
        [7079] = 56,
        [7080] = 57,
        [7081] = 82,
        [7075] = 40,
        [11100] = 50,
        [7077] = 54,
        [7009] = 53,
        [1601] = 68,
        [1602] = 70,
        [1603] = 75,
        [11101] = 50,
        [11102] = 50,
        [11113] = 90,
        [11103] = 50,
        [11104] = 50,
        [7049] = 85,
        [11105] = 50,
        [11106] = 70,
        [655] = 44,
        [1901] = 72,
        [1902] = 77,
        [1903] = 82,
        [1904] = 40,
        [1905] = 65,
        [1906] = 95,
        [11112] = 90,
        [2453] = 88,
        [11114] = 90,
        [2001] = 43,
        [2002] = 45,
        [2003] = 48,
        [2004] = 50,
        [2005] = 52,
        [11115] = 90,
        [2031] = 50,
        [2032] = 52,
        [2033] = 54,
        [2034] = 56,
        [2035] = 58,
        [2036] = 58,
}

function level_aldir(carlevel)
    if pc.get_level() > carlevel then
        return
    else
        local level = pc.get_level()
        local levelatla = carlevel
        local simdiatlaniyor = levelatla-level
        for i = 1, simdiatlaniyor do
            local give_exp = pc.get_next_exp()
            pc.give_exp2(give_exp)     
        end
    end
end 

function getinput(par)
    cmdchat("GetInputStringStart")
    local ret = input(cmdchat(par))
    cmdchat("GetInputStringEnd")
    return ret
end

function yang_Ayarla()
    yang2 = tostring(pc.get_gold())
    local yang = pc.get_gold() 
    local sayac = 10
    local basamak = 1
    local ilkhal = basamak
    while true do
        if yang / sayac >= 1 then
            basamak = basamak + 1
            sayac = sayac * 10
        else
            break
        end
    end
    t = {}
    sonucText = ""
    for i=1, string.len(yang2) do
        t[i]= (string.sub(yang2,i,i))
    end
    for k , v in pairs(t) do
        if (basamak  == 9 or basamak == 6 or basamak == 3) and sonucText !=  "" then
            sonucText = sonucText.."."
            sonucText = sonucText..v
        else
            sonucText = sonucText..v
        end
        basamak = basamak - 1
    end
    return sonucText
end 

function inc_today_count(questname, flag_name, count)
    local today = math.floor(get_global_time() / 86400)
    local today_flag = flag_name.."_today"
    local today_count_flag = flag_name.."_today_count"
    local last_day = pc.getqf(questname, today_flag)
    if last_day == today then
        pc.setf(questname, today_count_flag, pc.getf(questname, today_count_flag) + 1)
    else
        pc.setf(questname, today_flag, today)
        pc.setf(questname, today_count_flag, 1)
    end
end

function LIB_duration(ipe)
    -- if have == nil then
    -- seconds = ipe - get_global_time()
    -- chat("nil")
    -- else
    -- seconds = (get_global_time() + ipe) - get_global_time()
    -- chat("no nil")
    -- end
    
    if ipe >= get_global_time() then
    seconds = ipe - get_global_time()
    --chat("nil")
    else
    seconds = (get_global_time() + ipe) - get_global_time()
    --chat("no nil")
    end
    
    
    local days = 0
    local hours = math.floor(seconds / 3600)
    local mins = math.floor((seconds - (hours*3600)) / 60)
    local secs = math.floor(seconds - hours*3600 - mins*60 )
    local t = ""
    if tonumber(hours) >= 24 then
        days = math.floor(hours / 24)
        hours = math.floor(hours - (days*24))
    end
    if tonumber(days) == 1 then
        t = t..days.." Gun "
    elseif tonumber(days) >= 1 then
        t = t..days.." Gun "
    end
    if tonumber(hours) == 1 then
        t = t..hours.." Saat "
    elseif tonumber(hours) >= 1 then
        t = t..hours.." Saat "
    end
    if tonumber(mins) == 1 then
        t = t..mins.." Dakika "
    elseif tonumber(mins) >= 1 then
        t = t..mins.." Dakika "
    end
    if tonumber(secs) == 1 then
        t = t..secs.." Saniye "
    elseif tonumber(secs) >= 1 then
        t = t..secs.." Saniye "
    end
    if t == "" then
        return "(Keine Zeit Vorhanden!)"
    end
    return t
end

function say_npc()
    say_title(""..mob_name(npc.get_race()).."")
end

-- This function will return true always in window os,
--  but not in freebsd.
-- (In window os, RAND_MAX = 0x7FFF = 32767.)
function drop_gamble_with_flag(drop_flag)
        local dp, range = pc.get_killee_drop_pct()
        dp = 40000 * dp / game.get_event_flag(drop_flag)
        if dp < 0 or range < 0 then
            return false
        end
        return dp >= number(1, range)
end

function say2(str,dx)
    local maxl,actl,pat = dx or 50,0,'(.-)(%[.-%])()'
    local result,nb,lastPos,outp = {},0,0,''
    local function bere(stx)
        for le in string.gfind(stx,'((%S+)%s*)') do 
            if actl + string.len(le) > maxl then 
                outp = outp..'[ENTER]' 
                actl = 0 
            end 
            outp = outp..le 
            actl = actl + string.len(le) 
        end 
    end
    for part, dos,pos in string.gfind(str, pat) do 
        if part ~= '' then 
            bere(part)
        end
        outp = outp..dos 
        lastPos = pos 
    end 
    bere(string.sub(str,lastPos))
    say(outp)
    say()
end

function say_mavi(name) say(color256(0, 0, 255)..name..color256(0, 0, 255)) end
function say_kirmizi(name) say(color256(255, 106, 106)..name..color256(255, 106, 106)) end
function say_yesil(name) say(color256(0, 238, 0)..name..color256(0, 238, 0)) end
function say_altin(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end
function say_siyah(name) say(color256(0, 0, 0)..name..color256(0, 0, 0)) end
function say_beyaz(name) say(color256(255, 255, 255)..name..color256(255, 255, 255)) end
function say_sari(name) say(color256(255, 255, 0)..name..color256(255, 255, 0)) end
function say_mavi2(name) say(color256(0, 206, 209)..name..color256(0, 206, 209)) end

mysql_query10 = function(query)
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)  %s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2  ^10),{},{}
    --os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- fur MySQL51
    os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- fur MySQL55
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tostring(b) or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tostring(b) or b or 'NULL'
    end) end
    return out
end 

QuestFolder = get_locale_base_path().."/quest/sancak/"
Post = {['Folder'] = QuestFolder.."sistemler/offlinemesaj/", Delimiter = "~~~~~~~~~~"}

--**
--** Mesajý gönder
--**
function Post.ReadFromKeyboard(title)
    local mex = {}
    local n_righe = 14
    local stop = false
    while (n_righe >= 0 and not stop) do
        local corretto = false
        local riga
        while (not corretto) do
            say_title(title)
            say_yesil("Göndermek istediðiniz mesajý yazýnýz.")
            if n_righe > 0 then
                if n_righe > 1 then
                    say_mavi2("Yazabileceðiniz Satýr Sayýsý: "..n_righe.." [ENTER]")
                else
                    say_kirmizi("Son 1 Satýr Yazabilirsin.[ENTER]")
                end
            else
                say_sari("Mesajýný Girebilirsin:")
            end
            riga = tostring(input())
            if riga == "" or (string.find(riga, '%d') == nil and string.find(riga, '%a') == nil) then
                say_title(title)
                say_kirmizi("Yazdýðýn yazýlar geçerli deðil.")
                say_kirmizi("Lütfen tekrar yaz.")
                wait()
            else
                corretto = true
            end
        end
        table.insert(mex, riga)
        say_title(title)
        if n_righe == 0 then
            say_kirmizi("Daha fazla yazamazsýn.")
            stop = true
            wait()
        else
            say_sari("Baþka birþey yazmak ister misin?")
            local s = select("Evet","Hayýr")
            if s == 2 then
                stop = true
            end
            n_righe = n_righe-1
        end
    end
    return mex
end
        
--**
--** Mesaj gönderme
--**
function Post.SendMex(addr, mex, sender)
    local FileName = Post.Folder..addr
    if sender == nil then
        sender = pc.get_name()
    end
    if io.open(FileName, "r") == nil then
        io.output(FileName)
        io.write(sender.."\n")
        io.write("Gönderilen Tarih: "..os.date("%d/%m/%Y, %H:%m").."\n")
        for i,v in ipairs(mex) do
            io.write(v.."\n")
        end
        io.write(Post.Delimiter.."\n")
        io.flush()
        io.close()
        return
    end
    local out_file = io.open(FileName, "a")
    out_file:write(sender.."\n")
    out_file:write("Gönderilen Tarih: "..os.date("%d/%m/%Y, %H:%m").."\n")
    for i,v in ipairs(mex) do
        out_file:write(v.."\n")
    end
    out_file:write(Post.Delimiter.."\n")
    out_file:flush()
    out_file:close()   
end

--**
--** Gelen mesajlarý okuma
--**
function Post.CheckMex()
    local FileName = Post.Folder..pc.get_name()
    if io.open(FileName, "r") == nil then
        return false
    else
        return true
    end
end

--**
--** Gelen mesaj varmý die kontrol
--**
function Post.CountMex()
    local FileName = Post.Folder..pc.get_name()
    if io.open(FileName, "r") == nil then
        return false
    end
    io.input(FileName)
    local n_mex = 0
    for line in io.lines() do
        if line == Post.Delimiter then
            n_mex = n_mex+1
        end
    end
    io.input():close()
    return true, n_mex
end

--**
--** Gelen mesajlarý okur ve içindekileri siler
--**
function Post.ReadMex()
    local FileName = Post.Folder..pc.get_name()
    if io.open(FileName, "r") != nil then
        io.input(FileName)
        local mex = {}
        for line in io.lines() do
            table.insert(mex, line)
        end
        io.input():close()
        os.remove(FileName)
        return mex
    end
end

--**
--** Tüm mesajlar silinsin
--**
function Post.DeleteMex()
    local FileName = Post.Folder..pc.get_name()   
    if io.open(FileName, "r") != nil then
        os.remove(FileName)
    end
end

function genel_veri(gelen_veri) 
    miktar2 = tostring(gelen_veri) 
    local miktar = gelen_veri 
    local sayac = 10 
    local basamak = 1 
    local ilkhal = basamak 
    while true do 
        if miktar / sayac >= 1 then 
            basamak = basamak + 1 
            sayac = sayac * 10 
        else 
            break 
        end 
    end 
    t = {} 
    sonucText = "" 
    for i=1, string.len(miktar2) do 
        t[i]= (string.sub(miktar2,i,i)) 
    end 
    for k , v in pairs(t) do--1324 
        if (basamak  == 9 or basamak == 6 or basamak == 3) and sonucText !=  "" then 
            sonucText = sonucText.."." 
            sonucText = sonucText..v 
        else 
            sonucText = sonucText..v 
        end 
        basamak = basamak - 1 
    end 
    return sonucText 
end 


function check_file_exists(sPath)
    local f = io.open(sPath, "r")
    if f ~= nil then
        io.close(f)
        return true
    else
        return false
    end
end

function sancak_level_aldir(carlevel) 
    if pc.get_level() > carlevel then 
        return 
    else 
        local level = pc.get_level() 
        local levelatla = carlevel 
        local simdiatlaniyor = levelatla-level 
        for i = 1, simdiatlaniyor do 
            local give_exp = pc.get_next_exp() 
            pc.give_exp2(give_exp)     
        end 
    end 
end 

function string:split(delimiter)
    local result = {}
    local from = 1
    local delim_from, delim_to = string.find(self, delimiter, from)

    while delim_from do
        table.insert(result, string.sub(self, from , delim_from-1))
        from = delim_to + 1
        delim_from, delim_to = string.find(self, delimiter, from)
    end
    table.insert(result, string.sub(self, from))
    return result
end

q = q or {}

q["category_num"] = {"MAIN_QUEST", "COLLECT_QUEST", "LEVELUP_QUEST", "SYSTEM_QUEST", "NONE_TYPE_QUEST"}
q["category_map"] = {}

function q.GetCategoryIndex(category)
    for i = 1, 6 do
        if q["category_num"][i] == category then
            return (i-1)
        end
    end
    return
end

function q.GetQuestCategory()
    local qName = q.getcurrentquestname()
    for questName, questCategory in pairs(q["category_map"]) do
        --syschat(questName.." "..questCategory)
        if questName == qName then
            return questCategory
        end
    end
    return
end

function ReadQuestCategoryFile()
    for line in io.lines(get_locale_base_path().."/quest/questcategory.txt") do
        local tokens = string.split(line, "\t")
        local qName = tokens[1] or ""
        local category = string.gsub(tokens[2], "%s", "") or ""

        q["category_map"][qName] = q.GetCategoryIndex(category)
    end
end

function send_letter(text, cat)
    cat = cat or q.GetQuestCategory()
    text = cat..text
    makequestbutton(text)
    set_skin(NOWINDOW)
    q.set_title(text)
    q.start()
end

ReadQuestCategoryFile()
 
Kod:
dofile('locale/turkey/quest/questing.lua')
CONFIRM_NO = 0
CONFIRM_YES = 1
CONFIRM_OK = 1
CONFIRM_TIMEOUT = 2

MALE = 0
FEMALE = 1

item3 = {}

newline = "[ENTER]"

function notice_multiline( str , func )
    local p = 0
    local i = 0
    while true do
        i = string.find( str, "%[ENTER%]", i+1 )
        if i == nil then
            if string.len(str) > p then
                func( string.sub( str, p, string.len(str) ) )
            end
            break
        end
        func( string.sub( str, p, i-1 ) )
        p = i + 7
    end
end

function get_biolog_extra_info(mission, extra1)

    local analiza = false        -- Jezeli false to biolog zaczyna sie od badan (30 lv.), jezeli true biolog zaczyna sie od analiz (4 lv.)
    local drop = true            -- ANALIZA Jezeli false to przedmioty dropia dopuki nie skonczy danej misji, jezeli true to gracz moze miec w EQ tyle sztuk przedmiotu ile musi jeszcze oddac
    local drop2 = false            -- BADANIA Jezeli false to przedmioty dropia dopuki nie skonczy danej misji, jezeli true to gracz moze miec w EQ tyle sztuk przedmiotu ile musi jeszcze oddac
    local reward_in_btn = true        -- ANALIZA Jezeli true to nagrode moze zdobyc poprzez gui, jezeli false to po nagrode trzeba lecieæ do Biologa/Beak-Go
    local beakgo_reward = true        -- BADANIA Jezeli true to trzeba zapierdalac do Beak-Go zeby odebrac nagrode z badan, jezeli false to nagrode dostaniemy po ukonczeniu misji (button lub rozmowa z biologiem)
    -- ALL INFO END

    local info = {
        [1] = {
            ['poziom_misji'] = 4,
            ['id1'] = 50701,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {173},
            ['nagroda_yang'] = 10000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [2] = {
            ['poziom_misji'] = 7,
            ['id1'] = 50702,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {175},
            ['nagroda_yang'] = 15000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [3] = {
            ['poziom_misji'] = 10,
            ['id1'] = 50703,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {177},
            ['nagroda_yang'] = 20000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [4] = {
            ['poziom_misji'] = 15,
            ['id1'] = 50704,
            ['cid1'] = 5,
            ['luck'] = 100,
            ['mob_id1'] = {181},
            ['nagroda_yang'] = 25000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [5] = {
            ['poziom_misji'] = 20,
            ['id1'] = 50705,
            ['cid1'] = 10,
            ['luck'] = 100,
            ['mob_id1'] = {182},
            ['nagroda_yang'] = 30000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [6] = {
            ['poziom_misji'] = 25,
            ['id1'] = 50706,
            ['cid1'] = 10,
            ['luck'] = 100,
            ['mob_id1'] = {183},
            ['nagroda_yang'] = 40000000,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {0},    -- Przedmioty dla wszystkich
            }
        },
        [7] = {
            ['poziom_misji'] = 30,
            ['id1'] = 30006,
            ['cid1'] = 10,
            ['chance_id1'] = 50,
            ['id2'] = 30220,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {636, 656, 601, 602},
            ['mob_id2'] = {631, 632, 633, 634, 635, 636, 637},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50109},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+10 Hareket Hýzý ",
            ['nagroda_bonus_id'] = {apply.MOV_SPEED},
            ['nagroda_bonus_wartosc'] = {10}
        },
        [8] = {
            ['poziom_misji'] = 40,
            ['id1'] = 30047,
            ['cid1'] = 15,
            ['chance_id1'] = 50,
            ['id2'] = 30221,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {706, 756},
            ['mob_id2'] = {731, 732, 733, 734, 735, 736, 737, 701, 702, 703, 704, 705, 706, 707},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50110},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+5 Saldýrý Hýzý ",
            ['nagroda_bonus_id'] = {apply.ATT_SPEED},
            ['nagroda_bonus_wartosc'] = {5}
        },
        [9] = {
            ['poziom_misji'] = 50,
            ['id1'] = 30015,
            ['cid1'] = 15,
            ['chance_id1'] = 50,
            ['id2'] = 30222,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {1001},
            ['mob_id2'] = {1001, 1002, 1003, 1004},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50111},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+60 Savunma ",
            ['nagroda_bonus_id'] = {apply.DEF_GRADE_BONUS},
            ['nagroda_bonus_wartosc'] = {60}
        },
        [10] = {
            ['poziom_misji'] = 60,
            ['id1'] = 30050,
            ['cid1'] = 20,
            ['chance_id1'] = 50,
            ['id2'] = 30223,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {1107, 1137},
            ['mob_id2'] = {1101, 1102, 1103, 1104, 1105, 1106, 1107},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50112},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+50 Saldýrý Deðeri ",
            ['nagroda_bonus_id'] = {apply.ATT_GRADE_BONUS},
            ['nagroda_bonus_wartosc'] = {50}
        },
        [11] = {
            ['poziom_misji'] = 70,
            ['id1'] = 30165,
            ['cid1'] = 25,
            ['chance_id1'] = 50,
            ['id2'] = 30224,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {2301, 2302, 2303, 2304, 2305, 2311, 2312, 2313, 2314, 2315},
            ['mob_id2'] = {2301, 2302, 2303, 2304, 2305, 2311, 2312, 2313, 2314, 2315},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50113},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+10% Saldýrýlara Karþý Savunma[ENTER]+11% Hareket Hýzý ",
            ['nagroda_bonus_id'] = {POINT_DEF_BONUS, apply.MOV_SPEED},
            ['nagroda_bonus_wartosc'] = {10, 11}
        },
        [12] = {
            ['poziom_misji'] = 80,
            ['id1'] = 30166,
            ['cid1'] = 30,
            ['chance_id1'] = 50,
            ['id2'] = 30225,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {1401, 1402, 1403, 1601, 1602, 1603},
            ['mob_id2'] = {1401, 1402, 1403, 1601, 1602, 1603},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50114},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+6% Saldýrý Hýzý ve [ENTER]+10% Saldýrý Deðeri ",
            ['nagroda_bonus_id'] = {apply.ATT_SPEED, POINT_ATT_BONUS},
            ['nagroda_bonus_wartosc'] = {6, 10}
        },
        [13] = {
            ['poziom_misji'] = 85,
            ['id1'] = 30167,
            ['cid1'] = 40,
            ['chance_id1'] = 50,
            ['id2'] = 30226,
            ['chance_id2'] = 100,
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {2311, 2312, 2313, 2314, 2315},
            ['mob_id2'] = {2311, 2312, 2313, 2314, 2315},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50115},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+10% Yarý insan saldýrý hasarý ",
            ['nagroda_bonus_id'] = {apply.ATTBONUS_HUMAN},
            ['nagroda_bonus_wartosc'] = {10}
        },
        [14] = {
            ['poziom_misji'] = 90,
            ['id1'] = 30168,
            ['cid1'] = 50,
            ['chance_id1'] = 1000,        -- tu musi byc 1000, drop z kazdego bossa
            ['id2'] = 30227,
            ['chance_id2'] = 1000,        -- tu musi byc 1000, drop z kazdego bossa
            ['luck'] = 100,
            ['wait_time'] = 0,
            ['mob_id1'] = {691, 792, 791, 1093, 1304, 2091, 2191, 2206, 1901, 3090, 3290, 3590},
            ['mob_id2'] = {1093, 1304, 1901, 3090, 3290, 3590},
            ['nagroda_yang'] = 0,
            ['nagroda_exp'] = 0,
            ['nagroda_itemy'] = {
                [0] = {0},    -- Przedmioty tylko dla wojownika
                [1] = {0},    -- Przedmioty tylko dla ninjy
                [2] = {0},    -- Przedmioty tylko dla sury
                [3] = {0},    -- Przedmioty tylko dla szamana
                [4] = {50114, 50114},    -- Przedmioty dla wszystkich
            },
            ['nagroda_tekst'] = "+8% Yarý insan saldýrý hasarý ",
            ['nagroda_bonus_id'] = {apply.ATTBONUS_HUMAN},
            ['nagroda_bonus_wartosc'] = {8}
        }
    }

    -- info[1]['poziom_misji']

    -- TU JU¯ NIC NIE RUSZAJ!
    if mission == 0 then
        if extra1 == 1 then
            return analiza
        elseif extra1 == 2 then
            if analiza then        -- Jezeli misje zaczynaja sie od analiz
                return info[1]['poziom_misji']
            else
                return info[7]['poziom_misji']
            end
        elseif extra1 == 3 then
            return drop
        elseif extra1 == 4 then
            return drop2
        elseif extra1 == 5 then
            return reward_in_btn
        elseif extra1 == 6 then
            return beakgo_reward
        end
    elseif mission >= 1 and mission <= 14 then
        if extra1 == 1 then
            return info[mission]['poziom_misji']
        elseif extra1 == 2 then
            return info[mission]['id1']
        elseif extra1 == 3 then
            return info[mission]['cid1']
        elseif extra1 == 4 then
            return info[mission]['id2']
        elseif extra1 == 5 then
            return info[mission]['luck']
        elseif extra1 == 6 then
            return info[mission]['wait_time']
        elseif extra1 == 7 then
            return info[mission]['mob_id1']
        elseif extra1 == 8 then
            return info[mission]['mob_id2']
        elseif extra1 == 9 then
            return info[mission]['nagroda_yang']
        elseif extra1 == 10 then
            return info[mission]['nagroda_exp']
        elseif extra1 == 11 then
            return info[mission]['nagroda_itemy']
        elseif extra1 == 12 then
            if mission < 7 then return 0 end
            return info[mission]['nagroda_tekst']
        elseif extra1 == 13 then
            if mission < 7 then return 0 end
            return info[mission]['nagroda_bonus_id']
        elseif extra1 == 14 then
            if mission < 7 then return 0 end
            return info[mission]['nagroda_bonus_wartosc']
        elseif extra1 == 15 then
            if mission < 7 then return 1000 end
            return info[mission]['chance_id1']
        elseif extra1 == 16 then
            if mission < 7 then return 1000 end
            return info[mission]['chance_id2']
        end
    end
end

function SET_ACTUAL_BIOLOG_MISSION(misja)
    pc.setqf("misja_biolog", misja)
end

function GET_ACTUAL_BIOLOG_MISSION()
    return pc.getqf("misja_biolog")
end

function give_biolog_item(mission, opcja)
    -- 1 -> Oddawanie normalne, klikniecie na biologa            ANALIZA
    -- 2 -> Oddawanie poprzez button                            ANALIZA
    -- 3 -> Oddanie poprzez klikniecie na biologa                BADANIA
    -- 4 -> Oddanie poprzez button                                BADANIA
    -- 5 -> Oddanie kamienia, poprzez klikniecie na biologa        BADANIA
    -- 6 -> Oddanie kamienia, poprzez button                    BADANIA
    if opcja == 1 then
        say_title(mob_name(npc.get_race())..":[ENTER]")
        if pc.getqf("oddane") >= get_biolog_extra_info(mission, 3) then
            say_green("Gerekli sayýda ürünü zaten aldýnýz.")
            say()
            say_title("Ödülün:")
            biolog_nagroda(mission, false)
            cmdchat("bstatus 0")
            pc.setqf("oddane", 0)
            pc.setqf("czas_ponownie", 0)
            return 1
        end
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            say("Kazandýðýný görüyorum "..item_name(get_biolog_extra_info(mission, 2)).."!")
            say("Bir bakmama izin ver...")
            say()
            wait()
            say_title(mob_name(npc.get_race())..":[ENTER]")
            --say("[DELAY value;300]. . .[/DELAY]")
            if number(1, 100) > get_biolog_extra_info(mission, 5) then
                say_red("Özür dilerim!")
                say("Bu ürün benim araþtýrmam")
                say("için uygun deðil.")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            say("Tebrikler.")
            say("Baþarýyla teslim edildi.")
            pc.remove_item(get_biolog_extra_info(mission, 2), 1)
            say()
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                say_title("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                say("Gerekli sayýda nesneyi zaten aldýnýz.")
                say_title("Ödülün:")
                biolog_nagroda(mission, false)
                cmdchat("bstatus 0")
                pc.setqf("oddane", 0)
                pc.setqf("czas_ponownie", 0)
                return 1
            end
            say()
        else
            say("Bunu topladýðýn zaman bana dön")
            say(item_name(get_biolog_extra_info(mission, 2))..".")
            say_item(item_name(get_biolog_extra_info(mission, 2)), get_biolog_extra_info(mission, 2), item_name(get_biolog_extra_info(mission, 2)))
            say("Bu nesneyi aþaðýdaki canavarlardan toplayabilirsin.")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
            say()
        end
    elseif opcja == 2 then
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            if pc.getqf("oddane") >= get_biolog_extra_info(mission, 3) and get_biolog_extra_info(0, 5) == false then
                return chat("Zaten tüm öðeleri verdiniz, ödülü almak için Biyolog'a gidin.")
            end
            if number(1, 100) > get_biolog_extra_info(mission, 5) and pc.getqf("oddane") < get_biolog_extra_info(mission, 3) then
                chat("Bu amaç biyolog araþtýrmasý için uygun deðildir.")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                chat("Bu nesne çok iyi kalitedeydi!!")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                chat("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") >= get_biolog_extra_info(mission, 3) then
                if pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                    chat("Bu nesne çok iyi kalitedeydi!!")
                    pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                end
                chat("Gerekli sayýda nesneyi zaten aldýnýz.")
                if get_biolog_extra_info(0, 5) then
                    --chat("Ödülün:")
                    set_biolog_info_gui(mission, 0, 0, 0)
                    biolog_nagroda(mission, true)
                    cmdchat("bstatus 0")
                    pc.setqf("oddane", 0)
                    pc.setqf("czas_ponownie", 0)
                    return 1
                else
                    set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
                    chat("Ödülü toplamak için biyologa gidin!")
                    return 0
                end
            end
        else
            chat("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 2)))
            chat("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    chat("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
        end
    elseif opcja == 3 then
        say_title(mob_name(npc.get_race())..":[ENTER]")
        if pc.getqf("czas_ponownie")-get_time() > 0 and not pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            say("Öðeyi henüz veremezsiniz.")
            say("Dolmasý gereken süre: "..minuty.." dakika "..sekundy.." saniye")
            return
        elseif pc.getqf("czas_ponownie")-get_time() > 0 and pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            say("Öðeyi verebilirsin, çünkü sen GM'sin! ")
            say("Normalde beklemek zorunda kalacaksýn:: "..minuty.."m. "..sekundy.."s.")
        end
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            say("Kazandýðýný görüyorum "..item_name(get_biolog_extra_info(mission, 2)).."!")
            say("Bir bakmama izin ver...")
            say()
            wait()
            say_title(mob_name(npc.get_race())..":[ENTER]")
            --say("[DELAY value;300]. . .[/DELAY]")
            if number(1, 100) > get_biolog_extra_info(mission, 5) then
                say_red("Özür dilerim!")
                say("Bu ürün benim araþtýrmam")
                say("için uygun deðil.")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            say_green("Tebrikler.")
            say("Baþarýyla teslim edildi.")
            pc.remove_item(get_biolog_extra_info(mission, 2), 1)
            say()
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                say_title("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                pc.setqf("czas_ponownie", get_time()+get_biolog_extra_info(mission, 6))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                wait()
                say_title(mob_name(npc.get_race())..":[ENTER]")
                say_size(300, 400)
                say_green("Gerekli miktarý zaten kazandýnýz.")
                say()
                say("Araþtýrmamý bitirmek için")
                say("bir daha öðeye ihtiyacý var ...")
                say_item(item_name(get_biolog_extra_info(mission, 4)), get_biolog_extra_info(mission, 4), item_name(get_biolog_extra_info(mission, 4)))
                say("Bunu elde etmek için savaþacaðýn canavarlar:")
                for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                    if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                        say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                        break
                    end
                    if i == table.getn(get_biolog_extra_info(mission, 8)) then
                        say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                    else
                        say_reward("- "..mob_name(get_mob_id(mission, i, 1))..",")
                    end
                end
                say()
                cmdchat("bstatus 1")
                pc.setqf("oddane", 0)
                pc.setqf("czas_ponownie", 0)
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 1)
                return 1
            end
            say()
        else
            say("Bunu topladýðýn zaman bana dön")
            say(item_name(get_biolog_extra_info(mission, 2))..".")
            say_item(item_name(get_biolog_extra_info(mission, 2)), get_biolog_extra_info(mission, 2), item_name(get_biolog_extra_info(mission, 2)))
            say("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    say_reward("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
            say()
        end
    elseif opcja == 4 then
        if pc.getqf("czas_ponownie")-get_time() > 0 and not pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            chat("Öðeyi henüz veremezsiniz.")
            chat("Dolmasý gereken zaman: "..minuty.." dakika "..sekundy.." saniye")
            return
        elseif pc.getqf("czas_ponownie")-get_time() > 0 and pc.is_gm() then
            local pozostaly = pc.getqf("czas_ponownie")-get_time()
            local minuty = math.floor(pozostaly/60)
            local sekundy = pozostaly-minuty*60
            chat("Öðeyi verebilirsin, çünkü sen GM'sin! ")
            chat("Normalde beklemek zorunda kalacaksýn:: "..minuty.." dakika "..sekundy.." saniye")
        end
        if pc.count_item(get_biolog_extra_info(mission, 2)) >= 1 then
            if number(1, 100) > get_biolog_extra_info(mission, 5) then
                chat("Bu ürün benim araþtýrmamdo badañ biologa!")
                pc.remove_item(get_biolog_extra_info(mission, 2), 1)
                return
            end
            chat("Baþarýyla teslim edildi.")
            pc.remove_item(get_biolog_extra_info(mission, 2), 1)
            pc.setqf("oddane", pc.getqf("oddane")+1)
            if pc.getqf("oddane") <= get_biolog_extra_info(mission, 3)-1 then
                chat("Geriye kalan nesne sayýsý: "..get_biolog_extra_info(mission, 3)-pc.getqf("oddane"))
                pc.setqf("czas_ponownie", get_time()+get_biolog_extra_info(mission, 6))
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 0)
            elseif pc.getqf("oddane") == get_biolog_extra_info(mission, 3) then
                syschat("Gerekli miktarý zaten kazandýnýz.")
                chat("Araþtýrmayý tamamlamak için biyologun ")
                chat("bir daha öðeye ihtiyacý var ...")
                chat(item_name(get_biolog_extra_info(mission, 4)))
                chat("Bunu elde etmek için savaþacaðýn canavarlar:")
                for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                    if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                        chat("- "..mob_name(get_mob_id(mission, i, 1)))
                        break
                    end
                    if i == table.getn(get_biolog_extra_info(mission, 8)) then
                        chat("- "..mob_name(get_mob_id(mission, i, 1)))
                    else
                        chat("- "..mob_name(get_mob_id(mission, i, 1))..",")
                    end
                end
                cmdchat("bstatus 1")
                pc.setqf("oddane", 0)
                pc.setqf("czas_ponownie", 0)
                set_biolog_info_gui(mission, pc.getqf("oddane"), pc.getqf("czas_ponownie"), 1)
                return 1
            end
        else
            chat("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 2))..".")
            chat("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 7)) do
                if table.getn(get_biolog_extra_info(mission, 7)) == 1 then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 7)) then
                    chat("- "..mob_name(get_mob_id(mission, i, 0)))
                else
                    chat("- "..mob_name(get_mob_id(mission, i, 0))..",")
                end
            end
        end
    elseif opcja == 5 then
        say_title(mob_name(npc.get_race())..":[ENTER]")
        if pc.count_item(get_biolog_extra_info(mission, 4)) < 1 then
            say_red("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 4))..".")
            say()
            say_item(item_name(get_biolog_extra_info(mission, 4)), get_biolog_extra_info(mission, 4), item_name(get_biolog_extra_info(mission, 4)))
            say()
            say_title("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 8)) then
                    say_reward("- "..mob_name(get_mob_id(mission, i, 1)))
                else
                    say_reward("- "..mob_name(get_mob_id(mission, i, 1))..",")
                end
            end
            say()
        else
            say_green("Harika, buldun!")
            pc.remove_item(get_biolog_extra_info(mission, 4), 1)
            say("Çok teþekkür ederim!")
            say("Sýký çalýþmanýz karþýlýðýnda")
            say("bir ödül alacaksýnýz.")
            if get_biolog_extra_info(0, 6) then
                say("Ödül için bu görevliyi bul,")
                say_zloto("Beak-Go.")
                say()
                return 1
            else
                biolog_nagroda(mission, false)
                return 2
            end
        end
    elseif opcja == 6 then
        if pc.count_item(get_biolog_extra_info(mission, 4)) < 1 then
            chat("Bu nesne envanterinde bulunamadý: "..item_name(get_biolog_extra_info(mission, 4))..".")
            chat("Bunu elde etmek için savaþacaðýn canavarlar:")
            for i = 1, table.getn(get_biolog_extra_info(mission, 8)) do
                if table.getn(get_biolog_extra_info(mission, 8)) == 1 then
                    syschat("- "..mob_name(get_mob_id(mission, i, 1)))
                    break
                end
                if i == table.getn(get_biolog_extra_info(mission, 8)) then
                    syschat("- "..mob_name(get_mob_id(mission, i, 1)))
                else
                    syschat("- "..mob_name(get_mob_id(mission, i, 1))..",")
                end
            end
        else
            pc.remove_item(get_biolog_extra_info(mission, 4), 1)
            chat("Taþ verdin..")
            if get_biolog_extra_info(0, 6) then
                chat("Ödülden sonra Beak-Go'ya gidin.")
                return 1
            else
                biolog_nagroda(mission, true)
                return 2
            end
        end
    end
    return 0
end

function biolog_nagroda(mission, is_btn)
    -- Odbior nagrody od biologa lub od Beak-Go
    -- Yang, exp, przedmioty dla danej postaci, przedmioty dla wszystkich, bonusy
    if is_btn then
        if get_biolog_extra_info(mission, 9) > 0 then
            --chat(get_biolog_extra_info(mission, 9).." Yang")
            pc.change_money(get_biolog_extra_info(mission, 9))
        end
        if get_biolog_extra_info(mission, 10) > 0 then
            chat(get_biolog_extra_info(mission, 10).." Tecrübe")
            pc.give_exp2(get_biolog_extra_info(mission, 10))
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[pc.get_job()]) do
            if get_biolog_extra_info(mission, 11)[pc.get_job()][1] == 0 then break end
            --chat("- "..item_name(get_biolog_extra_info(mission, 11)[pc.get_job()][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[pc.get_job()][i], 1)
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[4]) do
            if get_biolog_extra_info(mission, 11)[4][1] == 0 then break end
            --chat("- "..item_name(get_biolog_extra_info(mission, 11)[4][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[4][i], 1)
        end
        if type(get_biolog_extra_info(mission, 13)) == "table" then
            chat(get_biolog_extra_info(mission, 12))
            for i = 1, table.getn(get_biolog_extra_info(mission, 13)) do
                affect.add_collect(get_biolog_extra_info(mission, 13)[i], get_biolog_extra_info(mission, 14)[i], 60*60*24*365*60)
            end
        end
    else
        if get_biolog_extra_info(mission, 9) > 0 then
            say_reward(get_biolog_extra_info(mission, 9).." Yang")
            pc.change_money(get_biolog_extra_info(mission, 9))
        end
        if get_biolog_extra_info(mission, 10) > 0 then
            say_reward(get_biolog_extra_info(mission, 10).." Tecrübe")
            pc.give_exp2(get_biolog_extra_info(mission, 10))
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[pc.get_job()]) do
            if get_biolog_extra_info(mission, 11)[pc.get_job()][1] == 0 then break end
            say_reward("- "..item_name(get_biolog_extra_info(mission, 11)[pc.get_job()][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[pc.get_job()][i], 1)
        end
        for i = 1, table.getn(get_biolog_extra_info(mission, 11)[4]) do
            if get_biolog_extra_info(mission, 11)[4][1] == 0 then break end
            say_reward("- "..item_name(get_biolog_extra_info(mission, 11)[4][i]))
            pc.give_item2(get_biolog_extra_info(mission, 11)[4][i], 1)
        end
        if type(get_biolog_extra_info(mission, 13)) == "table" then
            say_reward(get_biolog_extra_info(mission, 12))
            for i = 1, table.getn(get_biolog_extra_info(mission, 13)) do
                affect.add_collect(get_biolog_extra_info(mission, 13)[i], get_biolog_extra_info(mission, 14)[i], 60*60*24*365*60)
            end
        end
    end
end

function get_mob_id(mission, ktory, submission)
    local rekord = 7
    if submission == 1 then rekord = 8 end
    if type(get_biolog_extra_info(mission, rekord)) == "table" then
        if ktory <= 0 or ktory > table.getn(get_biolog_extra_info(mission, rekord)) then ktory = 1 end
        return get_biolog_extra_info(mission, rekord)[ktory]
    else
        return get_biolog_extra_info(mission, rekord)
    end
end

function is_biolog_mission_mob(mission, vnum, submission)
    local rekord = 7
    if submission == 1 then rekord = 8 end
    if type(get_biolog_extra_info(mission, rekord)) == "table" then
        for i = 1, table.getn(get_biolog_extra_info(mission, rekord)) do
            if get_biolog_extra_info(mission, rekord)[i] == vnum then
                return true
            end
        end
    else
        if vnum == get_biolog_extra_info(mission, rekord) then
            return true
        end
    end
    return false
end

function set_biolog_info_gui(mission, ile_oddalem, ile_jeszcze_czasu, submission)
    cmdchat("bstatus 1")
    if submission == 1 then
        cmdchat("btext txt1 "..ile_oddalem.."/1")
    else
        cmdchat("btext txt1 "..ile_oddalem.."/"..get_biolog_extra_info(mission, 3))
    end
    cmdchat("btext txt2 "..get_biolog_extra_info(mission, 5).."%")
    if ile_jeszcze_czasu < 0 then ile_jeszcze_czasu = 0 end
    cmdchat("btext txt3 "..ile_jeszcze_czasu)
    if mission >= 1 and mission <= 6 then
        cmdchat("btext name Biyolog_Analizi_"..mission)
    else
        cmdchat("btext name Biyolog_Araþtýrmasý_"..mission)
    end
    local rekord = 7
    if submission == 1 then rekord = 8 end
    local opis = ""
    for i = 1, table.getn(get_biolog_extra_info(mission, rekord)) do
        if table.getn(get_biolog_extra_info(mission, rekord)) == 1 then
            opis = "Bunlarý yok et!_"..mob_name(get_mob_id(mission, i, submission))
            break
        end
        if i == 1 then
            opis = "Bunlarý yok et!_"..mob_name(get_mob_id(mission, i, submission))
        else
            opis = opis..","..mob_name(get_mob_id(mission, i, submission))
        end
    end
    opis = string.sub(string.gsub(opis.." ", " ", "_"), 0, string.len(string.gsub(opis.." ", " ", "_")))
    if submission == 1 then        -- jezeli ma przyniesc kamien
        cmdchat("bitem "..get_biolog_extra_info(mission, 4))
    else
        cmdchat("bitem "..get_biolog_extra_info(mission, 2))
    end
end

function biolog_inputek(inputeczek)
    cmdchat("getBiologinputbegin")
    local ret = input(cmdchat(inputeczek))
    cmdchat("getBiologinputend")
    return ret
end

function get_today_count(questname, flag_name)
    local today = math.floor(get_global_time() / 86400)
    local today_flag = flag_name.."_today"
    local today_count_flag = flag_name.."_today_count"
    local last_day = pc.getf(questname, today_flag)
    if last_day == today then
        return pc.getf(questname, today_count_flag)
    else
        return 0
    end
end
-- "$flag_name"_today unix_timestamp % 86400
-- "$flag_name"_count count
function inc_today_count(questname, flag_name, count)
    local today = math.floor(get_global_time() / 86400)
    local today_flag = flag_name.."_today"
    local today_count_flag = flag_name.."_today_count"
    local last_day = pc.getqf(questname, today_flag)
    if last_day == today then
        pc.setf(questname, today_count_flag, pc.getf(questname, today_count_flag) + 1)
    else
        pc.setf(questname, today_flag, today)
        pc.setf(questname, today_count_flag, 1)
    end
end

-- This function will return true always in window os,
--  but not in freebsd.
-- (In window os, RAND_MAX = 0x7FFF = 32767.)
function drop_gamble_with_flag(drop_flag)
        local dp, range = pc.get_killee_drop_pct()
        dp = 40000 * dp / game.get_event_flag(drop_flag)
        if dp < 0 or range < 0 then
            return false
        end
        return dp >= number(1, range)
end

function split(str, delim, maxNb)
    if str == nil then return str end
    if string.find(str, delim) == nil then return { str } end
    if maxNb == nil or maxNb < 1 then maxNb = 0 end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end
    return result
end

mysql_query = function(query)
    local version = 55
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    if version == 51 then
        os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi)
    elseif version == 55 then
        os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi)
    else
        return 0
    end
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber(b) or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber(b) or b or 'NULL'
    end) end
    out.__lines = t[1]
    return out
end

function item3.get_attr(var)
return item.get_attr_type(var),item.get_attr_value(var)
end

guildstorage_path = "locale/turkey/quest/sancak/sistemler/"

function getinput(par)
    cmdchat("getinputbegin")
    local ret = input(cmdchat(par))
    cmdchat("getinputend")
    return ret
end

--quest.create = function(f) return coroutine.create(f) end
--quest.process = function(co,args) return coroutine.resume(co, args) end
setstate = q.setstate
newstate = q.setstate

q.set_clock = function(name, value) q.set_clock_name(name) q.set_clock_value(value) end
q.set_counter = function(name, value) q.set_counter_name(name) q.set_counter_value(value) end
c_item_name = function(vnum) return ("[ITEM value;"..vnum.."]") end
c_mob_name = function(vnum) return ("[MOB value;"..vnum.."]") end

-- d.set_folder = function (path) raw_script("[SET_PATH path;"..path.."]") end
-- d.set_folder = function (path) path.show_cinematic("[SET_PATH path;"..path.."]") end
-- party.run_cinematic = function (path) party.show_cinematic("[RUN_CINEMATIC value;"..path.."]") end

newline = "[ENTER]"
function color256(r, g, b) return "[COLOR r;"..(r/255.0).."|g;"..(g/255.0).."|b;"..(b/255.0).."]" end
function color(r,g,b) return "[COLOR r;"..r.."|g;"..g.."|b;"..b.."]" end
function delay(v) return "[DELAY value;"..v.."]" end
function setcolor(r,g,b) raw_script(color(r,g,b)) end
function setdelay(v) raw_script(delay(v)) end
function resetcolor(r,g,b) raw_script("[/COLOR]") end
function resetdelay(v) raw_script("[/DELAY]") end
function say_blue(name) say(color256(0, 0, 255)..name..color256(0, 0, 255)) end
function say_red(name) say(color256(255, 0, 0)..name..color256(255, 0, 0)) end
function say_green(name) say(color256(0, 238, 0)..name..color256(0, 238, 0)) end
function say_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end
function say_black(name) say(color256(0, 0, 0)..name..color256(0, 0, 0)) end
function say_white(name) say(color256(255, 255, 255)..name..color256(255, 255, 255)) end
function say_yellow(name) say(color256(255, 255, 0)..name..color256(255, 255, 0)) end
function say_blue2(name) say(color256(0, 206, 209)..name..color256(0, 206, 209)) end
function chat_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end

function say_light_yellow(name) say(color256(255,255,128)..name..color256(196, 196, 196)) end
function say_orange(name) say(color256(255,191,24)..name..color256(196, 196, 196)) end
function say_light_blue(name) say(color256(130, 192, 255)..name..color256(196, 196, 196)) end

-- minimap? ???? ??
function addmapsignal(x,y) raw_script("[ADDMAPSIGNAL x;"..x.."|y;"..y.."]") end

-- minimap ????? ?? ???
function clearmapsignal() raw_script("[CLEARMAPSIGNAL]") end

-- ??????? ??? ??? ?? ??? ???.
function setbgimage(src) raw_script("[BGIMAGE src;") raw_script(src) raw_script("]") end

-- ???? ???? ????.
function addimage(x,y,src) raw_script("[IMAGE x;"..x.."|y;"..y) raw_script("|src;") raw_script(src) raw_script("]") end

function makequestbutton(name)
    raw_script("[QUESTBUTTON idx;")
    raw_script(""..q.getcurrentquestindex())
    raw_script("|name;")
    raw_script(name) raw_script("]")
end

function make_quest_button_ex(name, icon_type, icon_name)
    test_chat(icon_type)
    test_chat(icon_name)
    raw_script("[QUESTBUTTON idx;")
    raw_script(""..q.getcurrentquestindex())
    raw_script("|name;")
    raw_script(name)
    raw_script("|icon_type;")
    raw_script(icon_type)
    raw_script("|icon_name;")
    raw_script(icon_name)
    raw_script("]")
end

function make_quest_button(name) makequestbutton(name) end

function send_letter_ex(name, icon_type, icon_name) make_quest_button_ex(name, icon_type, icon_name) set_skin(NOWINDOW) q.set_title(name) q.start() end

function send_letter(name) makequestbutton(name) set_skin(NOWINDOW) q.set_title(name) q.start() end
function clear_letter() q.done() end
function say_title(name) say(color256(255, 230, 186)..name..color256(196, 196, 196)) end
function say_reward(name) say(color256(255, 200, 200)..name..color256(196, 196, 196)) end
function say_blue(name) say(color256(0, 0, 255)..name..color256(0, 0, 255)) end
function say_red(name) say(color256(255, 0, 0)..name..color256(255, 0, 0)) end
function say_green(name) say(color256(0, 238, 0)..name..color256(0, 238, 0)) end
function say_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end
function say_black(name) say(color256(0, 0, 0)..name..color256(0, 0, 0)) end
function say_white(name) say(color256(255, 255, 255)..name..color256(255, 255, 255)) end
function say_yellow(name) say(color256(255, 255, 0)..name..color256(255, 255, 0)) end
function say_blue2(name) say(color256(0, 206, 209)..name..color256(0, 206, 209)) end
function chat_gold(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end

function say_light_yellow(name) say(color256(255,255,128)..name..color256(196, 196, 196)) end
function say_yellow(name) say(color256(255,255,53)..name..color256(196, 196, 196)) end
function say_orange(name) say(color256(255,191,24)..name..color256(196, 196, 196)) end
function say_light_blue(name) say(color256(130, 192, 255)..name..color256(196, 196, 196)) end
function say_red(name) say(color256(139, 35, 35)..name..color256(196, 196, 196)) end

function say_kingdom_red(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end
function say_kingdom_yellow(name) say(color256(255, 215, 0)..name..color256(196, 196, 196)) end
function say_kingdom_blue(name) say(color256(16, 78, 139)..name..color256(196, 196, 196)) end

function say_alert(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end

function say_gm(name) say(color256(238, 201, 0)..name..color256(196, 196, 196)) end
function say_gm_title(name) say(color256(238, 118, 0)..name..color256(196, 196, 196)) end

function say_help_title(name) say(color256(238, 118, 0)..name..color256(196, 196, 196)) end
function say_help(name) say(color256(139, 35, 35)..name..color256(196, 196, 196)) end
function say_help_red(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end

function say_event_title(name) say(color256(238, 118, 0)..name..color256(196, 196, 196)) end
function say_event(name) say(color256(139, 35, 35)..name..color256(196, 196, 196)) end
function say_event_red(name) say(color256(205, 0, 0)..name..color256(196, 196, 196)) end
function say_pc_name() say(pc.get_name()..":") end
function say_size(width, height) say("[WINDOW_SIZE width;"..width.."|height;"..height.."]") end
function setmapcenterposition(x,y)
    raw_script("[SETCMAPPOS x;")
    raw_script(x.."|y;")
    raw_script(y.."]")
end
function say_item(name, vnum, desc)
    say("[INSERT_IMAGE image_type;item|idx;"..vnum.."|title;"..name.."|desc;"..desc.."|index;".. 0 .."|total;".. 1 .."]")
end
function say_item_vnum(vnum)
    say_item(item_name(vnum), vnum, "")
end

function pc_is_novice()
    if pc.get_skill_group()==0 then
        return true
    else
        return false
    end
end
function pc_get_exp_bonus(exp, text)
    say_reward(text)
    pc.give_exp2(exp)
    set_quest_state("levelup", "run")
end
function pc_get_village_map_index(index)
    return village_map[pc.get_empire()][index]
end

village_map = {
    {1, 3},
    {21, 23},
    {41, 43},
}

function npc_is_same_empire()
    if pc.get_empire()==npc.empire then
        return true
    else
        return false
    end
end

function npc_get_skill_teacher_race(pc_empire, pc_job, sub_job)
    if 1==sub_job then
        if 0==pc_job then
            return WARRIOR1_NPC_LIST[pc_empire]
        elseif 1==pc_job then
            return ASSASSIN1_NPC_LIST[pc_empire]
        elseif 2==pc_job then
            return SURA1_NPC_LIST[pc_empire]
        elseif 3==pc_job then
            return SHAMAN1_NPC_LIST[pc_empire]
        end  
    elseif 2==sub_job then
        if 0==pc_job then
            return WARRIOR2_NPC_LIST[pc_empire]
        elseif 1==pc_job then
            return ASSASSIN2_NPC_LIST[pc_empire]
        elseif 2==pc_job then
            return SURA2_NPC_LIST[pc_empire]
        elseif 3==pc_job then
            return SHAMAN2_NPC_LIST[pc_empire]
        end  
    end

    return 0
end


function pc_find_square_guard_vid()
    if pc.get_empire()==1 then
        return find_npc_by_vnum(11000)
    elseif pc.get_empire()==2 then
        return find_npc_by_vnum(11002)
    elseif pc.get_empire()==3 then
        return find_npc_by_vnum(11004)
    end
    return 0
end

function pc_find_skill_teacher_vid(sub_job)
    local vnum=npc_get_skill_teacher_race(pc.get_empire(), pc.get_job(), sub_job)
    return find_npc_by_vnum(vnum)
end

function pc_find_square_guard_vid()
    local pc_empire=pc.get_empire()
    if pc_empire==1 then
        return find_npc_by_vnum(11000)
    elseif pc_empire==2 then
        return find_npc_by_vnum(11002)
    elseif pc_empire==3 then
        return find_npc_by_vnum(11004)
    end
end

function npc_is_same_job()
    local pc_job=pc.get_job()
    local npc_vnum=npc.get_race()

    -- test_chat("pc.job:"..pc.get_job())
    -- test_chat("npc_race:"..npc.get_race())
    -- test_chat("pc.skill_group:"..pc.get_skill_group())
    if pc_job==0 then
        if table_is_in(WARRIOR1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(WARRIOR2_NPC_LIST, npc_vnum) then return true end
    elseif pc_job==1 then
        if table_is_in(ASSASSIN1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(ASSASSIN2_NPC_LIST, npc_vnum) then return true end
    elseif pc_job==2 then
        if table_is_in(SURA1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(SURA2_NPC_LIST, npc_vnum) then return true end
    elseif pc_job==3 then
        if table_is_in(SHAMAN1_NPC_LIST, npc_vnum) then return true end
        if table_is_in(SHAMAN2_NPC_LIST, npc_vnum) then return true end
    end

    return false
end

function npc_get_job()
    local npc_vnum=npc.get_race()

    if table_is_in(WARRIOR1_NPC_LIST, npc_vnum) then return COND_WARRIOR_1 end
    if table_is_in(WARRIOR2_NPC_LIST, npc_vnum) then return COND_WARRIOR_2 end
    if table_is_in(ASSASSIN1_NPC_LIST, npc_vnum) then return COND_ASSASSIN_1 end
    if table_is_in(ASSASSIN2_NPC_LIST, npc_vnum) then return COND_ASSASSIN_2 end
    if table_is_in(SURA1_NPC_LIST, npc_vnum) then return COND_SURA_1 end
    if table_is_in(SURA2_NPC_LIST, npc_vnum) then return COND_SURA_2 end
    if table_is_in(SHAMAN1_NPC_LIST, npc_vnum) then return COND_SHAMAN_1 end
    if table_is_in(SHAMAN2_NPC_LIST, npc_vnum) then return COND_SHAMAN_2 end
    return 0

end

function time_min_to_sec(value)
    return 60*value
end

function time_hour_to_sec(value)
    return 3600*value
end

function next_time_set(value, test_value)
    local nextTime=get_time()+value
    if is_test_server() then
        nextTime=get_time()+test_value
    end
    pc.setqf("__NEXT_TIME__", nextTime)
end

function next_time_is_now(value)
    if get_time()>=pc.getqf("__NEXT_TIME__") then
        return true
    else
        return false
    end
end

function table_get_random_item(self)
    return self[number(1, table.getn(self))]
end

function table_is_in(self, test)
    for i = 1, table.getn(self) do
        if self[i]==test then
            return true
        end
    end
    return false
end


function giveup_quest_menu(title)
    local s=select("????", "????")
    if 2==s then
    say(title.." ???? ???")
    say("?????????")
    local s=select("?, ?????", "????")
    if 1==s then
        say(title.."???? ??????")
        restart_quest()
    end
    end
end

function restart_quest()
    set_state("start")
    q.done()
end

function complete_quest()
    set_state("__COMPLETE__")
    q.done()
end

function giveup_quest()
    set_state("__GIVEUP__")
    q.done()
end

function complete_quest_state(state_name)
    set_state(state_name)
    q.done()
end

function test_chat(log)
    if is_test_server() then
        chat(log)
    end
end

function bool_to_str(is)
    if is then
        return "true"
    else
        return "false"
    end
end

WARRIOR1_NPC_LIST     = {20300, 20320, 20340, }
WARRIOR2_NPC_LIST     = {20301, 20321, 20341, }
ASSASSIN1_NPC_LIST     = {20302, 20322, 20342, }
ASSASSIN2_NPC_LIST     = {20303, 20323, 20343, }
SURA1_NPC_LIST         = {20304, 20324, 20344, }
SURA2_NPC_LIST         = {20305, 20325, 20345, }
SHAMAN1_NPC_LIST     = {20306, 20326, 20346, }
SHAMAN2_NPC_LIST     = {20307, 20327, 20347, }

function skill_group_dialog(e, j, g) -- e = ??, j = ??, g = ??
    e = 1 -- XXX ???? ???? ??? ??? ?????
   

    -- ?? ????? ?? ??? ??
    if pc.job != j then
        say(locale.skill_group.dialog[e][pc.job][3])
    elseif pc.get_skill_group() == 0 then
        if pc.level < 5 then
            say(locale.skill_group.dialog[e][j][g][1])
            return
        end
        say(locale.skill_group.dialog[e][j][g][2])
        local answer = select(locale.yes, locale.no)

        if answer == 1 then
            --say(locale.skill_group.dialog[e][j][g][2])
            pc.set_skill_group(g)
        else
            --say(locale.skill_group.dialog[e][j][g][3])
        end
    --elseif pc.get_skill_group() == g then
        --say(locale.skill_group.dialog[e][j][g][4])
    --else
        --say(locale.skill_group.dialog[e][j][g][5])
    end
end

function show_horse_menu()
    if horse.is_mine() then          
        say(locale.horse_menu.menu)

        local s = 0
        if horse.is_dead() then
            s = select(locale.horse_menu.revive, locale.horse_menu.ride, locale.horse_menu.unsummon, locale.horse_menu.show_state ,locale.horse_menu.close)
        else
            s = select(locale.horse_menu.feed, locale.horse_menu.ride, locale.horse_menu.unsummon,  locale.horse_menu.show_state ,locale.horse_menu.close)
        end

        if s==1 then
            if horse.is_dead() then
                horse.revive()
            else
                local food = horse.get_grade() + 50054 - 1
                if pc.countitem(food) > 0 then
                pc.removeitem(food, 1)
                horse.feed()
                else
                say(locale.need_item_prefix..item_name(food)..locale.need_item_postfix);
                end
            end
        elseif s==2 then
            horse.ride()
        elseif s==3 then
            horse.unsummon()
        elseif s==4 then
            say("?? ????: "..horse.get_health_pct().."%")
            say("?? ???@?: "..horse.get_stamina_pct().."%")
            say("")
        elseif s==5 then                                                    
            -- do nothing
        end
    end
end

npc_index_table = {
    ['race'] = npc.getrace,
    ['empire'] = npc.get_empire,
}

pc_index_table = {
    ['weapon']        = pc.getweapon,
    ['level']        = pc.get_level,
    ['hp']        = pc.gethp,
    ['maxhp']        = pc.getmaxhp,
    ['sp']        = pc.getsp,
    ['maxsp']        = pc.getmaxsp,
    ['exp']        = pc.get_exp,
    ['nextexp']        = pc.get_next_exp,
    ['job']        = pc.get_job,
    ['money']        = pc.getmoney,
    ['gold']         = pc.getmoney,
    ['name']         = pc.getname,
    ['playtime']     = pc.getplaytime,
    ['leadership']     = pc.getleadership,
    ['empire']         = pc.getempire,
    ['skillgroup']     = pc.get_skill_group,
    ['x']         = pc.getx,
    ['y']         = pc.gety,
    ['local_x']     = pc.get_local_x,
    ['local_y']     = pc.get_local_y,
}

item_index_table = {
    ['vnum']        = item.get_vnum,
    ['name']        = item.get_name,
    ['size']        = item.get_size,
    ['count']        = item.get_count,
    ['type']        = item.get_type,
    ['sub_type']    = item.get_sub_type,
    ['refine_vnum']    = item.get_refine_vnum,
    ['level']        = item.get_level,
}

guild_war_bet_price_table =
{
    10000,
    30000,
    50000,
    100000
}

function npc_index(t,i)
    local npit = npc_index_table
    if npit[i] then
    return npit[i]()
    else
    return rawget(t,i)
    end
end

function pc_index(t,i)
    local pit = pc_index_table
    if pit[i] then
    return pit[i]()
    else
    return rawget(t,i)
    end
end

function item_index(t, i)
    local iit = item_index_table
    if iit[i] then
    return iit[i]()
    else
    return rawget(t, i)
    end
end

setmetatable(pc,{__index=pc_index})
setmetatable(npc,{__index=npc_index})
setmetatable(item,{__index=item_index})

--coroutine? ??? ??? ??
function select(...)
    return q.yield('select', arg)
end

function select_table(table)
    return q.yield('select', table)
end

-- coroutine? ??? ?? ?? ????
function wait()
    q.yield('wait')
end

function input()
    return q.yield('input')
end

function confirm(vid, msg, timeout)
    return q.yield('confirm', vid, msg, timeout)
end

function select_item()
    setskin(NOWINDOW)
    return q.yield('select_item')
end

--?? ?? ??? ??? ??
NOWINDOW = 0
NORMAL = 1
CINEMATIC = 2
SCROLL = 3

WARRIOR = 0
ASSASSIN = 1
SURA = 2
SHAMAN = 3

COND_WARRIOR_0 = 8
COND_WARRIOR_1 = 16
COND_WARRIOR_2 = 32
COND_WARRIOR = 56

COND_ASSASSIN_0 = 64
COND_ASSASSIN_1 = 128
COND_ASSASSIN_2 = 256
COND_ASSASSIN = 448

COND_SURA_0 = 512
COND_SURA_1 = 1024
COND_SURA_2 = 2048
COND_SURA = 3584

COND_SHAMAN_0 = 4096
COND_SHAMAN_1 = 8192
COND_SHAMAN_2 = 16384
COND_SHAMAN = 28672

PART_MAIN = 0
PART_HAIR = 3

GUILD_CREATE_ITEM_VNUM = 70101

QUEST_SCROLL_TYPE_KILL_MOB = 1
QUEST_SCROLL_TYPE_KILL_ANOTHER_EMPIRE = 2

apply = {
    ["MAX_HP"]        = 1,
    ["MAX_SP"]        = 2,
    ["CON"]            = 3,
    ["INT"]            = 4,
    ["STR"]            = 5,
    ["DEX"]            = 6,
    ["ATT_SPEED"]        = 7,
    ["MOV_SPEED"]        = 8,
    ["CAST_SPEED"]        = 9,
    ["HP_REGEN"]        = 10,
    ["SP_REGEN"]        = 11,
    ["POISON_PCT"]        = 12,
    ["STUN_PCT"]        = 13,
    ["SLOW_PCT"]        = 14,
    ["CRITICAL_PCT"]    = 15,
    ["PENETRATE_PCT"]    = 16,
    ["ATTBONUS_HUMAN"]    = 17,
    ["ATTBONUS_ANIMAL"]    = 18,
    ["ATTBONUS_ORC"]    = 19,
    ["ATTBONUS_MILGYO"]    = 20,
    ["ATTBONUS_UNDEAD"]    = 21,
    ["ATTBONUS_DEVIL"]    = 22,
    ["STEAL_HP"]        = 23,
    ["STEAL_SP"]        = 24,
    ["MANA_BURN_PCT"]    = 25,
    ["DAMAGE_SP_RECOVER"]    = 26,
    ["BLOCK"]        = 27,
    ["DODGE"]        = 28,
    ["RESIST_SWORD"]    = 29,
    ["RESIST_TWOHAND"]    = 30,
    ["RESIST_DAGGER"]    = 31,
    ["RESIST_BELL"]        = 32,
    ["RESIST_FAN"]        = 33,
    ["RESIST_BOW"]        = 34,
    ["RESIST_FIRE"]        = 35,
    ["RESIST_ELEC"]        = 36,
    ["RESIST_MAGIC"]    = 37,
    ["RESIST_WIND"]        = 38,
    ["REFLECT_MELEE"]    = 39,
    ["REFLECT_CURSE"]    = 40,
    ["POISON_REDUCE"]    = 41,
    ["KILL_SP_RECOVER"]    = 42,
    ["EXP_DOUBLE_BONUS"]    = 43,
    ["GOLD_DOUBLE_BONUS"]    = 44,
    ["ITEM_DROP_BONUS"]    = 45,
    ["POTION_BONUS"]    = 46,
    ["KILL_HP_RECOVER"]    = 47,
    ["IMMUNE_STUN"]        = 48,
    ["IMMUNE_SLOW"]        = 49,
    ["IMMUNE_FALL"]        = 50,
    ["SKILL"]        = 51,
    ["BOW_DISTANCE"]    = 52,
    ["ATT_GRADE_BONUS"]    = 53,
    ["DEF_GRADE_BONUS"]    = 54,
    ["MAGIC_ATT_GRADE"]    = 55,
    ["MAGIC_DEF_GRADE"]    = 56,
    ["CURSE_PCT"]        = 57,
    ["MAX_STAMINA"]        = 58,
    ["ATTBONUS_WARRIOR"]    = 59,
    ["ATTBONUS_ASSASSIN"]    = 60,
    ["ATTBONUS_SURA"]    = 61,
    ["ATTBONUS_SHAMAN"]    = 62,
    ["ATTBONUS_MONSTER"]    = 63,
}

-- ??? ??? -_-
special = {}

special.fortune_telling =
{
--  { prob    ??    item    money    remove money
    { 1,    0,    20,    20,    0    }, -- 10
    { 499,    0,    10,    10,    0    }, -- 5
    { 2500,    0,    5,    5,    0    }, -- 1
    { 5000,    0,    0,    0,    0    },
    { 1500,    0,    -5,    -5,    20000    },
    { 499,    0,    -10,    -10,    20000    },
    { 1,    0,    -20,    -20,    20000    },
}

special.questscroll_reward =
{
    {1,    1500,    3000,    30027,    0,    0    },
    {2,    1500,    3000,    30028,    0,    0    },
    {3,    1000,    2000,    30034,    30018,    0    },
    {4,    1000,    2000,    30034,    30011,    0    },
    {5,    1000,    2000,    30011,    30034,    0    },
    {6,    1000,    2000,    27400,    0,    0    },
    {7,    2000,    4000,    30023,    30003,    0    },
    {8,    2000,    4000,    30005,    30033,    0    },
    {9,    2000,    8000,    30033,    30005,    0    },
    {10,    4000,    8000,    30021,    30033,    30045},
    {11,    4000,    8000,    30045,    30022,    30046},
    {12,    5000,    12000,    30047,    30045,    30055},
    {13,    5000,    12000,    30051,    30017,    30058},
    {14,    5000,    12000,    30051,    30007,    30041},
    {15,    5000,    15000,    30091,    30017,    30018},
    {16,    3500,    6500,    30021,    30033,    0    },
    {17,    4000,    9000,    30051,    30033,    0    },
    {18,    4500,    10000,    30056,    30057,    30058},
    {19,    4500,    10000,    30059,    30058,    30041},
    {20,    5000,    15000,    0,    0,    0    },
}

special.active_skill_list = {
    {
        { 1, 2, 3, 4, 5, 6},
        { 16, 17, 18, 19, 20, 21},
    },
    {
        {31, 32, 33, 34, 35, 36},
        {46, 47, 48, 49, 50, 51},
    },
    {
        {61, 62, 63, 64, 65, 66},
        {76, 77, 78, 79, 80, 81},
    },
    {
        {91, 92, 93, 94, 95, 96},
        {106, 107, 108, 109, 110, 111},
    },
}

special.skill_reset_cost = {
    2000,
    2000,
    2000,
    2000,
    2000,
    2000,
    4000,
    6000,
    8000,
    10000,
    14000,
    18000,
    22000,
    28000,
    34000,
    41000,
    50000,
    59000,
    70000,
    90000,
    101000,
    109000,
    114000,
    120000,
    131000,
    141000,
    157000,
    176000,
    188000,
    200000,
    225000,
    270000,
    314000,
    348000,
    393000,
    427000,
    470000,
    504000,
    554000,
    600000,
    758000,
    936000,
    1103000,
    1276000,
    1407000,
    1568000,
    1704000,
    1860000,
    2080000,
    2300000,
    2700000,
    3100000,
    3500000,
    3900000,
    4300000,
    4800000,
    5300000,
    5800000,
    6400000,
    7000000,
    8000000,
    9000000,
    10000000,
    11000000,
    12000000,
    13000000,
    14000000,
    15000000,
    16000000,
    17000000,
}

special.levelup_img =
{
    [101] = "dog.tga",
    [102] = "wolf.tga",
    [103] = "wolf.tga",
    [104] = "wolf.tga",
    [105] = "wolf.tga",
    [105] = "wolf.tga",
    [106] = "wolf.tga",
    [107] = "wolf.tga",
    [108] = "wild_boar.tga",
    [109] = "wild_boar.tga",
    [110] = "bear.tga",
    [111] = "bear.tga",
    [112] = "bear.tga",
    [113] = "bear.tga",
    [114] = "tiger.tga",
    [115] = "tiger.tga",

    [301] = "bak_inf.tga",
    [302] = "bak_gung.tga",
    [303] = "bak_gen1.tga",
    [304] = "bak_gen2.tga",

    [401] = "huk_inf.tga",
    [402] = "huk_dol.tga",
    [403] = "huk_gen1.tga",
    [404] = "huk_gen2.tga",

    [501] = "o_inf.tga",
    [502] = "o_jol.tga",
    [503] = "o_gung.tga",
    [504] = "o_jang.tga",

    [601] = "ung_inf.tga",
    [602] = "ung_chuk.tga",
    [603] = "ung_tu.tga",
}

special.levelup_quest = {
    -- monster kill  monster   kill
    --    vnum        qty.         vnum        qty.     exp percent
{    0    ,    0    ,    0    ,    0    ,    0    }    ,    --    lev    1
{    101    ,    10    ,    102    ,    5    ,    10    }    ,    --    lev    2
{    101    ,    20    ,    102    ,    10    ,    10    }    ,    --    lev    3
{    102    ,    15    ,    103    ,    5    ,    10    }    ,    --    lev    4
{    103    ,    10    ,    104    ,    10    ,    10    }    ,    --    lev    5
{    104    ,    20    ,    108    ,    10    ,    10    }    ,    --    lev    6
{    108    ,    10    ,    105    ,    5    ,    10    }    ,    --    lev    7
{    108    ,    20    ,    105    ,    10    ,    10    }    ,    --    lev    8
{    105    ,    15    ,    109    ,    5    ,    10    }    ,    --    lev    9
{    105    ,    20    ,    109    ,    10    ,    10    }    ,    --    lev    10
{    109    ,    10    ,    110    ,    5    ,    10    }    ,    --    lev    11
{    110    ,    15    ,    106    ,    10    ,    10    }    ,    --    lev    12
{    106    ,    20    ,    111    ,    5    ,    10    }    ,    --    lev    13
{    111    ,    15    ,    107    ,    5    ,    10    }    ,    --    lev    14
{    111    ,    20    ,    107    ,    10    ,    10    }    ,    --    lev    15
{    107    ,    15    ,    114    ,    5    ,    10    }    ,    --    lev    16
{    107    ,    20    ,    114    ,    10    ,    10    }    ,    --    lev    17
{    114    ,    10    ,    112    ,    10    ,    10    }    ,    --    lev    18
{    112    ,    20    ,    113    ,    10    ,    10    }    ,    --    lev    19
{    113    ,    20    ,    302    ,    15    ,    10    }    ,    --    lev    20
{    302    ,    20    ,    115    ,    10    ,    "2-10"    }    ,    --    lev    21
{    115    ,    25    ,    304    ,    10    ,    "2-10"    }    ,    --    lev    22
{    304    ,    20    ,    401    ,    40    ,    "2-10"    }    ,    --    lev    23
{    401    ,    60    ,    402    ,    80    ,    "2-10"    }    ,    --    lev    24
{    501    ,    80    ,    404    ,    20    ,    "2-10"    }    ,    --    lev    25
{    502    ,    80    ,    406    ,    20    ,    "2-10"    }    ,    --    lev    26
{    406    ,    30    ,    504    ,    20    ,    "2-10"    }    ,    --    lev    27
{    631    ,    35    ,    504    ,    30    ,    "2-10"    }    ,    --    lev    28
{    631    ,    40    ,    632    ,    30    ,    "2-10"    }    ,    --    lev    29
{    632    ,    40    ,    2102    ,    30    ,    "2-10"    }    ,    --    lev    30
{    632    ,    50    ,    2102    ,    45    ,    "2-5"    }    ,    --    lev    31
{    633    ,    45    ,    2001    ,    40    ,    "2-5"    }    ,    --    lev    32
{    701    ,    35    ,    2103    ,    30    ,    "2-5"    }    ,    --    lev    33
{    701    ,    40    ,    2103    ,    40    ,    "2-5"    }    ,    --    lev    34
{    702    ,    40    ,    2002    ,    30    ,    "2-5"    }    ,    --    lev    35
{    704    ,    20    ,    2106    ,    20    ,    "2-5"    }    ,    --    lev    36
{    733    ,    30    ,    2003    ,    20    ,    "2-5"    }    ,    --    lev    37
{    734    ,    40    ,    2004    ,    20    ,    "2-5"    }    ,    --    lev    38
{    706    ,    40    ,    2005    ,    30    ,    "2-5"    }    ,    --    lev    39
{    707    ,    40    ,    2108    ,    20    ,    "2-5"    }    ,    --    lev    40
{    901    ,    40    ,    5123    ,    25    ,    "2-5"    }    ,    --    lev    41
{    902    ,    30    ,    5123    ,    30    ,    "2-5"    }    ,    --    lev    42
{    902    ,    40    ,    2031    ,    35    ,    "2-5"    }    ,    --    lev    43
{    903    ,    40    ,    2031    ,    40    ,    "2-5"    }    ,    --    lev    44
{    731    ,    50    ,    2032    ,    45    ,    "2-5"    }    ,    --    lev    45
{    732    ,    30    ,    5124    ,    30    ,    "2-5"    }    ,    --    lev    46
{    903    ,    35    ,    5125    ,    30    ,    "2-5"    }    ,    --    lev    47
{    904    ,    40    ,    5125    ,    35    ,    "2-5"    }    ,    --    lev    48
{    733    ,    40    ,    2033    ,    45    ,    "2-5"    }    ,    --    lev    49
{    734    ,    40    ,    5126    ,    20    ,    "2-5"    }    ,    --    lev    50
{    735    ,    50    ,    5126    ,    30    ,    "1-4"    }    ,    --    lev    51
{    904    ,    45    ,    2034    ,    45    ,    "1-4"    }    ,    --    lev    52
{    904    ,    50    ,    2034    ,    50    ,    "1-4"    }    ,    --    lev    53
{    736    ,    40    ,    1001    ,    30    ,    "1-4"    }    ,    --    lev    54
{    737    ,    40    ,    1301    ,    35    ,    "1-4"    }    ,    --    lev    55
{    905    ,    50    ,    1002    ,    30    ,    "1-4"    }    ,    --    lev    56
{    905    ,    60    ,    1002    ,    40    ,    "1-4"    }    ,    --    lev    57
{    906    ,    45    ,    1303    ,    40    ,    "1-4"    }    ,    --    lev    58
{    906    ,    50    ,    1303    ,    45    ,    "1-4"    }    ,    --    lev    59
{    907    ,    45    ,    1003    ,    40    ,    "1-4"    }    ,    --    lev    60

}

special.levelup_reward1 =
{
    -- warrior assassin  sura  shaman
    {     0,        0,      0,      0 },
    { 11200,    11400,  11600,  11800 }, -- ??
    { 12200,    12340,  12480,  12620 }, -- ??
    { 13000,    13000,  13000,  13000 }  -- ??
}

-- levelup_reward1 ??? ???? ??? ???? ??
-- ???? ???? ???? ??.
special.levelup_reward3 = {
    -- pct   item #  item count
    {   33,  27002,  10 }, -- 25%
    {   67,  27005,  10 }, -- 25%
  --{   75,  27101,   5 }, -- 25%
    {  100,  27114,   5 }, -- 25%
}

special.levelup_reward_gold21 =
{
    { 10000,    20 },
    { 20000,    50 },
    { 40000,    25 },
    { 80000,    3 },
    { 100000,    2 },
}
special.levelup_reward_gold31 =
{
    { 20000,    20 },
    { 40000,    40 },
    { 60000,    25 },
    { 80000,    10 },
    { 100000,    5 },
}
special.levelup_reward_gold41 =
{
    { 40000,    20 },
    { 60000,    40 },
    { 80000,    25 },
    { 100000,    10 },
    { 150000,    5 },
}
special.levelup_reward_gold51 =
{
    { 60000,    20 },
    { 80000,    40 },
    { 100000,    25 },
    { 150000,    10 },
    { 200000,    5 },
}

special.levelup_reward_exp21 =
{
    { 2,    9 },
    { 3,    14 },
    { 4,    39 },
    { 6,    24 },
    { 8,    9 },
    { 10,    4 },
}

special.levelup_reward_exp31 =
{
    { 2,    10 },
    { 2.5,    15 },
    { 3,    40 },
    { 3.5,    25 },
    { 4,    8 },
    { 4.5,    5 },
    { 5,    2 },
}
special.levelup_reward_exp41 =
{
    { 2,    10 },
    { 2.5,    15 },
    { 3,    40 },
    { 3.5,    25 },
    { 4,    8 },
    { 4.5,    5 },
    { 5,    2 },
}
special.levelup_reward_exp51 =
{
    { 1,    10 },
    { 1.5,    15 },
    { 2,    40 },
    { 2.5,    25 },
    { 3,    8 },
    { 3.5,    5 },
    { 4,    2 },
}

special.levelup_reward_item_21 =
{
    -- no couple ring
    { { 27002, 10 }, { 27005, 10 }, { 27114, 10 } }, -- lev 21
    { 15080, 15100, 15120, 15140 }, -- lev 22
    { 16080, 16100, 16120, 16140 }, -- lev 23
    { 17080, 17100, 17120, 17140 }, -- lev 24
    { { 27002, 10 }, { 27005, 10 }, { 27114, 10 } }, -- lev 25
    { { 27003, 20 }, { 27006, 20 }, { 27114, 10 } }, -- over lev 25

    -- with couple ring
    -- { { 27002, 10 }, { 27005, 10 }, { 27114, 10 }, { 70301, 1 } }, -- lev 21
    -- { 15080, 15100, 15120, 15140, 70301 }, -- lev 22
    -- { 16080, 16100, 16120, 16140, 70301 }, -- lev 23
    -- { 17080, 17100, 17120, 17140, 70301 }, -- lev 24
    -- { { 27002, 10 }, { 27005, 10 }, { 27114, 10 }, { 70301, 1 } }, -- lev 25
    -- { { 27003, 20 }, { 27006, 20 }, { 27114, 10 } }, -- over lev 25
}

special.warp_to_pos = {
-- ???
    {
    { 402100, 673900 },
    { 270400, 739900 },
    { 321300, 808000 },
    },
--????
    {
--A 5994 7563
--B 5978 6222
--C 7307 6898
    { 599400, 756300 },
    { 597800, 622200 },
    { 730700, 689800 },
    },
--????
    {
--A 2178 6272
    { 217800, 627200 },
--B 2219 5027
    { 221900, 502700 },
--C 3440 5025
    { 344000, 502500 },
    },
--???
    {
--A 4342 2906
    { 434200, 290600 },
--B 3752 1749
    { 375200, 174900 },
--C 4918 1736
    { 491800, 173600 },
    },
}

special.devil_tower =
{
    --{ 123, 608 },
    { 2048+126, 6656+384 },
    { 2048+134, 6656+147 },
    { 2048+369, 6656+629 },
    { 2048+369, 6656+401 },
    { 2048+374, 6656+167 },
    { 2048+579, 6656+616 },
    { 2048+578, 6656+392 },
    { 2048+575, 6656+148 },
}

special.lvq_map = {
    { -- "A1" 1
        {},
   
        { { 440, 565 }, { 460, 771 }, { 668, 800 },},
        { { 440, 565 }, { 460, 771 }, { 668, 800 },},
        { { 440, 565 }, { 460, 771 }, { 668, 800 },},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
       
        {{496, 401}, {494, 951}, {542, 1079}, {748, 9741},},
        {{853,557}, {845,780}, {910,956},},
        {{853,557}, {845,780}, {910,956},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
        {{340, 179}, {692, 112}, {787, 256}, {898, 296},},
       
        {{224,395}, {137,894}, {206,830}, {266,1067},},
        {{224,395}, {137,894}, {206,830}, {266,1067},},
        {{224,395}, {137,894}, {206,830}, {266,1067},},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
        {{405,74}},
       
        {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}},
       
        {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}}, {{405,74}},
    },


    { -- "A2" 2
        {},
       
        {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }},
       
        {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }},
       
        {{ 640,1437 }}, {{ 640,1437 }}, {{ 640,1437 }}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}},
       
        {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}}, {{640,1437}},
       
        {{640,1437}},
        {{640,1437}},
        {{640,1437}},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{244,1309}, {4567,1080}, {496,885}, {798,975}, {1059,1099}, {855,1351},},
        {{193,772}, {390,402}, {768,600}, {1075,789}, {1338,813},},
        {{193,772}, {390,402}, {768,600}, {1075,789}, {1338,813},},
    },



    { -- "A3" 3
        {},

        {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }},
        {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }}, {{ 948,804 }},

        {{ 948,804 }},
        {{ 948,804 }},
        {{ 948,804 }},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{438, 895}, {725, 864}, {632, 671},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{847, 412}, {844, 854}, {823, 757}, {433, 407},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{316,168}, {497,130}, {701,157}, {858,316},},
        {{200,277}, {130,646}, {211,638}, {291,851},},
        {{200,277}, {130,646}, {211,638}, {291,851},},
        {{200,277}, {130,646}, {211,638}, {291,851},},
        {{100,150}},
        {{100,150}},
        {{100,150}},
        {{100,150}},
        {{100,150}},
        {{100,150}},
    },

    {}, -- 4
    {}, -- 5
    {}, -- 6
    {}, -- 7
    {}, -- 8
    {}, -- 9
    {}, -- 10
    {}, -- 11
    {}, -- 12
    {}, -- 13
    {}, -- 14
    {}, -- 15
    {}, -- 16
    {}, -- 17
    {}, -- 18
    {}, -- 19
    {}, -- 20

    { -- "B1" 21
        {},
       
        {{412,635}, {629,428}, {829,586},},
        {{412,635}, {629,428}, {829,586},},
        {{412,635}, {629,428}, {829,586},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},
        {{329,643}, {632,349}, {905,556},},

        {{329,643}, {632,349}, {905,556},},
        {{866,822}, {706,224}, {247,722},},
        {{866,822}, {706,224}, {247,722},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
        {{617,948}, {353,221},},
   
        {{496,1089}, {890,1043},},
        {{496,1089}, {890,1043},},
        {{496,1089}, {890,1043},},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
        {{876,1127}},
   
        {{876,1127}}, {{876,1127}}, {{876,1127}}, {{876,1127}}, {{876,1127}},    {{876,1127}},    {{876,1127}},    {{876,1127}},    {{876,1127}}, {{876,1127}},
        {{876,1127}}, {{876,1127}}, {{876,1127}}, {{908,87}},    {{908,87}},        {{908,87}},        {{908,87}},        {{908,87}},        {{908,87}},
    },

    { -- "B2" 22
        {},

        {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }},
        {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }},
        {{ 95,819 }}, {{ 95,819 }}, {{ 95,819 }}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}},
        {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}}, {{746,1438}},

        {{746,1438}},
        {{746,1438}},
        {{746,1438}},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{ 172,810}, {288,465}, {475,841}, {303,156}, {687,466},},
        {{787,235}, {1209,382}, {1350,571}, {1240,852}, {1254,1126}, {1078,1285}, {727,1360},},
        {{787,235}, {1209,382}, {1350,571}, {1240,852}, {1254,1126}, {1078,1285}, {727,1360},},
    },


    { -- "B3" 23
        {},
       
        {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }},
        {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }}, {{ 106,88 }},

         {{ 106,88 }},
        {{ 106,88 }},
        {{ 106,88 }},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{230, 244}, {200, 444}, {594, 408},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{584,204}, {720,376}, {861,272},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{566,694}, {349,574}, {198,645},},
        {{816,721}, {489,823},},
        {{816,721}, {489,823},},
        {{816,721}, {489,823},},
        {{772,140}},
        {{772,140}},
        {{772,140}},
        {{772,140}},
        {{772,140}},
        {{772,140}},
    },

    {}, -- 24
    {}, -- 25
    {}, -- 26
    {}, -- 27
    {}, -- 28
    {}, -- 29
    {}, -- 30
    {}, -- 31
    {}, -- 32
    {}, -- 33
    {}, -- 34
    {}, -- 35
    {}, -- 36
    {}, -- 37
    {}, -- 38
    {}, -- 39
    {}, -- 40

    { -- "C1" 41
        {},

        {{385,446}, {169,592}, {211,692}, {632,681},},
        {{385,446}, {169,592}, {211,692}, {632,681},},
        {{385,446}, {169,592}, {211,692}, {632,681},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
        {{385,374}, {227,815}, {664,771},},
       
        {{385,374}, {227,815}, {664,771},},
        {{169,362}, {368,304}, {626,409}, {187,882}, {571,858},},
        {{169,362}, {368,304}, {626,409}, {187,882}, {571,858},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
        {{178,275}, {365,242}, {644,313}, {194,950}, {559,936},},
       
        {{452,160}, {536,1034}, {184,1044},},
        {{452,160}, {536,1034}, {184,1044},},
        {{452,160}, {536,1034}, {184,1044},},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
        {{137,126}},
       
        {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}},
        {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}}, {{137,126}},
    },

    { -- "C2" 42
        {},

        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
        {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}}, {{1409,139}},
   
        {{1409,139}},
        {{1409,139}},
        {{1409,139}},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{991,222}, {1201,525}, {613,232}, {970,751}, {1324,790},},
        {{192,211}, {247,600}, {249,882}, {987,981}, {1018,1288}, {1303,1174},},
        {{192,211}, {247,600}, {249,882}, {987,981}, {1018,1288}, {1303,1174},},
    },

    { -- "C3" 43
        {},

        {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}},
        {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}}, {{901,151}},
   
        {{901,151}},
        {{901,151}},
        {{901,151}},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{421, 189}, {167, 353},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{679,459}, {505,709},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{858,638}, {234,596},},
        {{635,856}, {324,855},},
        {{635,856}, {324,855},},
        {{635,856}, {324,855},},
        {{136,899}},
        {{136,899}},
        {{136,899}},
        {{136,899}},
        {{136,899}},
        {{136,899}},
    },

    {}, -- 44
    {}, -- 45
    {}, -- 46
    {}, -- 47
    {}, -- 48
    {}, -- 49
    {}, -- 50
    {}, -- 51
    {}, -- 52
    {}, -- 53
    {}, -- 54
    {}, -- 55
    {}, -- 56
    {}, -- 57
    {}, -- 58
    {}, -- 59
    {}, -- 60
}

function BuildSkillList(job, group)
    local skill_vnum_list = {}
    local skill_name_list = {}

    if pc.get_skill_group() != 0 then
        local skill_list = special.active_skill_list[job+1][group]
               
        table.foreachi( skill_list,
            function(i, t)
                local lev = pc.get_skill_level(t)

                if lev > 0 then
                    local name = locale.GM_SKILL_NAME_DICT[t]

                    if name != nil then
                        table.insert(skill_vnum_list, t)
                        table.insert(skill_name_list, name)
                    end
                end
            end
        )
    end

    table.insert(skill_vnum_list, 0)
    table.insert(skill_name_list, "??")

    return { skill_vnum_list, skill_name_list }
end

PREMIUM_EXP             = 0
PREMIUM_ITEM            = 1
PREMIUM_SAFEBOX         = 2
PREMIUM_AUTOLOOT        = 3
PREMIUM_FISH_MIND       = 4
PREMIUM_MARRIAGE_FAST   = 5
PREMIUM_GOLD            = 6

-- point type start
POINT_NONE                 = 0
POINT_LEVEL                = 1
POINT_VOICE                = 2
POINT_EXP                  = 3
POINT_NEXT_EXP             = 4
POINT_HP                   = 5
POINT_MAX_HP               = 6
POINT_SP                   = 7
POINT_MAX_SP               = 8
POINT_STAMINA              = 9  --????
POINT_MAX_STAMINA          = 10 --?? ????

POINT_GOLD                 = 11
POINT_ST                   = 12 --??
POINT_HT                   = 13 --??
POINT_DX                   = 14 --???
POINT_IQ                   = 15 --???
POINT_DEF_GRADE            = 16
POINT_ATT_SPEED            = 17 --????
POINT_ATT_GRADE            = 18 --??? MAX
POINT_MOV_SPEED            = 19 --????
POINT_CLIENT_DEF_GRADE        = 20 --????
POINT_CASTING_SPEED        = 21 --???? (?????*100) / (100 + ??) = ?? ??? ??
POINT_MAGIC_ATT_GRADE      = 22 --?????
POINT_MAGIC_DEF_GRADE      = 23 --?????
POINT_EMPIRE_POINT         = 24 --????
POINT_LEVEL_STEP           = 25 --? ????? ??.. (1 2 3 ? ? ?? 4 ?? ?? ?)
POINT_STAT                 = 26 --??? ?? ? ?? ??
POINT_SUB_SKILL            = 27 --?? ?? ???
POINT_SKILL                = 28 --??? ?? ???
POINT_WEAPON_MIN            = 29 --?? ?? ???
POINT_WEAPON_MAX            = 30 --?? ?? ???
POINT_PLAYTIME             = 31 --?????
POINT_HP_REGEN             = 32 --HP ???
POINT_SP_REGEN             = 33 --SP ???

POINT_BOW_DISTANCE         = 34 --? ???? ??? (meter)

POINT_HP_RECOVERY          = 35 --?? ?? ???
POINT_SP_RECOVERY          = 36 --??? ?? ???

POINT_POISON_PCT           = 37 --? ??
POINT_STUN_PCT             = 38 --?? ??
POINT_SLOW_PCT             = 39 --??? ??
POINT_CRITICAL_PCT         = 40 --???? ??
POINT_PENETRATE_PCT        = 41 --???? ??
POINT_CURSE_PCT            = 42 --?? ??

POINT_ATTBONUS_HUMAN       = 43 --???? ??
POINT_ATTBONUS_ANIMAL      = 44 --???? ??? % ??
POINT_ATTBONUS_ORC         = 45 --???? ??? % ??
POINT_ATTBONUS_MILGYO      = 46 --???? ??? % ??
POINT_ATTBONUS_UNDEAD      = 47 --???? ??? % ??
POINT_ATTBONUS_DEVIL       = 48 --??(??)?? ??? % ??
POINT_ATTBONUS_INSECT      = 49 --???
POINT_ATTBONUS_FIRE        = 50 --???
POINT_ATTBONUS_ICE         = 51 --???
POINT_ATTBONUS_DESERT      = 52 --???
POINT_ATTBONUS_MONSTER     = 53 --?? ????? ??
POINT_ATTBONUS_WARRIOR     = 54 --???? ??
POINT_ATTBONUS_ASSASSIN    = 55 --???? ??
POINT_ATTBONUS_SURA        = 56 --???? ??
POINT_ATTBONUS_SHAMAN        = 57 --???? ??

-- ADD_TRENT_MONSTER
POINT_ATTBONUS_TREE         = 58 --???? ?? 20050729.myevan UNUSED5
-- END_OF_ADD_TRENT_MONSTER
POINT_RESIST_WARRIOR        = 59 --???? ??
POINT_RESIST_ASSASSIN        = 60 --???? ??
POINT_RESIST_SURA            = 61 --???? ??
POINT_RESIST_SHAMAN        = 62 --???? ??

POINT_STEAL_HP             = 63 --??? ??
POINT_STEAL_SP             = 64 --??? ??

POINT_MANA_BURN_PCT        = 65 --?? ?

--/ ??? ??? =/

POINT_DAMAGE_SP_RECOVER    = 66 --???? ? ??? ?? ??

POINT_BLOCK                = 67 --???
POINT_DODGE                = 68 --???

POINT_RESIST_SWORD         = 69
POINT_RESIST_TWOHAND       = 70
POINT_RESIST_DAGGER        = 71
POINT_RESIST_BELL          = 72
POINT_RESIST_FAN           = 73
POINT_RESIST_BOW           = 74  --??   ??   : ??? ??
POINT_RESIST_FIRE          = 75  --??   ??   : ????? ?? ??? ??
POINT_RESIST_ELEC          = 76  --??   ??   : ????? ?? ??? ??
POINT_RESIST_MAGIC         = 77  --??   ??   : ????? ?? ??? ??
POINT_RESIST_WIND          = 78  --??   ??   : ????? ?? ??? ??

POINT_REFLECT_MELEE        = 79 --?? ??

--/ ?? ??? =/
POINT_REFLECT_CURSE        = 80 --?? ??
POINT_POISON_REDUCE        = 81 --???? ??

--/ ? ??? =/
POINT_KILL_SP_RECOVER        = 82 --? ??? MP ??
POINT_EXP_DOUBLE_BONUS        = 83
POINT_GOLD_DOUBLE_BONUS        = 84
POINT_ITEM_DROP_BONUS        = 85

--/ ?? ?? =/
POINT_POTION_BONUS            = 86
POINT_KILL_HP_RECOVERY        = 87

POINT_IMMUNE_STUN            = 88
POINT_IMMUNE_SLOW            = 89
POINT_IMMUNE_FALL            = 90
--========

POINT_PARTY_ATTACKER_BONUS        = 91
POINT_PARTY_TANKER_BONUS        = 92

POINT_ATT_BONUS            = 93
POINT_DEF_BONUS            = 94

POINT_ATT_GRADE_BONUS        = 95
POINT_DEF_GRADE_BONUS        = 96
POINT_MAGIC_ATT_GRADE_BONUS    = 97
POINT_MAGIC_DEF_GRADE_BONUS    = 98

POINT_RESIST_NORMAL_DAMAGE        = 99

POINT_HIT_HP_RECOVERY        = 100
POINT_HIT_SP_RECOVERY         = 101
POINT_MANASHIELD            = 102 --???? ??? ?? ???? ?? ??

POINT_PARTY_BUFFER_BONUS        = 103
POINT_PARTY_SKILL_MASTER_BONUS    = 104

POINT_HP_RECOVER_CONTINUE        = 105
POINT_SP_RECOVER_CONTINUE        = 106

POINT_STEAL_GOLD            = 107
POINT_POLYMORPH            = 108 --??? ??? ??
POINT_MOUNT                = 109 --???? ??? ??

POINT_PARTY_HASTE_BONUS        = 110
POINT_PARTY_DEFENDER_BONUS        = 111
POINT_STAT_RESET_COUNT        = 112 --?? ?? ??? ?? ?? ?? ??? (1? 1??? ????)

POINT_HORSE_SKILL            = 113

POINT_MALL_ATTBONUS        = 114 --??? +x%
POINT_MALL_DEFBONUS        = 115 --??? +x%
POINT_MALL_EXPBONUS        = 116 --??? +x%
POINT_MALL_ITEMBONUS        = 117 --??? ??? x/10?
POINT_MALL_GOLDBONUS        = 118 --? ??? x/10?

POINT_MAX_HP_PCT            = 119 --????? +x%
POINT_MAX_SP_PCT            = 120 --????? +x%

POINT_SKILL_DAMAGE_BONUS        = 121 --?? ??? *(100+x)%
POINT_NORMAL_HIT_DAMAGE_BONUS    = 122 --?? ??? *(100+x)%

-- DEFEND_BONUS_ATTRIBUTES
POINT_SKILL_DEFEND_BONUS        = 123 --?? ?? ???
POINT_NORMAL_HIT_DEFEND_BONUS    = 124 --?? ?? ???
-- END_OF_DEFEND_BONUS_ATTRIBUTES

-- PC_BANG_ITEM_ADD
POINT_PC_BANG_EXP_BONUS        = 125 --PC? ?? ??? ???
POINT_PC_BANG_DROP_BONUS        = 126 --PC? ?? ??? ???
-- END_PC_BANG_ITEM_ADD
-- POINT_MAX_NUM = 128    common/length.h
-- point type start

function setvarchar(name, var)
    local laenge = string.len (var)
    local setchar = 0
    local save_name = 0
    local letter = 0
    while laenge > setchar do
        setchar = setchar + 1
        letter = string.sub (var, setchar, setchar)
        letter = string.byte(letter, 1)
        save_name = ""..name.."_char_"..setchar..""
        pc.setqf(save_name, letter)
    end
    local save_laenge=""..name.."laenge"
    pc.setqf(save_laenge, laenge)
end

function getvarchar(name)
    local save_laenge = ""..name.."laenge"
    local laenge = pc.getqf(save_laenge)
    local save_name = 0
    local var = ""
    local letter = 0
    local getchar = 0
    while laenge > getchar do
        getchar = getchar + 1
        save_name = ""..name.."_char_"..getchar..""
        letter = pc.getqf(save_name)
        if letter!=0 then
            letter = string.char(letter)
        else
            letter = ""
        end
        var = ""..var..""..letter..""
    end
    return var
end

function delvarchar(name)
    local save_laenge = ""..name.."laenge"
    local laenge = pc.getqf(save_laenge)
    local getchar = 0
    while laenge > getchar do
        getchar = getchar + 1
        local save_name = ""..name.."_char_"..getchar..""
        pc.delqf(save_name)
    end
    pc.delqf(save_laenge)
end

function global_setvarchar(name, var)
    local laenge = string.len (var)
    local setchar = 0
    local save_name = 0
    local letter = 0
    while laenge > setchar do
        setchar = setchar + 1
        letter = string.sub (var, setchar, setchar)
        letter = string.byte(letter)
        if letter==91 or letter==93 then
            letter=32
        end
        save_name = ""..name.."_char_"..setchar..""
        game.set_event_flag(save_name, letter)
    end
    local save_laenge=""..name.."laenge"
    game.set_event_flag(save_laenge, laenge)
end

function global_getvarchar(name)
    local save_laenge = ""..name.."laenge"
    local laenge = game.get_event_flag(save_laenge)
    local save_name = 0
    local var = ""
    local letter = 0
    local getchar = 0
    while laenge > getchar do
        getchar = getchar + 1
        save_name = ""..name.."_char_"..getchar..""
        letter = game.get_event_flag(save_name)
        if letter!=0 then
            letter = string.char(letter)
        else
            letter = ""
        end
       
        var = ""..var..""..letter..""
    end
    return var
end

function actual_time()
    return os.date()
end

function actual_timestamp()
    return os.time()
end

function search_time(h,m,s)
    local out = {}
    out.h = os.date("%H")+h
    out.m = os.date("%M")+m
    out.s = os.date("%S")+s
    while out.h >= 24 do
        out.h = out.h - 24
    end
    while out.m >= 60 do
        out.m = out.m - 60
    end
    while out.s >= 60 do
        out.s = out.s - 60
    end
    if out.h < 10 then
        out.h = "0"..out.h
    end
    if out.m < 10 then
        out.m = "0"..out.m
    end
    if out.s < 10 then
        out.s = "0"..out.s
    end
    return out
end

function SendAchievement(Achievement, new_points, count)
    local Achievement = string.gsub(Achievement, " ", "_")
    if count != nil then
        if count != 1 then
            Achievement = Achievement.."#"..count
        end
    end
    cmdchat("achievement "..Achievement.."%"..new_points.."")
end

function setenergy(typ,value,timez)
pc.setqf("energy_value",value)
pc.setqf("energy_typ",typ)
pc.setqf("energy_date",timez)
end

function setenergytime(timez)
pc.setqf("energy_date",timez)
end
function getenergytyp()
return pc.getqf("energy_typ")
end

function getenergyvalue()
return pc.getqf("energy_value")
end
function getenergytime()
return pc.getqf("energy_date")
end

function costume_system_create()
    os.execute("mysql -u root player --execute=\"INSERT INTO costume_system(pid) VALUES ('".. pc.get_player_id() .."')\"")
end

function costume_system_read(type_v)
    local mysql_read = (mysql_query("SELECT "..type_v.." as result_value from player.costume_system where pid = ('".. pc.get_player_id() .."')") or {["result_value"] = 0})
    return mysql_read.result_value[1]
end

function costume_system_update(type_s, value)
    if type_s == "part_main_old" then
        if value < 41002 then
            os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
        end

    elseif type_s == "part_hair_old" then
        os.execute("mysql -u root player --execute=\"UPDATE costume_system SET "..type_s.." =('"..value.."') where pid = ('".. pc.get_player_id() .."')\"")
    end
end


TORNEO_READ            = 0
TORNEO_PLUS            = 1
TORNEO_NEW            = 3
TORNEO_NEXT            = 4

TORNEO_MEMBER        = 1
TORNEO_REGISTRED    = 2
TORNEO_START        = 3
TORNEO_FINISH        = 4
TORNEO_STAGE        = 5
TORNEO_ROUND        = 6

function torneo_open_regi()
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo_stage_*"
    os.execute("cd "..TORNEO_PATH.." && rm -rf "..TORNEO_FILE)
    game.set_event_flag("torneo_close", 0)
end

function torneo_round(number)
    local stage = { 8,16,24,32,40,48,56,64 }
    local x = 1
    while true do
        if stage[x] == nil then break end
        if number <= stage[x] then
            return x
        end
        x = x + 1
    end
end

function torneo_tool(linea, stage, round, modo)
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo_stage_"..stage.."_round_"..round..".txt"
    local x = 1
    local file
    local newRound
    local result
    if modo == 0 then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            local line = file:read("*l")
            if line == nil then
                break
            end
            local text = string.gsub(line, "\n", "")
            if x == linea then
                io.close(file)
                return text
            end
            x = x + 1
        end
        io.close(file)
    elseif modo == 1 then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "a+")
        file:write(linea.."\n")
        io.close(file)
    elseif modo == 2 then
        if round <= 2 then
            newRound = 1
        elseif round <= 4 then
            newRound = 2
        elseif round <= 6 then
            newRound = 3
        elseif round <= 8 then
            newRound = 4
        end
        local TORNEO_NEWFILE = "torneo_stage_"..stage.."_round_"..newRound..".txt"
        file = io.open(TORNEO_PATH..TORNEO_NEWFILE, "a+")
        file:write(linea.."\n")
        io.close(file)
        return newRound
    end
end

function torneo_data(linea, modo)
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo.txt"
    local x = 1
    local file = ""
    if modo == TORNEO_READ then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            local line = file:read("*l")
            if line == nil then
                break
            end
            local text = string.gsub(line, "\n", "")
            if x == linea then
                io.close(file)
                return text
            end
            x = x + 1
        end
        io.close(file)
    elseif modo == TORNEO_PLUS then
        local linee = {}
        local x = 1
        local y = 1
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            linee[x] = file:read("*l")
            if linee[x] == nil then
                break
            end
            x = x + 1
        end
        io.close(file)
        os.rename(TORNEO_PATH..TORNEO_FILE, TORNEO_PATH..TORNEO_FILE..".BAK")
        local update = io.open(TORNEO_PATH..TORNEO_FILE, "a+")
        while true do
            if linee[y] == nil then break end
            if y == linea then
                local newPoint = tonumber(linee[y]) + 1
                update:write(newPoint.."\n")
            else
                update:write(linee[y].."\n")
            end
            io.flush()
            y = y + 1
        end
        io.close(update)
    elseif modo == TORNEO_NEXT then
        local linee = {}
        local x = 1
        local y = 1
        file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
        while true do
            linee[x] = file:read("*l")
            if linee[x] == nil then
                break
            end
            x = x + 1
        end
        io.close(file)
        local newMember = tonumber(linee[1])/2
        local newFinish = 0
        local newStage = tonumber(linee[5])+1
        local newRound = 1
        local newStart = tonumber(linee[3])+1
        local update = io.open(TORNEO_PATH..TORNEO_FILE, "w+")
        update:write(newMember.."\n"..linee[2].."\n"..newStart.."\n"..newFinish.."\n"..newStage.."\n"..newRound.."\n")
        io.close(update)
    elseif modo == TORNEO_NEW then
        file = io.open(TORNEO_PATH..TORNEO_FILE, "w+")
        file:write(linea.."\n0\n0\n0\n1\n1\n")
        io.close(file)
    end
end

function torneo_opp(posizione, stage, round)
    local member = {}
    local x = 1
    local sfidanti = tonumber(torneo_member(stage, round))/2
    while true do
        member[x] = torneo_tool(x, stage, round, 0)
        if member[x] == nil then break end
        x = x + 1
    end
    local opps = sfidanti + posizione
    local chll = posizione - sfidanti
    if posizione <= sfidanti then
        return member[opps]
    else
        return member[chll]
    end
end

function torneo_member(stage, round)
    local TORNEO_PATH = "locale/turkey/quest/object/torneo/"
    local TORNEO_FILE = "torneo_stage_"..stage.."_round_"..round..".txt"
    local x = 1
    local file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
    while true do
        local line = file:read("*l")
        if line == nil then break end
        x = x + 1
    end
    io.close(file)
    local result = x - 1
    return result
end      

function torneo_number(name, stage, round)
    local player = {}
    local x = 1
    while true do
        player[x] = torneo_tool(x, stage, round, 0)
        if player[x] == name then break end
        x = x + 1
    end
    return x
end

function say_color(color,text)
if color=="blue" then
say(color256(0, 0, 255)..text..color256(196, 196, 196))
elseif color == "green" then
say(color256(0, 255, 0)..text..color256(196, 196, 196))
elseif color == "red" then
say(color256(255, 0, 0)..text..color256(196, 196, 196))
elseif color == "yellow" then
say(color256(255, 255, 0)..text..color256(196, 196, 196))
elseif color == "white" then
say(color256(255, 255, 255)..text..color256(196, 196, 196))
elseif color == "black" then
say(color256(0, 0, 0)..text..color256(196, 196, 196))
elseif color == "cyan" then
say(color256(0, 255, 255)..text..color256(196, 196, 196))
elseif color == "pink" then
say(color256(255, 0, 255)..text..color256(196, 196, 196))
elseif color == "orange" then
say(color256(255, 145, 0)..text..color256(196, 196, 196))
elseif color == "purple" then
say(color256(100, 0, 255)..text..color256(196, 196, 196))
else
say(color256(196, 196, 196)..text..color256(196, 196, 196))
end
end

PetExpTable = {
    [1] = 300, [2] = 600, [3] = 900,
    [4] = 1200, [5] = 1500, [6] = 1800,
    [7] = 2100, [8] = 2400, [9] = 2700,
    [10] = 3000, [11] = 3300, [12] = 3600,
    [13] = 3900, [14] = 4200, [15] = 4500,
    [16] = 4800, [17] = 5100, [18] = 5400,
    [19] = 5700, [20] = 6000, [21] = 6300,
    [22] = 6600, [23] = 6900, [24] = 7200,
    [25] = 7500, [26] = 7800, [27] = 8100,
    [28] = 8400, [29] = 8700, [30] = 9000,
    [31] = 9300, [32] = 9600, [33] = 9900,
    [34] = 10200, [35] = 10500, [36] = 10800,
    [37] = 11100, [38] = 11400, [39] = 11700,
    [40] = 12000, [41] = 12300, [42] = 12600,
    [43] = 12900, [44] = 13200, [45] = 13500,
    [46] = 13800, [47] = 14100, [48] = 14400,
    [49] = 14700, [50] = 15000,    [51] = 15300,
    [52] = 15600, [53] = 15900, [54] = 16200,
    [55] = 16500, [56] = 16800, [57] = 17100,
    [58] = 17400, [59] = 17700, [60] = 18000,
    [61] = 18300, [62] = 18600, [63] = 18900,
    [64] = 19200, [65] = 19500, [66] = 19800,
    [67] = 20100, [68] = 20400, [69] = 20700,
    [70] = 21000, [71] = 21300, [72] = 21600,
    [73] = 21900, [74] = 22200, [75] = 22500,
    [76] = 22800, [77] = 23100, [78] = 23400,
    [79] = 23700, [80] = 24000,    [81] = 24300,
    [82] = 24600, [83] = 24900, [84] = 25200,
    [85] = 25500, [86] = 25800, [87] = 26100,
    [88] = 26400, [89] = 26700, [90] = 27000,
    [91] = 27300, [92] = 27600, [93] = 27900,
    [94] = 28200, [95] = 28500, [96] = 28800,
    [97] = 29100, [98] = 29400, [99] = 29700,
    [100] = 30000, [101] = 30300, [102] = 30600,
    [103] = 30900, [104] = 31200, [105] = 31500,
    [106] = 31800, [107] = 32100, [108] = 32400,
    [109] = 32700, [110] = 33000, [111] = 33300,
    [112] = 33600, [113] = 33900, [114] = 34200,
    [115] = 34500, [116] = 34800, [117] = 35100,
    [118] = 35400, [119] = 35700, [120] = 36000,
    [121] = 36300, [122] = 36600, [123] = 36900,
    [124] = 37200, [125] = 37500, [126] = 37800,
    [127] = 38100, [128] = 38400, [129] = 38700,
    [130] = 39000, [131] = 39300, [132] = 39600,
    [133] = 39900, [134] = 40200, [135] = 40500,
    [136] = 40800, [137] = 41100, [138] = 41400,
    [139] = 41700, [140] = 42000, [141] = 42300,
    [142] = 42600, [143] = 42900, [144] = 43200,
    [145] = 43500, [146] = 43800, [147] = 44100,
    [148] = 44400, [149] = 44700, [150] = 45000,
}


PetBonus = {
    { "Ofansif", { "Saldiri Degeri","Buyulu Saldiri Degeri", }, { "Savascilara Karsi Guclu","Ninjalara Karsi Guclu","Suralara Karsi Guclu","Samanlara Karsi Guclu","Canavarlara Karsi Guclui", }, { "Kritik Vurus Sansi","Delici Vurus Sansi", }, { "Sersemletme Sansi","Zehirleme Sansi","Yavaslatma Sansi", }, },
    { "Defansif", { "Savunma","Buyu Savunmasi", }, { "Kilic Savunmasi","?ftel Savunmasi","Bicak Savunmasi","Can Savunmasi","Yelpaze Savunmasi","Ok Savunmasi","Buyuye Karsi Dayanikllik", }, { "Max HP","Max SP", }, { "HP Uretimi","SP Uretimi", }, },
    { 1, { 53,55, }, { 59,60,61,62,63, }, { 15,16, }, { 13,12,14, }, },
    { 2, { 54,56, }, { 29,30,31,32,33,34,37, }, { 1,2, }, { 10,11, }, },
}


PetArray = {
    {53001, "atesankasi", "Ates Ankasi", 30068, PetExpTable, { 3,1,3,1, }, },
    {53002, "buzankasi", "Buz Ankasi", 30068, PetExpTable, { 3,3,1,1, }, },
    {53003, "rengeyigi", " Ren Geyigi", 30068, PetExpTable, { 3,1,1,3, }, },
    {53005, "gencazrail", "Genc Azrail", 30068, PetExpTable, { 2,1,3,2, }, },
    {53006, "genckurt", " Genc Kurt", 30068, PetExpTable, { 1,3,1,3, }, },
    {53007, "gencaslan", " Genc Aslan", 30068, PetExpTable, { 1,1,3,3, }, },
    {53008, "gencdomuz", "Genc Domuz", 30068, PetExpTable, { 1,3,3,1, }, },
    {53009, "genckaplan", "Genc Kaplan", 30068, PetExpTable, { 2,3,2,1, }, },
}


PET_NAME                 = 1
PET_LEVEL                = 2
PET_EXP                    = 3


PET_TYPE                = 1
PET_BON1                = 2
PET_BON2                = 3
PET_BON3                = 4
PET_BON4                = 5


PET_SUMMON                = 0
PET_UNSUMMON            = 1


PET_READ                = 0
PET_WRITE                = 1


PET_DATA                = 0
PET_BONUS                = 1


function inizializza(i)
    say_title(" Evcil Hayvan ")
    say("")
    say(" Merhaba , ?ce Evcil Hayvan?a ?im Vermelisin ")
    local scelta = select(" Tamam "," Daha Sonra ")
    if scelta == 2 then
        return -1
    end
    say_title(" Evcil Hayvan ")
    say("")
    say(" Evcil Hayvan?a Hangi ?mi Vermek ?tiyorsun? ")
    say("")
    say_reward(" ?im: ")
    local PetName = tostring(input())
    if PetName == "" then
        say_title(" Evcil Hayvan ")
        say("")
        say_reward(" Bo? B?akamazs?! ")
        return -1
    end
    local DATA_PATH = "locale/turkey/quest/object/pet/"
    local LOCAL_PATH = pc.get_name().."/"
    local PET_FILE = PetArray[i][2]..".txt"
    local PET_BONUS_FILE = PetArray[i][2].."_bonus.txt"
    if pc.getqf("local_path2") != 1 then
        os.execute("cd "..DATA_PATH.." && mkdir "..LOCAL_PATH.." && chmod 777 "..LOCAL_PATH)
        pc.setqf("local_path2", 1)
    end
    local file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE , "w")
    file:write(PetName.."\n1\n0\n") --nome livello exp
    io.close(file)
    local bonus = io.open(DATA_PATH..LOCAL_PATH..PET_BONUS_FILE , "w")
    bonus:write("0\n0\n0\n0\n0\n")  
    io.close(bonus)
    os.execute("cd "..DATA_PATH..LOCAL_PATH.." && chmod 777 *.txt")
    return 0
end


function GetGrade(i)
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local x = 0
    local y = 0
    local Grade = 1
    while true do
        x = x + 1
        y = y + 1
        if y == 10 then
            Grade = Grade + 1
            y = 0
        end
        if x == PetLevel then
            return Grade
        end
    end
end
   
function evoca(i, stato)
    local bonus = { 3,4,5,6, }
    local status = PetArray[i][6]
    local PetGrade = tonumber(GetGrade(i))
    local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ)
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local horse_level = horse.get_level()
    local apply = 0
    local level = 21 + i
    if stato == PET_SUMMON then
        local z = 1
        while true do
            if bonus[z] == nil then break end
            apply = PetGrade*status[z]
            affect.add_collect(bonus[z], apply, 60*60*8)
            z = z + 1
        end
        horse.set_level(level)
        horse.set_name(PetName)
        horse.summon()
        chat(" Evcil Hayvan????rd?. ")
        horse.set_level(horse_level)
    else
        local z = 1
        while true do
            if bonus[z] == nil then break end
            apply = PetGrade*status[z]
            affect.remove_collect(bonus[z], apply, 60*60*8)
            z = z + 1
        end
        horse.set_level(level)
        horse.unsummon()
        chat(" Evcil Hayvan??G?derdin. ")
        horse.set_level(horse_level)
    end
end


function PetInfo(x)
    while true do
        say_title(" Evcil Hayvan ")
        say("")
        say(" 4 Tane "..PetBonus[x][1].." Teknik Vard?")
        say(" A?a?daki Kategorilerden Bunlara Ula?abilirsin. ")
        local y = 0
        if x == 1 then
            y = select( " Sald??Teknikleri "," Sava? Teknikleri "," Vuru? Teknikleri "," ??c? Teknikler "," Geri D? ")
        else
            y = select( " Savunma Teknikleri "," Korunma Teknikleri "," Ya?am Teknikleri "," Yenileyici Teknikler "," Geri D? ")
        end
        if y == 5 then
            break
        end
        while true do
            say_title(" Evcil Hayvan ")
            say("Informazioni abilita':")
            say("")
            say("Con l'apprendimento di questa tecnica potrai")
            say("incrementare il valore "..PetBonus[x][1])
            say("Tecniche disponibili:")
            say("")
            local z = 1
            while true do
                if PetBonus[x][y+1][z] == nil then break end
                say_reward(PetBonus[x][y+1][z])
                z = z + 1
            end
            local b = select(" Geri D? ")
            if b == 1 then
                break
            end
        end
    end
end


function PetSet(i, t)
    say_title(" Evcil Hayvan ")
    say("")
    say(" "..PetBonus[t][1].." Tekni?mi Se?ek ?tiyorsun? ")
    say("")
    local conferma = select(" Evet "," Hay? ")
    if conferma == 2 then
        return
    end
    say_title(" Evcil Hayvan ")
    say("")
    say(" Yeni Beceriler Geli?tirip Hayvan??G?lendire- ")
    say(" bilirsin."..PetBonus[t][1].." Tekni? Se?ek ?tedi?ne ")
    say(" Eminmisin? E?r Tekni?ni Se?ikten Sonra ")
    say(" Be?nmezsen Yetene? De??ebilirsin. ")
    local k = select(" Evet "," Hay? ")
    if k == 2 then
        return
    end
    local w = 2
    local bonus = {}
    local bon = {}
    while true do
        if PetBonus[t][w] == nil then break end
        say_title(" Evcil Hayvan ")
        say(" Yetenek Se?e : ")
        say("")
        say_reward(" Yaln? Birini Se?bilirsin Dikkatli Se?m Yap ")
        say("")
        local x = select_table( PetBonus[t][w] )
        bonus[w-1] = x
        bon[w-1] = PetBonus[t][w][x]
        w = w + 1
    end
    say_title(" Evcil Hayvan ")
    say("")
    say(" Yetenek Se?min ? ?kilde :")
    say("")
    say(" Yetenek 1:  "..bon[1])
    say(" Yetenek 2:  "..bon[2])
    say(" Yetenek 3:  "..bon[3])
    say(" Yetenek 4:  "..bon[4])
    say("")
    say_reward(" Onayl?ormusun? ")
    say("")
    local c = select(" Evet "," Hay? ")
    if c == 2 then
        return
    end
    data_tool(i, t.."\n"..bonus[1].."\n"..bonus[2].."\n"..bonus[3].."\n"..bonus[4].."\n", PET_BONUS, PET_WRITE)
end


function PetMenuAbi(i)
    local check = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ))
    local status = PetArray[i][6]
    local PetGrade = tonumber(GetGrade(i))
    local PetType = tonumber(data_tool(i, PET_TYPE, PET_BONUS, PET_READ))
    local bon1 = tonumber(data_tool(i, PET_BON1, PET_BONUS, PET_READ))
    local bon2 = tonumber(data_tool(i, PET_BON2, PET_BONUS, PET_READ))
    local bon3 = tonumber(data_tool(i, PET_BON3, PET_BONUS, PET_READ))
    local bon4 = tonumber(data_tool(i, PET_BON4, PET_BONUS, PET_READ))
    if check == 0 then
        while true do
            say_title(" Evcil Hayvan ")
            say(" Merhaba,")
            say(" Burada Evcil Hayvaninin Yetene?ni Se?bilirsin. ")
            say(" Konu Hakk?da Bilgin Yoksa Bilgi Kismindan, ")
            say(" Bakabilirsin. ")
            local z = select( "Ofansif","Defans","Bilgi","Kapat")
            if z == 1 then
                PetSet(i, z)
                return
            elseif z == 2 then
                PetSet(i, z)
                return
            elseif z == 3 then
                while true do
                    say_title(" Evcil Hayvan ")
                    say("")
                    say(" 4 Farkli Yetenek S???Vard?, ")
                    say(" Sald??Stiline Ba??Olarak. ")
                    say("")
                    local x = select( "Ofansif Stil","Defansif Stil"," Geri D? ")
                    if x == 1 then
                        PetInfo(x)
                    elseif x == 2 then
                        PetInfo(x)
                    elseif x == 3 then
                        break
                    end
                end
            elseif z == 4 then
                break
            end
        end
    else
        say_title(" Evcil Hayvan ")
        say("")
        say_reward(" Ne Yapmak ?tiyorsun? ")
        say("")
        local y = select(" Mevcut Yetenekler "," Yetenek S??la "," Geri D? ")
        if y == 1 then
            local point = {}
            local p = 1
            while true do
                if status[p] == nil then break end
                point[p] = status[p]*PetGrade
                p = p + 1
            end
            say_title(" Evcil Hayvan ")
            say(" Mevcut ?ellikleri: ")
            say("")
            say_reward(" Statlar? ")
            say("VIT:  +"..point[1])
            say("INT:  +"..point[2])
            say("STR:  +"..point[3])
            say("DEX:  +"..point[4])
            say("")
            say_reward(" Yetenekleri: ")
            say(PetBonus[PetType][2][bon1]..":  +"..PetGrade)
            say(PetBonus[PetType][3][bon2]..":  +"..PetGrade)
            say(PetBonus[PetType][4][bon3]..":  +"..PetGrade)
            say(PetBonus[PetType][5][bon4]..":  +"..PetGrade)
        elseif y == 2 then
            say_title(" Evcil Hayvan ")
            say(" Yetene?ni S??lamak ?tedi?nden Eminmisin?")
            say(" E?r ?leysen Se?ek ?tedi?n Yetene? Se?")
            local j = select(" Ofansif Stil "," Defansif Stil "," Geri D? ")
            if j == 1 then
                PetSet(i, j)
            elseif j == 2 then
                PetSet(i, j)
            else
                return
            end
        elseif y == 3 then
            return
        end
    end
end


function show_pet_menu(i)
    local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ)
    local PetRace = PetArray[i][3]
    local PetFood = PetArray[i][4]
    local PetGrade = tonumber(GetGrade(i))
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local PetExp = tonumber(data_tool(i, PET_EXP, PET_DATA, PET_READ))
    local PetNextExp = PetArray[i][5][PetLevel]
    while true do
        say_title(" Evcil Hayvan ")
        say("")
        say(" Ne Yapmak ?tiyorsun? ")
        say("")
        local s = select(" Pet ?ellikleri ", " Peti Besle ", " Pet Yetenekleri ", " Di?r ", " Kapat " )
        if s == 4 then
            say_title(" Evcil Hayvan ")
            say("")
            say(" Ne Yapmak ?tiyorsun? ")
            say("")
            local z = select( " ?im Ver ", " G?der ", " Geri D? ", " Kapat " )
            if z == 1 then
                say_title(" Evcil Hayvan ")
                say("")
                say(" Evcil Hayvan?a Hangi ?mi Vermek ?tiyorsun? ")
                say("")
                say_reward("?im :")
                local PetNewName = tostring(input())
                if PetNewName == "" then
                    say_title(" Evcil Hayvan ")
                    say("")
                    say_reward(" Bo? B?akamazs?! ")
                    return
                end
                if PetNewName == nome then
                    say_title(" Evcil Hayvan ")
                    say("")
                    say_reward(" Ayn??mi Veremezsin! ")
                    return
                end
                data_tool(i, PetNewName.."\n"..PetLevel.."\n"..PetExp.."\n", PET_DATA, PET_WRITE)
                evoca(i, PET_UNSUMMON)
                evoca(i, PET_SUMMON)
                return
            elseif z == 2 then
                evoca(i, PET_UNSUMMON)
                return
            elseif z == 3 then
            elseif z == 4 then
                break
            end
        elseif s == 1 then
            say_title(" Evcil Hayvan ")
            say("")
            say(" ?im: "..PetName.." ")
            say(" S??: "..PetRace.." ")
            say(" Level: "..PetLevel.." ")
            say(" Yetenek Seviyesi: "..PetGrade.." ")
            say(" Exp: "..PetExp.." / "..PetNextExp.." ")
            say(" Sa??: "..horse.get_health_pct().."% ")
            say(" Dayan?l??: "..horse.get_stamina_pct().."% ")
            say(" Yeme?: "..item_name(PetFood).." ")
            return
        elseif s == 2 then
            if pc.countitem(PetFood) > 0 then
                say_title(" Evcil Hayvan ")
                say("")
                say(" Evcil Hayvan? Art? Karn?Tok ")
                pc.removeitem(PetFood, 1)
                horse.feed()
                return
            else
                say_title(" Evcil Hayvan ")
                say("")
                say(" Evcil Hayvan? Beslemek ?in "..item_name(PetFood).." Adl?")
                say(" Yeme? Sahip Olmal??. ")
                say("")
                return
            end
        elseif s == 3 then
            if PetLevel >= 10 then
                PetMenuAbi(i)
                return
            else
                say_title(" Evcil Hayvan ")
                say("")
                say_reward(" Yetenekler 10 Level ?t?Evcil Hayvanlar ?indir ")
                return
            end
        elseif s == 5 then
            break
        end
    end
end


function PetGiveExp(i, Point)
    local PetName = data_tool(i, PET_NAME, PET_DATA, PET_READ)
    local PetLevel = tonumber(data_tool(i, PET_LEVEL, PET_DATA, PET_READ))
    local PetExp = tonumber(data_tool(i, PET_EXP, PET_DATA, PET_READ))
    local PetNextExp = PetArray[i][5][PetLevel]
    if PetLevel == 150 then
        return
    end
    local PetNewExp = PetExp + Point
    while true do
        if PetNewExp < PetNextExp then break end
        PetNewExp = PetNewExp - PetNextExp
        PetLevel = PetLevel + 1
    end
    data_tool(i, PetName.."\n"..PetLevel.."\n"..PetNewExp.."\n", PET_DATA, PET_WRITE)
end


function data_tool(i, linea, tipo, modo)
    local DATA_PATH = "locale/turkey/quest/object/pet//"
    local LOCAL_PATH = pc.get_name().."/"
    local x = 1
    local file = ""
    local PET_FILE = ""
    local PET_BACKUP = ""
    if tipo == PET_DATA then
        PET_FILE = PetArray[i][2]..".txt"
        PET_BACKUP = PetArray[i][2]..".bak"
    elseif tipo == PET_BONUS then
        PET_FILE = PetArray[i][2].."_bonus.txt"
        PET_BACKUP = PetArray[i][2].."_bonus.bak"
    end
    if modo == PET_READ then
        file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE, "r")
        while true do
            local line = file:read("*l")
            if line == nil then
                break
            end
            text = string.gsub(line, "\n", "")
            if x == linea then
                io.close(file)
                return text
            end
            x = x + 1
        end
        io.close(file)
    elseif modo == PET_WRITE then
        os.execute("cd "..DATA_PATH..LOCAL_PATH.." && mv "..PET_FILE.." "..PET_BACKUP)
        file = io.open(DATA_PATH..LOCAL_PATH..PET_FILE, "w")
        file:write(linea)
        io.close(file)
        os.execute("cd "..DATA_PATH..LOCAL_PATH.." && chmod 777 "..PET_FILE)
    end
end

get_mob_level =
    {
        [2051] = 65,
        [2052] = 67,
        [2053] = 69,
        [2054] = 71,
        [2055] = 73,
        [11116] = 90,
        [2061] = 60,
        [2062] = 62,
        [2063] = 64,
        [2064] = 66,
        [2065] = 68,
        [2071] = 70,
        [2072] = 72,
        [2073] = 74,
        [2074] = 76,
        [2075] = 78,
        [2076] = 78,
        [11117] = 90,
        [2091] = 60,
        [2092] = 79,
        [2093] = 65,
        [2094] = 72,
        [2095] = 70,
        [2101] = 19,
        [2102] = 37,
        [2103] = 39,
        [2104] = 44,
        [2105] = 47,
        [2106] = 48,
        [2107] = 51,
        [2108] = 54,
        [5131] = 22,
        [2401] = 87,
        [5132] = 25,
        [2402] = 89,
        [5133] = 27,
        [2131] = 60,
        [2132] = 62,
        [2133] = 64,
        [2134] = 66,
        [2135] = 68,
        [101] = 1,
        [102] = 3,
        [103] = 4,
        [2152] = 37,
        [105] = 9,
        [106] = 13,
        [107] = 16,
        [108] = 7,
        [109] = 10,
        [110] = 12,
        [111] = 15,
        [112] = 19,
        [113] = 21,
        [114] = 18,
        [115] = 24,
        [5141] = 35,
        [131] = 8,
        [132] = 9,
        [133] = 11,
        [134] = 14,
        [135] = 18,
        [136] = 21,
        [137] = 12,
        [138] = 15,
        [139] = 17,
        [140] = 20,
        [141] = 24,
        [142] = 26,
        [143] = 24,
        [144] = 29,
        [151] = 9,
        [152] = 16,
        [153] = 10,
        [154] = 21,
        [2203] = 70,
        [2204] = 71,
        [2205] = 72,
        [2206] = 73,
        [2207] = 78,
        [171] = 1,
        [172] = 3,
        [173] = 4,
        [174] = 6,
        [175] = 9,
        [2224] = 71,
        [177] = 16,
        [178] = 7,
        [179] = 10,
        [180] = 12,
        [181] = 15,
        [182] = 19,
        [183] = 21,
        [184] = 18,
        [185] = 24,
        [2234] = 71,
        [2235] = 72,
        [191] = 30,
        [192] = 31,
        [193] = 33,
        [194] = 35,
        [5153] = 49,
        [5157] = 54,
        [2291] = 75,
        [2292] = 99,
        [2293] = 99,
        [5161] = 30,
        [2301] = 65,
        [2302] = 67,
        [2303] = 69,
        [2304] = 70,
        [2305] = 71,
        [2306] = 84,
        [2307] = 86,
        [2311] = 74,
        [2312] = 76,
        [2313] = 77,
        [2314] = 80,
        [2315] = 82,
        [301] = 18,
        [302] = 20,
        [303] = 25,
        [304] = 25,
        [8501] = 35,
        [8502] = 30,
        [8503] = 25,
        [8504] = 5,
        [8505] = 10,
        [8506] = 12,
        [8507] = 15,
        [8508] = 20,
        [8509] = 25,
        [8510] = 21,
        [8511] = 11,
        [331] = 18,
        [332] = 20,
        [333] = 25,
        [334] = 25,
        [351] = 18,
        [352] = 20,
        [353] = 25,
        [354] = 25,
        [2403] = 89,
        [2404] = 90,
        [2411] = 91,
        [2412] = 93,
        [2413] = 95,
        [2414] = 97,
        [2451] = 84,
        [5127] = 54,
        [2452] = 86,
        [2431] = 80,
        [2432] = 82,
        [2433] = 82,
        [2434] = 83,
        [2454] = 90,
        [391] = 23,
        [392] = 26,
        [393] = 28,
        [394] = 31,
        [395] = 23,
        [396] = 26,
        [397] = 28,
        [398] = 31,
        [401] = 26,
        [402] = 27,
        [403] = 29,
        [404] = 30,
        [405] = 33,
        [406] = 35,
        [8600] = 73,
        [8601] = 86,
        [8602] = 73,
        [8603] = 86,
        [8604] = 73,
        [8605] = 86,
        [8606] = 73,
        [8607] = 86,
        [8608] = 73,
        [8609] = 86,
        [8610] = 73,
        [8611] = 86,
        [8612] = 73,
        [8613] = 86,
        [8614] = 73,
        [8615] = 86,
        [8616] = 86,
        [11108] = 70,
        [431] = 31,
        [432] = 33,
        [433] = 35,
        [434] = 36,
        [435] = 38,
        [436] = 40,
        [2491] = 93,
        [2492] = 95,
        [2493] = 97,
        [2494] = 88,
        [2495] = 90,
        [451] = 26,
        [452] = 27,
        [453] = 29,
        [454] = 30,
        [455] = 33,
        [456] = 35,
        [2505] = 83,
        [2506] = 84,
        [2507] = 85,
        [2508] = 79,
        [2509] = 80,
        [2510] = 81,
        [2511] = 82,
        [2512] = 83,
        [2513] = 84,
        [2514] = 86,
        [1175] = 65,
        [491] = 32,
        [492] = 37,
        [493] = 39,
        [494] = 45,
        [2543] = 81,
        [2544] = 82,
        [2545] = 83,
        [2546] = 84,
        [2547] = 86,
        [501] = 29,
        [502] = 32,
        [503] = 35,
        [504] = 36,
        [531] = 35,
        [532] = 37,
        [533] = 40,
        [534] = 42,
        [2591] = 89,
        [2592] = 89,
        [2593] = 89,
        [2594] = 89,
        [2595] = 89,
        [2596] = 89,
        [2597] = 91,
        [2598] = 91,
        [551] = 29,
        [552] = 32,
        [553] = 35,
        [554] = 36,
        [2482] = 92,
        [2483] = 94,
        [2484] = 96,
        [5134] = 29,
        [591] = 42,
        [595] = 42,
        [601] = 26,
        [602] = 29,
        [603] = 31,
        [604] = 33,
        [2151] = 19,
        [104] = 6,
        [631] = 34,
        [632] = 36,
        [633] = 39,
        [634] = 40,
        [635] = 44,
        [636] = 46,
        [637] = 49,
        [2155] = 47,
        [2156] = 48,
        [651] = 34,
        [652] = 36,
        [653] = 39,
        [654] = 40,
        [2157] = 51,
        [656] = 46,
        [657] = 49,
        [2158] = 54,
        [2501] = 79,
        [2502] = 80,
        [2503] = 81,
        [5001] = 10,
        [2504] = 82,
        [691] = 50,
        [692] = 55,
        [693] = 60,
        [701] = 35,
        [702] = 38,
        [703] = 41,
        [704] = 44,
        [705] = 48,
        [706] = 49,
        [707] = 51,
        [731] = 52,
        [732] = 53,
        [733] = 54,
        [734] = 54,
        [735] = 55,
        [736] = 56,
        [737] = 57,
        [751] = 35,
        [752] = 38,
        [753] = 41,
        [754] = 44,
        [755] = 48,
        [756] = 49,
        [757] = 51,
        [771] = 52,
        [772] = 53,
        [773] = 54,
        [774] = 54,
        [775] = 55,
        [776] = 56,
        [777] = 57,
        [7050] = 35,
        [2481] = 91,
        [791] = 54,
        [792] = 62,
        [793] = 64,
        [794] = 72,
        [795] = 54,
        [796] = 62,
        [7051] = 31,
        [7001] = 52,
        [7002] = 53,
        [2191] = 67,
        [7004] = 54,
        [7005] = 55,
        [7006] = 56,
        [7007] = 56,
        [7008] = 52,
        [2192] = 72,
        [7010] = 54,
        [11107] = 70,
        [7012] = 52,
        [7013] = 53,
        [7014] = 54,
        [7015] = 54,
        [7016] = 55,
        [7017] = 56,
        [7018] = 56,
        [7019] = 59,
        [7020] = 59,
        [7021] = 60,
        [7022] = 61,
        [7023] = 62,
        [7024] = 64,
        [7025] = 66,
        [7026] = 67,
        [7027] = 70,
        [7028] = 72,
        [7029] = 35,
        [7030] = 31,
        [7031] = 33,
        [7032] = 35,
        [7033] = 36,
        [7034] = 38,
        [7035] = 40,
        [7036] = 52,
        [7037] = 53,
        [7038] = 54,
        [7039] = 54,
        [7040] = 55,
        [7041] = 56,
        [7042] = 57,
        [7043] = 81,
        [7044] = 81,
        [901] = 49,
        [902] = 51,
        [903] = 53,
        [904] = 55,
        [905] = 58,
        [906] = 58,
        [907] = 59,
        [5004] = 80,
        [5005] = 85,
        [7054] = 36,
        [2541] = 79,
        [7056] = 40,
        [7057] = 52,
        [7058] = 53,
        [7059] = 54,
        [7060] = 54,
        [2542] = 80,
        [7062] = 56,
        [2201] = 69,
        [7064] = 81,
        [7065] = 81,
        [7066] = 82,
        [7067] = 83,
        [7068] = 83,
        [2202] = 69,
        [7070] = 85,
        [7071] = 33,
        [7072] = 35,
        [7073] = 36,
        [7074] = 38,
        [155] = 24,
        [932] = 51,
        [933] = 53,
        [934] = 55,
        [935] = 58,
        [936] = 58,
        [937] = 59,
        [7082] = 83,
        [7083] = 83,
        [7084] = 84,
        [7085] = 85,
        [7086] = 35,
        [7087] = 36,
        [7088] = 38,
        [7089] = 40,
        [7090] = 54,
        [7091] = 55,
        [7092] = 56,
        [7093] = 57,
        [7094] = 83,
        [7095] = 83,
        [7096] = 84,
        [7097] = 85,
        [991] = 59,
        [992] = 60,
        [993] = 61,
        [1001] = 57,
        [1002] = 58,
        [1003] = 59,
        [1004] = 60,
        [5101] = 22,
        [5102] = 25,
        [5103] = 27,
        [5104] = 29,
        [5111] = 35,
        [5112] = 37,
        [5113] = 39,
        [5114] = 40,
        [5115] = 41,
        [5116] = 42,
        [5121] = 45,
        [5122] = 47,
        [5123] = 49,
        [5124] = 52,
        [5125] = 53,
        [5126] = 54,
        [1031] = 67,
        [1032] = 69,
        [1033] = 70,
        [1034] = 71,
        [1035] = 72,
        [1036] = 73,
        [1037] = 71,
        [1038] = 72,
        [1039] = 73,
        [1040] = 74,
        [1041] = 75,
        [2222] = 69,
        [5142] = 37,
        [5143] = 39,
        [5144] = 40,
        [5145] = 41,
        [5146] = 42,
        [2223] = 70,
        [11109] = 70,
        [5151] = 45,
        [5152] = 47,
        [176] = 13,
        [5154] = 52,
        [5155] = 53,
        [5156] = 54,
        [1061] = 67,
        [1062] = 69,
        [1063] = 70,
        [1064] = 71,
        [1065] = 72,
        [1066] = 73,
        [1067] = 71,
        [1068] = 72,
        [1069] = 73,
        [1070] = 74,
        [1071] = 75,
        [2227] = 90,
        [1091] = 75,
        [1092] = 75,
        [1093] = 78,
        [1094] = 75,
        [1095] = 82,
        [1096] = 75,
        [2231] = 69,
        [1101] = 62,
        [1102] = 63,
        [1103] = 64,
        [1104] = 64,
        [1105] = 65,
        [1106] = 66,
        [1107] = 66,
        [2233] = 70,
        [1131] = 81,
        [1132] = 81,
        [1133] = 82,
        [1134] = 83,
        [1135] = 83,
        [1136] = 84,
        [1137] = 85,
        [1151] = 52,
        [1152] = 53,
        [1153] = 54,
        [1154] = 54,
        [1155] = 55,
        [1156] = 56,
        [1157] = 56,
        [2221] = 69,
        [1171] = 62,
        [1172] = 63,
        [1173] = 64,
        [1174] = 64,
        [2153] = 39,
        [1176] = 66,
        [1177] = 66,
        [1191] = 70,
        [1192] = 70,
        [11110] = 70,
        [2154] = 44,
        [11505] = 100,
        [11506] = 100,
        [11507] = 100,
        [11508] = 100,
        [11509] = 100,
        [11510] = 100,
        [2225] = 72,
        [1301] = 57,
        [1302] = 59,
        [1303] = 58,
        [1304] = 75,
        [1305] = 61,
        [1306] = 75,
        [1307] = 80,
        [1308] = 40,
        [1309] = 65,
        [1310] = 95,
        [7045] = 82,
        [7046] = 83,
        [2226] = 60,
        [7047] = 83,
        [7048] = 84,
        [1331] = 57,
        [1332] = 59,
        [1333] = 58,
        [1334] = 75,
        [1335] = 61,
        [5002] = 75,
        [5003] = 1,
        [7052] = 33,
        [11111] = 70,
        [7053] = 35,
        [7055] = 38,
        [1401] = 66,
        [1402] = 73,
        [1403] = 77,
        [7061] = 55,
        [7003] = 54,
        [7063] = 57,
        [5162] = 43,
        [7069] = 84,
        [5163] = 55,
        [931] = 49,
        [7076] = 54,
        [2232] = 69,
        [1501] = 69,
        [1502] = 72,
        [1503] = 76,
        [7078] = 55,
        [7079] = 56,
        [7080] = 57,
        [7081] = 82,
        [7075] = 40,
        [11100] = 50,
        [7077] = 54,
        [7009] = 53,
        [1601] = 68,
        [1602] = 70,
        [1603] = 75,
        [11101] = 50,
        [11102] = 50,
        [11113] = 90,
        [11103] = 50,
        [11104] = 50,
        [7049] = 85,
        [11105] = 50,
        [11106] = 70,
        [655] = 44,
        [1901] = 72,
        [1902] = 77,
        [1903] = 82,
        [1904] = 40,
        [1905] = 65,
        [1906] = 95,
        [11112] = 90,
        [2453] = 88,
        [11114] = 90,
        [2001] = 43,
        [2002] = 45,
        [2003] = 48,
        [2004] = 50,
        [2005] = 52,
        [11115] = 90,
        [2031] = 50,
        [2032] = 52,
        [2033] = 54,
        [2034] = 56,
        [2035] = 58,
        [2036] = 58,
}

function level_aldir(carlevel)
    if pc.get_level() > carlevel then
        return
    else
        local level = pc.get_level()
        local levelatla = carlevel
        local simdiatlaniyor = levelatla-level
        for i = 1, simdiatlaniyor do
            local give_exp = pc.get_next_exp()
            pc.give_exp2(give_exp)    
        end
    end
end

function getinput(par)
    cmdchat("GetInputStringStart")
    local ret = input(cmdchat(par))
    cmdchat("GetInputStringEnd")
    return ret
end

function yang_Ayarla()
    yang2 = tostring(pc.get_gold())
    local yang = pc.get_gold()
    local sayac = 10
    local basamak = 1
    local ilkhal = basamak
    while true do
        if yang / sayac >= 1 then
            basamak = basamak + 1
            sayac = sayac * 10
        else
            break
        end
    end
    t = {}
    sonucText = ""
    for i=1, string.len(yang2) do
        t[i]= (string.sub(yang2,i,i))
    end
    for k , v in pairs(t) do
        if (basamak  == 9 or basamak == 6 or basamak == 3) and sonucText !=  "" then
            sonucText = sonucText.."."
            sonucText = sonucText..v
        else
            sonucText = sonucText..v
        end
        basamak = basamak - 1
    end
    return sonucText
end

function inc_today_count(questname, flag_name, count)
    local today = math.floor(get_global_time() / 86400)
    local today_flag = flag_name.."_today"
    local today_count_flag = flag_name.."_today_count"
    local last_day = pc.getqf(questname, today_flag)
    if last_day == today then
        pc.setf(questname, today_count_flag, pc.getf(questname, today_count_flag) + 1)
    else
        pc.setf(questname, today_flag, today)
        pc.setf(questname, today_count_flag, 1)
    end
end

function LIB_duration(ipe)
    -- if have == nil then
    -- seconds = ipe - get_global_time()
    -- chat("nil")
    -- else
    -- seconds = (get_global_time() + ipe) - get_global_time()
    -- chat("no nil")
    -- end
   
    if ipe >= get_global_time() then
    seconds = ipe - get_global_time()
    --chat("nil")
    else
    seconds = (get_global_time() + ipe) - get_global_time()
    --chat("no nil")
    end
   
   
    local days = 0
    local hours = math.floor(seconds / 3600)
    local mins = math.floor((seconds - (hours*3600)) / 60)
    local secs = math.floor(seconds - hours*3600 - mins*60 )
    local t = ""
    if tonumber(hours) >= 24 then
        days = math.floor(hours / 24)
        hours = math.floor(hours - (days*24))
    end
    if tonumber(days) == 1 then
        t = t..days.." Gun "
    elseif tonumber(days) >= 1 then
        t = t..days.." Gun "
    end
    if tonumber(hours) == 1 then
        t = t..hours.." Saat "
    elseif tonumber(hours) >= 1 then
        t = t..hours.." Saat "
    end
    if tonumber(mins) == 1 then
        t = t..mins.." Dakika "
    elseif tonumber(mins) >= 1 then
        t = t..mins.." Dakika "
    end
    if tonumber(secs) == 1 then
        t = t..secs.." Saniye "
    elseif tonumber(secs) >= 1 then
        t = t..secs.." Saniye "
    end
    if t == "" then
        return "(Keine Zeit Vorhanden!)"
    end
    return t
end

function say_npc()
    say_title(""..mob_name(npc.get_race()).."")
end

-- This function will return true always in window os,
--  but not in freebsd.
-- (In window os, RAND_MAX = 0x7FFF = 32767.)
function drop_gamble_with_flag(drop_flag)
        local dp, range = pc.get_killee_drop_pct()
        dp = 40000 * dp / game.get_event_flag(drop_flag)
        if dp < 0 or range < 0 then
            return false
        end
        return dp >= number(1, range)
end

function say2(str,dx)
    local maxl,actl,pat = dx or 50,0,'(.-)(%[.-%])()'
    local result,nb,lastPos,outp = {},0,0,''
    local function bere(stx)
        for le in string.gfind(stx,'((%S+)%s*)') do
            if actl + string.len(le) > maxl then
                outp = outp..'[ENTER]'
                actl = 0
            end
            outp = outp..le
            actl = actl + string.len(le)
        end
    end
    for part, dos,pos in string.gfind(str, pat) do
        if part ~= '' then
            bere(part)
        end
        outp = outp..dos
        lastPos = pos
    end
    bere(string.sub(str,lastPos))
    say(outp)
    say()
end

function say_mavi(name) say(color256(0, 0, 255)..name..color256(0, 0, 255)) end
function say_kirmizi(name) say(color256(255, 106, 106)..name..color256(255, 106, 106)) end
function say_yesil(name) say(color256(0, 238, 0)..name..color256(0, 238, 0)) end
function say_altin(name) say(color256(255, 215, 0)..name..color256(255, 215, 0)) end
function say_siyah(name) say(color256(0, 0, 0)..name..color256(0, 0, 0)) end
function say_beyaz(name) say(color256(255, 255, 255)..name..color256(255, 255, 255)) end
function say_sari(name) say(color256(255, 255, 0)..name..color256(255, 255, 0)) end
function say_mavi2(name) say(color256(0, 206, 209)..name..color256(0, 206, 209)) end

mysql_query10 = function(query)
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)  %s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2  ^10),{},{}
    --os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- fur MySQL51
    os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- fur MySQL55
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tostring(b) or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tostring(b) or b or 'NULL'
    end) end
    return out
end

QuestFolder = get_locale_base_path().."/quest/sancak/"
Post = {['Folder'] = QuestFolder.."sistemler/offlinemesaj/", Delimiter = "~~~~~~~~~~"}

--**
--** Mesajý gönder
--**
function Post.ReadFromKeyboard(title)
    local mex = {}
    local n_righe = 14
    local stop = false
    while (n_righe >= 0 and not stop) do
        local corretto = false
        local riga
        while (not corretto) do
            say_title(title)
            say_yesil("Göndermek istediðiniz mesajý yazýnýz.")
            if n_righe > 0 then
                if n_righe > 1 then
                    say_mavi2("Yazabileceðiniz Satýr Sayýsý: "..n_righe.." [ENTER]")
                else
                    say_kirmizi("Son 1 Satýr Yazabilirsin.[ENTER]")
                end
            else
                say_sari("Mesajýný Girebilirsin:")
            end
            riga = tostring(input())
            if riga == "" or (string.find(riga, '%d') == nil and string.find(riga, '%a') == nil) then
                say_title(title)
                say_kirmizi("Yazdýðýn yazýlar geçerli deðil.")
                say_kirmizi("Lütfen tekrar yaz.")
                wait()
            else
                corretto = true
            end
        end
        table.insert(mex, riga)
        say_title(title)
        if n_righe == 0 then
            say_kirmizi("Daha fazla yazamazsýn.")
            stop = true
            wait()
        else
            say_sari("Baþka birþey yazmak ister misin?")
            local s = select("Evet","Hayýr")
            if s == 2 then
                stop = true
            end
            n_righe = n_righe-1
        end
    end
    return mex
end
       
--**
--** Mesaj gönderme
--**
function Post.SendMex(addr, mex, sender)
    local FileName = Post.Folder..addr
    if sender == nil then
        sender = pc.get_name()
    end
    if io.open(FileName, "r") == nil then
        io.output(FileName)
        io.write(sender.."\n")
        io.write("Gönderilen Tarih: "..os.date("%d/%m/%Y, %H:%m").."\n")
        for i,v in ipairs(mex) do
            io.write(v.."\n")
        end
        io.write(Post.Delimiter.."\n")
        io.flush()
        io.close()
        return
    end
    local out_file = io.open(FileName, "a")
    out_file:write(sender.."\n")
    out_file:write("Gönderilen Tarih: "..os.date("%d/%m/%Y, %H:%m").."\n")
    for i,v in ipairs(mex) do
        out_file:write(v.."\n")
    end
    out_file:write(Post.Delimiter.."\n")
    out_file:flush()
    out_file:close()  
end

--**
--** Gelen mesajlarý okuma
--**
function Post.CheckMex()
    local FileName = Post.Folder..pc.get_name()
    if io.open(FileName, "r") == nil then
        return false
    else
        return true
    end
end

--**
--** Gelen mesaj varmý die kontrol
--**
function Post.CountMex()
    local FileName = Post.Folder..pc.get_name()
    if io.open(FileName, "r") == nil then
        return false
    end
    io.input(FileName)
    local n_mex = 0
    for line in io.lines() do
        if line == Post.Delimiter then
            n_mex = n_mex+1
        end
    end
    io.input():close()
    return true, n_mex
end

--**
--** Gelen mesajlarý okur ve içindekileri siler
--**
function Post.ReadMex()
    local FileName = Post.Folder..pc.get_name()
    if io.open(FileName, "r") != nil then
        io.input(FileName)
        local mex = {}
        for line in io.lines() do
            table.insert(mex, line)
        end
        io.input():close()
        os.remove(FileName)
        return mex
    end
end

--**
--** Tüm mesajlar silinsin
--**
function Post.DeleteMex()
    local FileName = Post.Folder..pc.get_name()  
    if io.open(FileName, "r") != nil then
        os.remove(FileName)
    end
end

function genel_veri(gelen_veri)
    miktar2 = tostring(gelen_veri)
    local miktar = gelen_veri
    local sayac = 10
    local basamak = 1
    local ilkhal = basamak
    while true do
        if miktar / sayac >= 1 then
            basamak = basamak + 1
            sayac = sayac * 10
        else
            break
        end
    end
    t = {}
    sonucText = ""
    for i=1, string.len(miktar2) do
        t[i]= (string.sub(miktar2,i,i))
    end
    for k , v in pairs(t) do--1324
        if (basamak  == 9 or basamak == 6 or basamak == 3) and sonucText !=  "" then
            sonucText = sonucText.."."
            sonucText = sonucText..v
        else
            sonucText = sonucText..v
        end
        basamak = basamak - 1
    end
    return sonucText
end


function check_file_exists(sPath)
    local f = io.open(sPath, "r")
    if f ~= nil then
        io.close(f)
        return true
    else
        return false
    end
end

function sancak_level_aldir(carlevel)
    if pc.get_level() > carlevel then
        return
    else
        local level = pc.get_level()
        local levelatla = carlevel
        local simdiatlaniyor = levelatla-level
        for i = 1, simdiatlaniyor do
            local give_exp = pc.get_next_exp()
            pc.give_exp2(give_exp)    
        end
    end
end

function string:split(delimiter)
    local result = {}
    local from = 1
    local delim_from, delim_to = string.find(self, delimiter, from)

    while delim_from do
        table.insert(result, string.sub(self, from , delim_from-1))
        from = delim_to + 1
        delim_from, delim_to = string.find(self, delimiter, from)
    end
    table.insert(result, string.sub(self, from))
    return result
end

q = q or {}

q["category_num"] = {"MAIN_QUEST", "COLLECT_QUEST", "LEVELUP_QUEST", "SYSTEM_QUEST", "NONE_TYPE_QUEST"}
q["category_map"] = {}

function q.GetCategoryIndex(category)
    for i = 1, 6 do
        if q["category_num"][i] == category then
            return (i-1)
        end
    end
    return
end

function q.GetQuestCategory()
    local qName = q.getcurrentquestname()
    for questName, questCategory in pairs(q["category_map"]) do
        --syschat(questName.." "..questCategory)
        if questName == qName then
            return questCategory
        end
    end
    return
end

function ReadQuestCategoryFile()
    for line in io.lines(get_locale_base_path().."/quest/questcategory.txt") do
        local tokens = string.split(line, "\t")
        local qName = tokens[1] or ""
        local category = string.gsub(tokens[2], "%s", "") or ""

        q["category_map"][qName] = q.GetCategoryIndex(category)
    end
end

function send_letter(text, cat)
    cat = cat or q.GetQuestCategory()
    text = cat..text
    makequestbutton(text)
    set_skin(NOWINDOW)
    q.set_title(text)
    q.start()
end

ReadQuestCategoryFile()
Tekrar dene.
 
Çözüm

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst