Kod Metin Bot Kontrol Sistemi - Stone Bot Control System Lua + C++

Erdem Çevrimdışı

Erdem

Fenomen Üye
Yönetici
KURUCU
11 Haz 2023
423
135
252
Bot kontrolun çalışma mantığı 30 metin kırdığınızda çarınız sersemler ve quest ekranı gelir orada captcha doğrulaması yapmanızı ister 3 hakkınız var 3 kere yanlış yaparsanız sizi köye ışınlar.

Kod:
quest anti_bot_captcha begin
    state start begin
        function setting()
            return
            {
                ["true_vnum"] = { 101129 , 9600 , 12829 , 2169 , 11839 , 12789 , 71107 , 79 , 2099 , 199 , 2159 , 3169 , 2139 , 5349 , 1139 , 101006 , 12809 , 7009 , 13109 , 7029 , 189 , 39 , 7019 , 29 , 101005 },
                ["fake_vnum1"] = { 11299 , 17229 , 7379 , 2079 , 101119 , 20509 , 2129 , 18089 , 11819 , 129 , 13089 , 89 , 69 , 11849 , 101141 , 469 , 12849 , 101004 , 16579 , 2069 , 101140 , 14579 , 169 , 2039 , 15459 },
                ["fake_vnum2"] = { 11899 , 2019 , 101144 , 11499 , 20259 , 3199 , 139 , 101109 , 7059 , 2109 , 13169 , 17709 , 14229 , 2059 , 7039 , 99 , 49 , 101143 , 13069 , 18099 , 11699 , 479 , 15449 , 179 , 2049 },
                ["fake_vnum3"] = { 5129 , 20009 , 59 , 2089 , 2379 , 9830 , 11829 , 20759 , 101142 , 119 , 2179 , 2009 , 2119 , 16229 , 11809 , 101139 , 19 , 2029 , 1349 , 11859 , 2179 , 13149 , 7049 , 13129 , 2149 },

                ["metin_limit"] = { 50 },
                ["failed_limit"] = { 3 },
            }
        end

        function block_player()
            pc.setqf("anti_bot_captcha_status", 1)

            pc.affect_stun()
        end

        function unblock_player()
            pc.setqf("anti_bot_captcha_status", 0)
            pc.setqf("anti_bot_captcha_metin_counter", 0)
            pc.setqf("anti_bot_captcha_failed_counter", 0)

            affect.remove(210)
        end

        function metin_register()
            pc.setqf("anti_bot_captcha_metin_counter", pc.getqf("anti_bot_captcha_metin_counter")+1)

            local metin_counter = pc.getqf("anti_bot_captcha_metin_counter")
            local captcha_status = pc.getqf("anti_bot_captcha_status")

            -- syschat(string.format("anti_bot_captcha_metin_counter: %d / anti_bot_captcha_status: %d", metin_counter, captcha_status))
        end

        function captcha_ok()
            anti_bot_captcha.unblock_player()
        end

        function captcha_failed()
            local setting = anti_bot_captcha.setting()


            pc.setqf("anti_bot_captcha_failed_counter", pc.getqf("anti_bot_captcha_failed_counter")+1)

            syschat(string.format("Wrong captcha! (You failed %d of %d attempts)", pc.getqf("anti_bot_captcha_failed_counter"), setting.failed_limit[1]))

            if pc.getqf("anti_bot_captcha_failed_counter") >= setting.failed_limit[1] then
                pc.setqf("anti_bot_captcha_failed_counter", 0)
                warp_to_village()
            end

            send_letter("Captcha")
        end

        function show_captcha()
            local setting = anti_bot_captcha.setting()

            local true_vnum_total = table.getn(setting.true_vnum) -- total of items in the table
            local random_true_vnum = number(1, true_vnum_total) -- random value
            local true_item = setting.true_vnum[random_true_vnum] -- random result

            local fake_vnum_total1 = table.getn(setting.fake_vnum1) -- total of items in the table
            local fake_vnum_total2 = table.getn(setting.fake_vnum2) -- total of items in the table
            local fake_vnum_total3 = table.getn(setting.fake_vnum3) -- total of items in the table

            local random_fake_vnum_1 = number(1, fake_vnum_total1) --- random value
            local fake_item1 = setting.fake_vnum1[random_fake_vnum_1] -- random result

            local random_fake_vnum_2 = number(1, fake_vnum_total2) --- random value
            local fake_item2 = setting.fake_vnum2[random_fake_vnum_2] -- random result

            local random_fake_vnum_3 = number(1, fake_vnum_total3) --- random value
            local fake_item3 = setting.fake_vnum3[fake_vnum_total3] -- random result

            local random_question = number(1, 4)

            if pc.getqf("anti_bot_captcha_status") == 0 then
                say_title("Captcha:")
                say("You have no pending verification.")
                return;
            end

            say("What is the name of this item?")
            say_item_vnum(true_item)
            say("[ENTER][ENTER]")

            if random_question == 1 then
                local menu = select(item_name(true_item), item_name(fake_item1), item_name(fake_item2), item_name(fake_item3))

                if menu == 1 then
                    anti_bot_captcha.captcha_ok()
                elseif menu == 2 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 3 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 4 then
                    anti_bot_captcha.captcha_failed()
                end

            elseif random_question == 2 then
                local menu = select(item_name(fake_item1), item_name(true_item), item_name(fake_item2), item_name(fake_item3))

                if menu == 1 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 2 then
                    anti_bot_captcha.captcha_ok()
                elseif menu == 3 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 4 then
                    anti_bot_captcha.captcha_failed()
                end

            elseif random_question == 3 then
                local menu = select(item_name(fake_item1), item_name(fake_item2), item_name(true_item), item_name(fake_item3))

                if menu == 1 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 2 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 3 then
                    anti_bot_captcha.captcha_ok()
                elseif menu == 4 then
                    anti_bot_captcha.captcha_failed()
                end

            elseif random_question == 4 then
                local menu = select(item_name(fake_item1), item_name(fake_item2), item_name(fake_item3), item_name(true_item))

                if menu == 1 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 2 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 3 then
                    anti_bot_captcha.captcha_failed()
                elseif menu == 4 then
                    anti_bot_captcha.captcha_ok()
                end
            end
        end

        when login or letter begin
            send_letter("Captcha")
        end

        when button or info begin
            anti_bot_captcha.show_captcha()
        end

        when kill with not npc.is_pc() and npc.is_metin() begin
            anti_bot_captcha.metin_register()

            local setting = anti_bot_captcha.setting()

            if pc.getqf("anti_bot_captcha_metin_counter") >= setting.metin_limit[1] then
                anti_bot_captcha.block_player()
                anti_bot_captcha.show_captcha()
            end
        end

    end
end

Kod:
// aç : questlua_pc.cpp

// dosya içinde bul void RegisterPCFunctionTable() üstüne ekle
    int pc_affect_stun(lua_State * L)
    {
        const uint32_t lDuration = 86400; // 24h in seconds
        const LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        if (ch)
            ch->AddAffect(AFFECT_STUN, POINT_NONE, 0, AFF_STUN, lDuration, 0, true);
        return 0;
    }
bul
{ NULL,            NULL            }
üstüne ekle
{ "affect_stun", pc_affect_stun },
 
resim

Benzer konular

resim
Geri
Üst