how can i get the extra_strings array to be added to the complete array when needed and used in order left to right or right to left

bool LOBBY_MAPS_EXTRA = false;
bool LOBBY_DPAD_CYCLE = false;



const char* stringsM[] = {
    "mplobby_01", "mp_arena", "mp_bac_01", "mp_bac_03", "mp_bac_042", "mp_balance", "mp_bor_01", "mp_bor_02", "mp_bor_03",
    "mp_coop_delivery", "mp_coop_gauntlet", "mp_coop_gauntlet_minimap", "mp_coop_gauntlet_mm", "mp_ptp_01", "mp_ptp_02",
    "mp_ptp_02_minimap01", "mp_ptp_02_mm", "mp_ptp_03"
};
const int stringsMSize = sizeof(stringsM) / sizeof(stringsM[0]);

const char* extra_strings[] = {
    "mp_brothel", "mp_brothl2", "mp_churchh", "mp_crashld", "mp_crib", "mp_crib001", "mp_demoder",
    "mp_kingrec", "mp_legal", "mp_legale2", "mp_legalee", "mp_methlab", "mp_movieth", "mp_nighcl2", "mp_nighcl3",
    "mp_nightcl", "mp_parking", "mp_pricemn", "mp_snatch", "mp_stripc2", "mp_teashop", "mp_thebar", "mp_thebar2", "mp_yacht"
};

const int extra_stringsSize = sizeof(extra_strings) / sizeof(extra_strings[0]);

int currentIndex = 0;

here are my global variables

const char* moveLeft(const char* strings[], int& currentIndex, int size) {
    currentIndex = (currentIndex - 1 + size) % size;
    return strings[currentIndex];
}

const char* moveRight(const char* strings[], int& currentIndex, int size) {
    currentIndex = (currentIndex + 1) % size;
    return strings[currentIndex];
}

here are my functions for moving left or right

void updateStrings(bool LOBBY_MAPS_EXTRA) {
    static const int maxStrings = stringsMSize + extra_stringsSize;
    static const int finalStringsSize = LOBBY_MAPS_EXTRA ? maxStrings : stringsMSize;
    static const char** finalStrings = new const char*[finalStringsSize];

    if (LOBBY_MAPS_EXTRA) {
        // Copy both arrays into the finalStrings array
        std::copy(stringsM, stringsM + stringsMSize, finalStrings);
        std::copy(extra_strings, extra_strings + extra_stringsSize, finalStrings + stringsMSize);
        
        // Update currentIndex if it's out of bounds
        if (currentIndex >= finalStringsSize) {
            currentIndex = 0; // Reset currentIndex to the beginning
        }
    } else {
        // Copy only the stringsM array into the finalStrings array
        std::copy(stringsM, stringsM + stringsMSize, finalStrings);
        
        // Update currentIndex if it's out of bounds
        if (currentIndex >= stringsMSize) {
            currentIndex = 0; // Reset currentIndex to the beginning
        }
    }
}

here is my function to update the strings when LOBBY_MAPS_EXTRA is true or false




void MonitorKeysWithXInput() {
    DWORD dwResult;
    XINPUT_STATE state;

    // Loop indefinitely to monitor XInput state changes
    while (true) {
        auto toggleBool = [](bool& value) { value = !value; };
        // Get the state of the controller
        dwResult = XInputGetState(0, &state);

        if (dwResult == ERROR_SUCCESS) {
[7:04 PM]
if ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)) {
    if (LOBBY_DPAD_CYCLE) {
        // Move to the next string index
        int newIndex = (currentIndex + 1) % stringsMSize;
        
        // Update the memory address only if the new index is within bounds
        if (newIndex < stringsMSize) {
            // Memory address to replace
            char* addressToReplace = reinterpret_cast<char*>(0x82069194);
            const char* newString = moveRight(stringsM, currentIndex, stringsMSize);
            std::strcpy(addressToReplace, newString);
            
            // Determine the length of the final string
            size_t length = strlen("subtitle_add "lobby set: "") 
                            + strlen(addressToReplace) 
                            + 1 // For the terminating null character
                            + 2; // For the extra quotes and space
            

            
            // Clean up dynamically allocated memory
            delete[] command;
        } else {
            std::cout << "Reached end of strings array!" << std::endl;
        }
    }
}
if ((state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)) {
    if (LOBBY_DPAD_CYCLE) {
        // Move to the previous string index
        int newIndex = (currentIndex - 1 + stringsMSize) % stringsMSize;
        
        // Update the memory address only if the new index is within bounds
        if (newIndex >= 0) {
            // Memory address to replace
            char* addressToReplace = reinterpret_cast<char*>(0x82069194);
            const char* newString = moveLeft(stringsM, currentIndex, stringsMSize);
            std::strcpy(addressToReplace, newString);
            
            // Determine the length of the final string
            size_t length = strlen("subtitle_add "lobby set: "") 
                            + strlen(addressToReplace) 
                            + 1 // For the terminating null character
                            + 2; // For the extra quotes and space
            
            // Clean up dynamically allocated memory
            delete[] command;
        } else {
            std::cout << "Reached beginning of strings array!" << std::endl;
        }
    }
}
        }
        else {
            // The controller is not connected or an error occurred
            std::cout << "Controller not connected or an error occurred!" << std::endl;

            // Sleep for a short duration before trying again
            Sleep(1000);
        }
    }
}

here is the function scanning for buttons on a xbox controller

please note that this is for c++ version 14

for some reason it is only going through the first string, even if LOBBY_MAPS_EXTRA is true

I have tried many variations of this code and it only goes through StringsM

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật