Сократить

accord-

Потрачен
Автор темы
436
79
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Версия MoonLoader
.026-beta
Можно ли как-то это сократить?
Lua:
        elseif windows == 4 then
            if imgui.Button(u8"LSPD", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 1')
            end   

            if imgui.Button(u8"RCPD", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 2')
            end   
            
            if imgui.Button(u8"FBI", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 3')
            end   
            
            if imgui.Button(u8"SFPD", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 4')
            end   
            
            if imgui.Button(u8"Больница ЛС", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 5')
            end   
            
            if imgui.Button(u8"Правительство", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 6')
            end   
            
            if imgui.Button(u8"Больница СФ", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 8')
            end   
            
            if imgui.Button(u8"Лицензеры", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 9')
            end   
            if imgui.Button(u8"Радио ЛС", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 10')
            end   
            
            if imgui.Button(u8"Грув", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 11')
            end   
            
            if imgui.Button(u8"Вагос", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 12')
            end   
            
            if imgui.Button(u8"Баллас", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 13')
            end   
            
            if imgui.Button(u8"Ацтек", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 14')
            end   
            
            if imgui.Button(u8"Рифа", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 15')
            end   
            
            if imgui.Button(u8"Русская Мафия", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 16')
            end   
            
            if imgui.Button(u8"Якудза", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 17')
            end   
            
            if imgui.Button(u8"ЛКН", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 18')
            end   
            
            if imgui.Button(u8"Варлок", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 19')
            end   
            if imgui.Button(u8"Армия ЛС", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 20')
            end   
            
            if imgui.Button(u8"Центральный Банк", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 21')
            end   
            
            if imgui.Button(u8"Больница ЛВ", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 22')
            end   
            
            if imgui.Button(u8"ЛВПД", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 23')
            end   
            
            if imgui.Button(u8"Радио ЛВ", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 24')
            end   
            
            if imgui.Button(u8"Ночные Волки", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 25')
            end   
            
            if imgui.Button(u8"Радио СФ", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 26')
            end   
            
            if imgui.Button(u8"Армия СФ", imgui.ImVec2(550,20)) then
                sampSendChat('/amember 27')
            end
 
Решение
Lua:
local Buttons =
{
    'LSPD',
    'RCPD',
    'FBI',
    'SFPD',
    'Больница ЛС',
    'Правительство',
    'Больница СФ',
    'Лицензеры',
    'Радио ЛС',
    'Грув',
    'Вагос',
    'Баллас',
    'Ацтек',
    'Рифа',
    'Русская мафия',
    'Якудза',
    'ЛКН',
    'Варлок',
    'Армия ЛС',
    'Центральный Банк',
    'Больница ЛВ',
    'ЛВПД',
    'Радио ЛВ',
    'Ночные Волки',
    'Радио СФ',
    'Армия СФ'
}

elseif windows == 4 then
    for Key, Value in ipairs(Buttons) do
        if imgui.Button(u8(Value), imgui.ImVec2(550,20)) then
            if Key >=7 then sampSendChat('/amember '..Key+1)
            else sampSendChat('/amember '..Key)
            end
        end
    end
end

Manuel Leon

Известный
266
170
Lua:
local Buttons =
{
    'LSPD',
    'RCPD',
    'FBI',
    'SFPD',
    'Больница ЛС',
    'Правительство',
    'Больница СФ',
    'Лицензеры',
    'Радио ЛС',
    'Грув',
    'Вагос',
    'Баллас',
    'Ацтек',
    'Рифа',
    'Русская мафия',
    'Якудза',
    'ЛКН',
    'Варлок',
    'Армия ЛС',
    'Центральный Банк',
    'Больница ЛВ',
    'ЛВПД',
    'Радио ЛВ',
    'Ночные Волки',
    'Радио СФ',
    'Армия СФ'
}

elseif windows == 4 then
    for Key, Value in ipairs(Buttons) do
        if imgui.Button(u8(Value), imgui.ImVec2(550,20)) then
            if Key >=7 then sampSendChat('/amember '..Key+1)
            else sampSendChat('/amember '..Key)
            end
        end
    end
end
 
  • Нравится
Реакции: YarikVL