Помогите с Lua (выравнивание текста)

Dima_CODEX32

Новичок
Автор темы
9
0
Есть скрипт, который отображает на экране онлайн банд\мафий в игре. Мне нужно чтобы можно было выбрать по какой стороне выравнивался текст скрипта. По стандарту он выравнивается только по левой (с лево на право) стороне, а мне нужно наоборот, чтобы он выравнивался по правой. К данной теме будет приложен сам скрипт. Буду очень благодарен если кто-то поможет!
Lua:
require "lib.sampfuncs"
require "lib.moonloader"
local inicfg = require 'inicfg'
local lanes = require("lanes").configure()
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

    function main()
        while not isSampAvailable() do
            wait(1000)
        end
        start = true
        if not doesDirectoryExist("moonloader/config") then    createDirectory("moonloader/config") end
        Data = inicfg.load({
            Main = {
                Time = 10,
                fontName = "Tahoma",
                fontSize = 12,
                fontFlags = 5,
                FirstColor = 0xFFFFFF,
                SecondColor = 0x00B4FF,
                PosX = 5,
                PosY = 200,
                gap = 10,
            },
            Frac = {
                elc = true,
                gsf = true,
                bls = true,
                lsv = true,
                lcn = true,
                ykz = true,
                rm = true,
                sfr = true,
                bk = true,
                sr = true,
                ttm = true,
                ha = true,
                ls = true,
                lv = true,
                fbi = true,
                emt = true,
                ka = false,
                tax = false,
                rep = false,
                grj = false,
            },
        }, "CheckerOnline")
        url = 'http://galaxy-rpg.ru/players'
        inicfg.save(Data, "CheckerOnline")
        Font = renderCreateFont(Data.Main.fontName, Data.Main.fontSize, Data.Main.fontFlags)
        sampRegisterChatCommand("online", onl)
        Dialog = lua_thread.create_suspended(DialogFunc)
        Timer = lua_thread.create_suspended(TimerFunc)
        Stream = lua_thread.create(StreamFunc)
        elc, gsf, bls, lsv, lcn, ykz, rm, sfr, bk, sr, ttm, ha, ls, lv, fbi, na, emt, ka, tax, rep, grj = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        elcs, gsfs, blss, lsvs, lcns, ykzs, rms, sfrs, bks, srs, ttms, has, lss, lvs, fbis, nas, emts, kas, taxs, reps, grjs = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        time = os.date("%H:%M:%S")
        align = 1
        while sampServerFunc() do
            wait(0)
            if start then
                start = false
                obnovlenie()
            end
                m = 0
                String0 = string.format("{FFFFFF} ")
                String1 = string.format("{FFFFFF}", time)
                renderFontDrawText(Font, String0, Data.Main.PosX, Data.Main.PosY-Data.Main.gap*1, 0xFFFFFFFF)
                renderFontDrawText(Font, String1, Data.Main.PosX, Data.Main.PosY, 0xFFFFFFFF)
                if Data.Frac.elc then
                    m = m + 1
                    String2 = string.format("{0FD9FA}ELC - %d/%d", elc, elcs)
                    renderFontDrawText(Font, String2, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.gsf then
                    m = m + 1
                    String3 = string.format("{10DC29}GRV - %d/%d", gsf, gsfs)
                    renderFontDrawText(Font, String3, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.bls then
                    m = m + 1
                    String4 = string.format("{8A2CD7}BLS - %d/%d", bls, blss)
                    renderFontDrawText(Font, String4, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.lsv then
                    m = m + 1
                    String5 = string.format("{FFD720}LSV - %d/%d", lsv, lsvs)
                    renderFontDrawText(Font, String5, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.lcn then
                    m = m + 1
                    String6 = string.format("{057F94}LCN - %d/%d", lcn, lcns)
                    renderFontDrawText(Font, String6, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ykz then
                    m = m + 1
                    String7 = string.format("{FAFB71}YKZ - %d/%d", ykz, ykzs)
                    renderFontDrawText(Font, String7, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.rm then
                    m = m + 1
                    String8 = string.format("{778899}RM - %d/%d", rm, rms)
                    renderFontDrawText(Font, String8, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.sfr then
                    m = m + 1
                    String9 = string.format("{20D4AD}SFR - %d/%d", sfr, sfrs)
                    renderFontDrawText(Font, String9, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.bk then
                    m = m + 1
                    String10 = string.format("{4C436E}BK - %d/%d", bk, bks)
                    renderFontDrawText(Font, String10, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.sr then
                    m = m + 1
                    String11 = string.format("{6495ED}SR - %d/%d", sr, srs)
                    renderFontDrawText(Font, String11, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ttm then
                    m = m + 1
                    String12 = string.format("{FA24CC}TTM - %d/%d", ttm, ttms)
                    renderFontDrawText(Font, String12, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ha then
                    m = m + 1
                    String13 = string.format("{70524D}HA - %d/%d", ha, has)
                    renderFontDrawText(Font, String13, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ls then
                    m = m + 1
                    String14 = string.format("{1A30BF}LSPD - %d/%d", ls, lss)
                    renderFontDrawText(Font, String14, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.lv then
                    m = m + 1
                    String15 = string.format("{6152C2}LVPD - %d/%d", lv, lvs)
                    renderFontDrawText(Font, String15, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.fbi then
                    m = m + 1
                    String16 = string.format("{0000A0}FBI - %d/%d", fbi, fbis)
                    renderFontDrawText(Font, String16, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.na then
                    m = m + 1
                    String17 = string.format("{247C1B}ARMA - %d/%d", na, nas)
                    renderFontDrawText(Font, String17, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.emt then
                    m = m + 1
                    String18 = string.format("{DC143C}EMT - %d/%d", emt, emts)
                    renderFontDrawText(Font, String18, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ka then
                    m = m + 1
                    String19 = string.format("{E59338}АДВ - %d/%d", ka, kas)
                    renderFontDrawText(Font, String19, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.tax then
                    m = m + 1
                    String20 = string.format("{A55043}ТАКС - %d/%d", tax, taxs)
                    renderFontDrawText(Font, String20, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.rep then
                    m = m + 1
                    String21 = string.format("{C1F7EC}РЕП - %d/%d", rep, reps)
                renderFontDrawText(Font, String21, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
            end
            if Data.Frac.grj then
                m = m + 1
                String22 = string.format("{FFFFFF}ГРЖД - %d/%d", grj, grjs)
                renderFontDrawText(Font, String22, Data.Main.PosX, Data.Main.PosY+Data.Main.gap*m, 0xFFFFFFFF)
            end
        end
    end
   
    function obnovlenie()
      async_http_request('GET', 'http://www.galaxy-rpg.ru/players', nil --[[параметры запроса]],
      function(response) -- вызовется при успешном выполнении и получении ответа
        text = u8:decode(response.text)
        text = text:match("tab%-group%-2(.-)server%-2%-tab")
        elc, gsf, bls, lsv, lcn, ykz, rm, sfr, bk, sr, ttm, ha, ls, lv, fbi, na, emt, ka, tax, rep, grj = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        for stroka in string.gmatch(text, '[^\r\n]+') do
            if string.find(stroka, "El Coronos") then elc = elc + 1
            elseif string.find(stroka, "The Grove Street") then gsf = gsf + 1
            elseif string.find(stroka, "The Ballas Gang") then bls = bls + 1
            elseif string.find(stroka, "Los Santos Vagos") then lsv = lsv + 1
            elseif string.find(stroka, "La Cosa Nostra") then lcn = lcn + 1
            elseif string.find(stroka, "Yakuza") then ykz = ykz + 1
            elseif string.find(stroka, "Русская Мафия") then rm = rm + 1
            elseif string.find(stroka, "San Fierro Rifa") then sfr = sfr + 1
            elseif string.find(stroka, "Black Kings") then bk = bk + 1
            elseif string.find(stroka, "Street Racers") then sr = sr + 1
            elseif string.find(stroka, "The Triads Mafia") then ttm = ttm + 1
            elseif string.find(stroka, "Hell Angels") then ha = ha + 1
            elseif string.find(stroka, "Полиция LS") then ls = ls + 1
            elseif string.find(stroka, "Полиция LV") then lv = lv + 1
            elseif string.find(stroka, "ФБР") then fbi = fbi + 1
            elseif string.find(stroka, "Армия") then na = na + 1
            elseif string.find(stroka, "EMT") then emt = emt + 1
            elseif string.find(stroka, "Коллегия адвокатов") then ka = ka + 1
            elseif string.find(stroka, "Таксопарк") then tax = tax + 1
            elseif string.find(stroka, "San News") then rep = rep + 1
            elseif string.find(stroka, "Гражданский") then grj = grj + 1
            end
        end
        time = os.date("%H:%M:%S")
        Timer:run(Data.Main.Time*60)
      end,
      function(err) -- вызовется при ошибке, err - текст ошибки. эту функцию можно не указывать
        sampAddChatMessage("Ошибка в обновлении онлайна", -1)
        sampAddChatMessage(err, -1)
        Timer:run(60)
      end)
    end
   
    function TimerFunc(timeLeft)
        if timeLeft and timeLeft > 0 then
            local timeNow = os.time()
            local timeEnd = timeNow + timeLeft
            local timeNowD = timeNow + 1
            while timeLeft > 0 do
                wait(0)
                timeNow = os.time()
                timeLeft = timeEnd - timeNow
                if timeNow >= timeNowD then
                    timeNowD = os.time() + 1
                end
            end
            start = true
        end
    end
   
    function sampServerFunc()
        local ip, port = sampGetCurrentServerAddress()
        local serverIpString = string.format("%s:%d", ip, port)
        if serverIpString == "176.32.39.200:7777" then
            return true
        elseif serverIpString == "176.32.39.199:7777" then
            return true
        elseif serverIpString == "176.32.39.198:7777" then
            return true
        else
            return false
        end
    end
   
    function StreamFunc()
        while true do
            wait(0)
            elcs, gsfs, blss, lsvs, lcns, ykzs, rms, sfrs, bks, srs, ttms, has, lss, lvs, fbis, nas, emts, kas, taxs, reps, grjs = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            for k, PED in pairs(getAllChars()) do
                local res, id = sampGetPlayerIdByCharHandle(PED)
                if res then
                    if isCharModel(PED, 114) or isCharModel(PED, 47) or isCharModel(PED, 115) or isCharModel(PED, 116) or isCharModel(PED, 292) or isCharModel(PED, 298) then elcs = elcs + 1 --elc
                    elseif isCharModel(PED, 86) or isCharModel(PED, 105) or isCharModel(PED, 106) or isCharModel(PED, 107) or isCharModel(PED, 195) or isCharModel(PED, 195) or isCharModel(PED, 269) or isCharModel(PED, 270) or isCharModel(PED, 271) then gsfs = gsfs + 1 --gsf
                    elseif isCharModel(PED, 13) or isCharModel(PED, 28) or isCharModel(PED, 102) or isCharModel(PED, 103) or isCharModel(PED, 104) then blss = blss + 1  --bls
                    elseif isCharModel(PED, 12) or isCharModel(PED, 108) or isCharModel(PED, 109) or isCharModel(PED, 110) or isCharModel(PED, 273) then lsvs = lsvs +1  --lsv
                    elseif isCharModel(PED, 46) or isCharModel(PED, 98) or isCharModel(PED, 113) or isCharModel(PED, 124) or isCharModel(PED, 126) or isCharModel(PED, 223) or isCharModel(PED, 233) then lcns = lcns + 1 --lcn
                    elseif isCharModel(PED, 120) or isCharModel(PED, 121) or isCharModel(PED, 122) or isCharModel(PED, 123) or isCharModel(PED, 169) or isCharModel(PED, 186) or isCharModel(PED, 228) then ykzs = ykzs + 1 --ykz
                    elseif isCharModel(PED, 3) or isCharModel(PED, 111) or isCharModel(PED, 112) or isCharModel(PED, 125) or isCharModel(PED, 206) or isCharModel(PED, 216) or isCharModel(PED, 272) then rms = rms + 1 --rm
                    elseif isCharModel(PED, 30) or isCharModel(PED, 40) or isCharModel(PED, 173) or isCharModel(PED, 174) or isCharModel(PED, 175) or isCharModel(PED, 184) then sfrs = sfrs + 1 --sfr
                    elseif isCharModel(PED, 24) or isCharModel(PED, 25) or isCharModel(PED, 66) or isCharModel(PED, 67) or isCharModel(PED, 190) or isCharModel(PED, 297) or isCharModel(PED, 183) then bks = bks + 1 --bk
                    elseif isCharModel(PED, 21) or isCharModel(PED, 48) or isCharModel(PED, 60) or isCharModel(PED, 180) or isCharModel(PED, 193) or isCharModel(PED, 250) or isCharModel(PED, 299) then srs = srs + 1 --sr
                    elseif isCharModel(PED, 117) or isCharModel(PED, 118) or isCharModel(PED, 141) or isCharModel(PED, 170) or isCharModel(PED, 208) or isCharModel(PED, 294) then ttms = ttms + 1 --ttm
                    elseif isCharModel(PED, 100) or isCharModel(PED, 192) or isCharModel(PED, 247) or isCharModel(PED, 248) or isCharModel(PED, 254) then has = has + 1 --ha
                    elseif isCharModel(PED, 280) or isCharModel(PED, 282) or isCharModel(PED, 284) or isCharModel(PED, 283) or isCharModel(PED, 267) or isCharModel(PED, 266) or isCharModel(PED, 265) then
                    lss = lss + 1 --lspd, lvpd
                    lvs = lvs + 1
                    elseif isCharModel(PED, 306) then lss = lss + 1
                    elseif isCharModel(PED, 309) then lvs = lvs + 1
                    elseif isCharModel(PED, 191) or isCharModel(PED, 287) then nas = nas + 1 --na
                    elseif isCharModel(PED, 285) or isCharModel(PED, 286) or isCharModel(PED, 163) or isCharModel(PED, 164) or isCharModel(PED, 211) then fbis = fbis + 1 -- fbi
                    elseif isCharModel(PED, 70) or isCharModel(PED, 156) or isCharModel(PED, 275) or isCharModel(PED, 276) or isCharModel(PED, 274) or isCharModel(PED, 308) then emts = emts + 1 --emt
                    elseif isCharModel(PED, 171) or isCharModel(PED, 189) or isCharModel(PED, 20) or isCharModel(PED, 59) or isCharModel(PED, 217) or isCharModel(PED, 240) or isCharModel(PED, 194) then kas = kas + 1 --ka
                    elseif isCharModel(PED, 261) or isCharModel(PED, 262) or isCharModel(PED, 253) or isCharModel(PED, 255) or isCharModel(PED, 61) or isCharModel(PED, 172) then taxs = taxs + 1 --tax
                    elseif isCharModel(PED, 187) or isCharModel(PED, 188) or isCharModel(PED, 290) or isCharModel(PED, 295) or isCharModel(PED, 150) then reps = reps + 1 --rep
                    else grjs = grjs + 1
                    end
                end
            end
        end
    end
   
    function onl()
        Dialog:run()
    end
   
    function DialogFunc()
        ::Main::
        DialogText = string.format("{F6DB6A}Автообновление раз в {FFFFFF}%d{F6DB6A} минут\t\n{F6DB6A}Расстояние между строками в чекере:\t{FFFFFF}%d\n{F6DB6A}{F6DB6A}Изменить положение чекера на экране\t{FFFFFF}X: %d Y: %d\n{F6DB6A}Изменить отображаемые фракции\n{F6DB6A}Настройки шрифта", Data.Main.Time, Data.Main.gap, Data.Main.PosX, Data.Main.PosY)
        dialogId = 999
        dialogButton = nil
        dialogListItem = nil
        dialogInput = nil
        dialogBool = false
        sampShowDialog(dialogId, string.format("{FFFFFF}CheckerOnline{00B4FF}"), DialogText, "Выбрать", "Закрыть", 4)
        while not dialogBool do
            wait(0)
            dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
        end
        if dialogButton ~= 0 then
            if dialogListItem == 0 then
                ::SetTime::
                local DialogText = string.format("{F6DB6A}Введите время, через которое онлайн будет обновляться.\n\n{F6DB6A}Установленное значение: {FFFFFF}%d", Data.Main.Time)
                dialogId = 1000
                dialogButton = nil
                dialogListItem = nil
                dialogInput = nil
                dialogBool = false
                sampShowDialog(dialogId, "{FFFFFF}Изменение времени обновления" , DialogText, "Применить", "Назад", 1)
                while not dialogBool do
                    wait(0)
                    dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                end
                if dialogButton ~= 0 then
                    if dialogInput ~= nil and #dialogInput > 0 and string.find(dialogInput, "%d+") then
                    dialogInput = tonumber(string.match(dialogInput, "^%D*(%d+)%D*"))
                        Data.Main.Time = dialogInput
                        inicfg.save(Data, "CheckerOnline")
                        goto SetTime
                    else
                        sampAddChatMessage("/* {FF5555}CheckerOnline {00B4FF}*/ {FFFFFF}Введите конкретное время в минутах.", -1)
                        goto SetTime
                    end
                else
                    goto Main
                end
            elseif dialogListItem == 1 then
                ::Setgap::
                local DialogText = string.format("{F6DB6A}Введите расстояние, между строками.\n\n{F6DB6A}Установленное значение: {FFFFFF}%d", Data.Main.gap)
                dialogId = 1001
                dialogButton = nil
                dialogListItem = nil
                dialogInput = nil
                dialogBool = false
                sampShowDialog(dialogId, "{FFFFFF}Изменение расстояния" , DialogText, "Применить", "Назад", 1)
                while not dialogBool do
                    wait(0)
                    dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                end
                if dialogButton ~= 0 then
                    if dialogInput ~= nil and #dialogInput > 0 and string.find(dialogInput, "%d+") then
                    dialogInput = tonumber(string.match(dialogInput, "^%D*(%d+)%D*"))
                        Data.Main.gap = dialogInput
                        inicfg.save(Data, "CheckerOnline")
                        goto Setgap
                    else
                        sampAddChatMessage("/* {FF5555}CheckerOnline {00B4FF}*/ {FFFFFF}Введите конкретное значение расстояния.", -1)
                        goto Setgap
                    end
                else
                    goto Main
                end
            elseif dialogListItem == 2 then
                sampSetCursorMode(4)
                wait(150)
                while not sampIsChatInputActive() and not sampIsDialogActive() do
                    wait(0)
                    m = 0
                    local cursorPosX, cursorPosY = getCursorPos()
                    local StringTest0 = string.format("{FFFFFF}ПОСЛЕДНЕЕ ОБНОВЛЕНИЕ:")
                    local StringTest1 = string.format("{FFFFFF}[00:00:00]")
                renderFontDrawText(Font, StringTest0, cursorPosX, cursorPosY-Data.Main.gap, 0xFFFFFFFF)
                renderFontDrawText(Font, StringTest1, cursorPosX, cursorPosY, 0xFFFFFFFF)
                if Data.Frac.elc then
                    m = m + 1
                    local StringTest2 = string.format("{0FD9FA}EL CORONOS - 0/0")
                    renderFontDrawText(Font, StringTest2, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.gsf then
                    m = m + 1
                    local StringTest3 = string.format("{10DC29}THE GROVE STREET - 0/0")
                    renderFontDrawText(Font, StringTest3, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.bls then
                    m = m + 1
                    local StringTest4 = string.format("{8A2CD7}THE BALLAS GANG - 0/0")
                    renderFontDrawText(Font, StringTest4, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.lsv then
                    m = m + 1
                    local StringTest5 = string.format("{FFD720}LOS SANTOS VAGOS - 0/0")
                    renderFontDrawText(Font, StringTest5, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.lcn then
                    m = m + 1
                    local StringTest6 = string.format("{057F94}LA COSA NOSTRA - 0/0")
                    renderFontDrawText(Font, StringTest6, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ykz then
                    m = m + 1
                    local StringTest7 = string.format("{FAFB71}YAKUZA MAFIA - 0/0")
                    renderFontDrawText(Font, StringTest7, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.rm then
                    m = m + 1
                    local StringTest8 = string.format("{778899}РУССКАЯ МАФИЯ - 0/0")
                    renderFontDrawText(Font, StringTest8, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.sfr then
                    m = m + 1
                    local StringTest9 = string.format("{20D4AD}SAN FIERRO RIFA - 0/0")
                    renderFontDrawText(Font, StringTest9, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.bk then
                    m = m + 1
                    local StringTest10 = string.format("{4C436E}BLACK KINGS - 0/0")
                    renderFontDrawText(Font, StringTest10, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.sr then
                    m = m + 1
                    local StringTest11 = string.format("{6495ED}STREET RACERS - 0/0")
                    renderFontDrawText(Font, StringTest11, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ttm then
                    m = m + 1
                    local StringTest12 = string.format("{FA24CC}THE TRIADS MAFIA - 0/0")
                    renderFontDrawText(Font, StringTest12, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ha then
                    m = m + 1
                    local StringTest13 = string.format("{70524D}HELL ANGELS - 0/0")
                    renderFontDrawText(Font, StringTest13, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ls then
                    m = m + 1
                    local StringTest14 = string.format("{1A30BF}LSPD - 0/0")
                    renderFontDrawText(Font, StringTest14, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.lv then
                    m = m + 1
                    local StringTest15 = string.format("{6152C2}LVPD - 0/0")
                    renderFontDrawText(Font, StringTest15, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.fbi then
                    m = m + 1
                    local StringTest16 = string.format("{0000A0}FBI - 0/0")
                    renderFontDrawText(Font, StringTest16, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.na then
                    m = m + 1
                    local StringTest17 = string.format("{247C1B}NATIONAL GUARD - 0/0")
                    renderFontDrawText(Font, StringTest17, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.emt then
                    m = m + 1
                    local StringTest18 = string.format("{DC143C}EMT - 0/0")
                    renderFontDrawText(Font, StringTest18, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.ka then
                    m = m + 1
                    local StringTest19 = string.format("{E59338}АДВОКАТОВ - 0/0")
                    renderFontDrawText(Font, StringTest19, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.tax then
                    m = m + 1
                    local StringTest20 = string.format("{A55043}ТАКСИСТОВ - 0/0")
                    renderFontDrawText(Font, StringTest20, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.rep then
                    m = m + 1
                    local StringTest21 = string.format("{C1F7EC}РЕПОРТЕРОВ - 0/0")
                    renderFontDrawText(Font, StringTest21, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                if Data.Frac.grj then
                    m = m + 1
                    local StringTest22 = string.format("{FFFFFF}ГРАЖДАНСКИХ - 0/0")
                    renderFontDrawText(Font, StringTest22, cursorPosX, cursorPosY+Data.Main.gap*m, 0xFFFFFFFF)
                end
                    if isKeyJustPressed(0x01) then
                        Data.Main.PosX, Data.Main.PosY = cursorPosX, cursorPosY
                        inicfg.save(Data, "CheckerOnline")
                        while isKeyDown(0x01) do wait(0) end
                        sampSetCursorMode(0)
                        goto Main
                    elseif isKeyJustPressed(0x1B) then
                        sampSetCursorMode(0)
                        goto Main
                    end
                end
            elseif dialogListItem == 3 then
                ::Fract::
                if Data.Frac.elc then boolelc = "{55FF55}Активировано" else boolelc = "{FF5555}Деактивировано" end
                if Data.Frac.gsf then boolgsf = "{55FF55}Активировано" else boolgsf = "{FF5555}Деактивировано" end
                if Data.Frac.bls then boolbls = "{55FF55}Активировано" else boolbls = "{FF5555}Деактивировано" end
                if Data.Frac.lsv then boollsv = "{55FF55}Активировано" else boollsv = "{FF5555}Деактивировано" end
                if Data.Frac.lcn then boollcn = "{55FF55}Активировано" else boollcn = "{FF5555}Деактивировано" end
                if Data.Frac.ykz then boolykz = "{55FF55}Активировано" else boolykz = "{FF5555}Деактивировано" end
                if Data.Frac.rm then boolrm = "{55FF55}Активировано" else boolrm = "{FF5555}Деактивировано" end
                if Data.Frac.sfr then boolsfr = "{55FF55}Активировано" else boolsfr = "{FF5555}Деактивировано" end
                if Data.Frac.bk then boolbk = "{55FF55}Активировано" else boolbk = "{FF5555}Деактивировано" end
                if Data.Frac.sr then boolsr = "{55FF55}Активировано" else boolsr = "{FF5555}Деактивировано" end
                if Data.Frac.ttm then boolttm = "{55FF55}Активировано" else boolttm = "{FF5555}Деактивировано" end
                if Data.Frac.ha then boolha = "{55FF55}Активировано" else boolha = "{FF5555}Деактивировано" end
                if Data.Frac.ls then boolls = "{55FF55}Активировано" else boolls = "{FF5555}Деактивировано" end
                if Data.Frac.lv then boollv = "{55FF55}Активировано" else boollv = "{FF5555}Деактивировано" end
                if Data.Frac.na then boolna = "{55FF55}Активировано" else boolna = "{FF5555}Деактивировано" end
                if Data.Frac.fbi then boolfbi = "{55FF55}Активировано" else boolfbi = "{FF5555}Деактивировано" end
                if Data.Frac.emt then boolemt = "{55FF55}Активировано" else boolemt = "{FF5555}Деактивировано" end
                if Data.Frac.ka then boolka = "{55FF55}Активировано" else boolka = "{FF5555}Деактивировано" end
                if Data.Frac.tax then booltax = "{55FF55}Активировано" else booltax = "{FF5555}Деактивировано" end
                if Data.Frac.rep then boolrep = "{55FF55}Активировано" else boolrep = "{FF5555}Деактивировано" end
                if Data.Frac.grj then boolgrj = "{55FF55}Активировано" else boolgrj = "{FF5555}Деактивировано" end
                local DialogText = string.format("{0FD9FA}El Coronos\t%s\n{10DC29}Grove Street Family\t%s\n{8A2CD7}The Ballas Gang\t%s\n{FFD720}Los Santos Vagos\t%s\n{057F94}La Cosa Nostra\t%s\n{FAFB71}Yakuza Mafia\t%s\n{778899}Русская мафия\t%s\n{20D4AD}San Fierro Rifa\t%s\n{4C436E}Black Kings\t%s\n{6495ED}Street Racers\t%s\n{FA24CC}The Triads Mafia\t%s\n{70524D}Hell Angels\t%s\n{1A30BF}LSPD\t%s\n{6152C2}LVPD\t%s\n{247C1B}Армия\t%s\n{0000A0}FBI\t%s\n{DC143C}EMT\t%s\n{E59338}Адвокаты\t%s\n{A55043}Таксисты\t%s\n{C1F7EC}Репортеры\t%s\n{FFFFFF}Гражданские\t%s\n", boolelc, boolgsf, boolbls, boollsv, boollcn, boolykz, boolrm, boolsfr, boolbk, boolsr, boolttm, boolha, boolls, boollv, boolna, boolfbi, boolemt, boolka, booltax, boolrep, boolgrj)
                dialogId = 1002
                dialogButton = nil
                dialogListItem = nil
                dialogInput = nil
                dialogBool = false
                sampShowDialog(dialogId, "{FFFFFF}Отображаемые фракции" , DialogText, "Выбрать", "Назад", 4)
                while not dialogBool do
                    wait(0)
                    dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                end
                if dialogButton ~= 0 then
                    if dialogListItem == 0 then
                        if Data.Frac.elc then Data.Frac.elc = false else Data.Frac.elc = true end
                        goto Fract
                    elseif dialogListItem == 1 then
                        if Data.Frac.gsf then Data.Frac.gsf = false else Data.Frac.gsf = true end
                        goto Fract
                    elseif dialogListItem == 2 then
                        if Data.Frac.bls then Data.Frac.bls = false else Data.Frac.bls = true end
                        goto Fract
                    elseif dialogListItem == 3 then
                        if Data.Frac.lsv then Data.Frac.lsv = false else Data.Frac.lsv = true end
                        goto Fract
                    elseif dialogListItem == 4 then
                        if Data.Frac.lcn then Data.Frac.lcn = false else Data.Frac.lcn = true end
                        goto Fract
                    elseif dialogListItem == 5 then
                        if Data.Frac.ykz then Data.Frac.ykz = false else Data.Frac.ykz = true end
                        goto Fract
                    elseif dialogListItem == 6 then
                        if Data.Frac.rm then Data.Frac.rm = false else Data.Frac.rm = true end
                        goto Fract
                    elseif dialogListItem == 7 then
                        if Data.Frac.sfr then Data.Frac.sfr = false else Data.Frac.sfr = true end
                        goto Fract
                    elseif dialogListItem == 8 then
                        if Data.Frac.bk then Data.Frac.bk = false else Data.Frac.bk = true end
                        goto Fract
                    elseif dialogListItem == 9 then
                        if Data.Frac.sr then Data.Frac.sr = false else Data.Frac.sr = true end
                        goto Fract
                    elseif dialogListItem == 10 then
                        if Data.Frac.ttm then Data.Frac.ttm = false else Data.Frac.ttm = true end
                        goto Fract
                    elseif dialogListItem == 11 then
                        if Data.Frac.ha then Data.Frac.ha = false else Data.Frac.ha = true end
                        goto Fract
                    elseif dialogListItem == 12 then
                        if Data.Frac.ls then Data.Frac.ls = false else Data.Frac.ls = true end
                        goto Fract
                    elseif dialogListItem == 13 then
                        if Data.Frac.lv then Data.Frac.lv = false else Data.Frac.lv = true end
                        goto Fract
                    elseif dialogListItem == 14 then
                        if Data.Frac.na then Data.Frac.na = false else Data.Frac.na = true end
                        goto Fract
                    elseif dialogListItem == 15 then
                        if Data.Frac.fbi then Data.Frac.fbi = false else Data.Frac.fbi = true end
                        goto Fract
                    elseif dialogListItem == 16 then
                        if Data.Frac.emt then Data.Frac.emt = false else Data.Frac.emt = true end
                        goto Fract
                    elseif dialogListItem == 17 then
                        if Data.Frac.ka then Data.Frac.ka = false else Data.Frac.ka = true end
                        goto Fract
                    elseif dialogListItem == 18 then
                        if Data.Frac.tax then Data.Frac.tax = false else Data.Frac.tax = true end
                        goto Fract
                    elseif dialogListItem == 19 then
                        if Data.Frac.rep then Data.Frac.rep = false else Data.Frac.rep = true end
                        goto Fract
                    elseif dialogListItem == 20 then
                        if Data.Frac.grj then Data.Frac.grj = false else Data.Frac.grj = true end
                        goto Fract
                    end
                else
                    goto Main
                end
            elseif dialogListItem == 4 then
                ::FontSet::
                local DialogText = string.format("{F6DB6A}Изменить название шрифта\t'%s'\n{F6DB6A}Изменить размер шрифта\tSize: %d\n{F6DB6A}Изменить cтиль шрифта\t{FFFFFF}Flags: %d", Data.Main.fontName, Data.Main.fontSize, Data.Main.fontFlags)
                dialogId = 1003
                dialogButton = nil
                dialogListItem = nil
                dialogInput = nil
                dialogBool = false
                sampShowDialog(dialogId, "{FFFFFF}Настройки шрифта" , DialogText, "Выбрать", "Назад", 4)
                while not dialogBool do
                    wait(0)
                    dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                end
                if dialogButton ~= 0 then
                    if dialogListItem == 0 then
                        ::FontSetName::
                        local DialogText = string.format("{F6DB6A}Введите название шрифа целиком.\n{F6DB6A}Например: Comic Sans MS, Arial Black, Tahoma\n\n{F6DB6A}Установленное значение: {FFFFFF}%s", Data.Main.fontName)
                        dialogId = 1004
                        dialogButton = nil
                        dialogListItem = nil
                        dialogInput = nil
                        dialogBool = false
                        sampShowDialog(dialogId, "{FFFFFF}Изменение названия шрифта" , DialogText, "Применить", "Назад", 1)
                        sampSetCurrentDialogEditboxText(Data.Main.fontName)
                        while not dialogBool do
                            wait(0)
                            dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                        end
                        if dialogButton ~= 0 then
                            if dialogInput ~= nil and #dialogInput > 0 and string.find(dialogInput, "%S+") then
                                dialogInput = string.match(dialogInput, "^%s*(.-)%s*$")
                                Data.Main.fontName = tostring(dialogInput)
                                inicfg.save(Data, "CapinfoCheck")
                                renderReleaseFont(Font)
                                Font = renderCreateFont(Data.Main.fontName, Data.Main.fontSize, Data.Main.fontFlags)
                                goto FontSetName
                            else
                                sampAddChatMessage(string.format("/* {FF5555}CheckerOnline {00B4FF}*/ {FFFFFF}Введите название шрифта."), -1)
                                goto FontSetName
                            end
                        else
                            goto FontSet
                        end
                    elseif dialogListItem == 1 then
                        ::FontSetSize::
                        local DialogText = string.format("{F6DB6A}Введите размер шрифта от 1 до 55.\n\n{F6DB6A}Установленное значение: {FFFFFF}%d", Data.Main.fontSize)
                        dialogId = 1005
                        dialogButton = nil
                        dialogListItem = nil
                        dialogInput = nil
                        dialogBool = false
                        sampShowDialog(dialogId, "{FFFFFF}Изменение размер шрифта" , DialogText, "Применить", "Назад", 1)
                        while not dialogBool do
                            wait(0)
                            dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                        end
                        if dialogButton ~= 0 then
                            if dialogInput ~= nil and #dialogInput > 0 and string.find(dialogInput, "%d+") then
                                dialogInput = tonumber(string.match(dialogInput, "^%D*(%d+)%D*"))
                                if dialogInput >= 1 and dialogInput <= 55 then
                                    Data.Main.fontSize = dialogInput
                                    inicfg.save(Data, "CapinfoCheck")
                                    renderReleaseFont(Font)
                                    Font = renderCreateFont(Data.Main.fontName, Data.Main.fontSize, Data.Main.fontFlags)
                                else
                                    sampAddChatMessage(string.format("/* {FF5555}CheckerOnline {00B4FF}*/ {FFFFFF}Введите размер шрифта от 1 до 55."), -1)
                                end
                                goto FontSetSize
                            else
                                sampAddChatMessage(string.format("/* {FF5555}CheckerOnline {00B4FF}*/ {FFFFFF}Введите размер шрифта от 1 до 55."), -1)
                                goto FontSetSize
                            end
                        else
                            goto FontSet
                        end
                    elseif dialogListItem == 2 then
                        ::FontSetFlags::
                        local fontFlagsSet = Data.Main.fontFlags
                        if fontFlagsSet == 0 then
                            FCR_NONE, FCR_NONEclr = 1, 0xF6DB6A
                        else
                            FCR_NONE, FCR_NONEclr = 0, 0xBFC0C2
                        end
                        if fontFlagsSet >= 32 then
                            FCR_STRIKEOUT, FCR_STRIKEOUTclr = 1, 0xF6DB6A
                            fontFlagsSet = fontFlagsSet - 32
                        else
                            FCR_STRIKEOUT, FCR_STRIKEOUTclr = 0, 0xBFC0C2
                        end
                        if fontFlagsSet >= 16 then
                            FCR_UNDERLINE, FCR_UNDERLINEclr = 1, 0xF6DB6A
                            fontFlagsSet = fontFlagsSet - 16
                        else
                            FCR_UNDERLINE, FCR_UNDERLINEclr = 0, 0xBFC0C2
                        end
                        if fontFlagsSet >= 8 then
                            FCR_SHADOW, FCR_SHADOWclr = 1, 0xF6DB6A
                            fontFlagsSet = fontFlagsSet - 8
                        else
                            FCR_SHADOW, FCR_SHADOWclr = 0, 0xBFC0C2
                        end
                        if fontFlagsSet >= 4 then
                            FCR_BORDER, FCR_BORDERclr = 1, 0xF6DB6A
                            fontFlagsSet = fontFlagsSet - 4
                        else
                            FCR_BORDER, FCR_BORDERclr = 0, 0xBFC0C2
                        end
                        if fontFlagsSet >= 2 then
                            FCR_ITALICS, FCR_ITALICSclr = 1, 0xF6DB6A
                            fontFlagsSet = fontFlagsSet - 2
                        else
                            FCR_ITALICS, FCR_ITALICSclr = 0, 0xBFC0C2
                        end
                        if fontFlagsSet == 1 then
                            FCR_BOLD, FCR_BOLDclr = 1, 0xF6DB6A
                            fontFlagsSet = fontFlagsSet - 1
                        else
                            FCR_BOLD, FCR_BOLDclr = 0, 0xBFC0C2
                        end
                        local DialogText = string.format("{%06X}Без особенностей\n{%06X}Жирный\n{%06X}Наклонный\n{%06X}Обводка\n{%06X}Тень\n{%06X}Подчеркнутый\n{%06X}Зачеркнутый", FCR_NONEclr, FCR_BOLDclr, FCR_ITALICSclr, FCR_BORDERclr, FCR_SHADOWclr, FCR_UNDERLINEclr, FCR_STRIKEOUTclr)
                        dialogId = 1106
                        dialogButton = nil
                        dialogListItem = nil
                        dialogBool = false
                        dialogInput = nil
                        sampShowDialog(dialogId, "{FFFFFF}Изменение стиля шрифта" , DialogText, "Выбрать", "Назад", 2)
                        while not dialogBool do
                            wait(0)
                            dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
                        end
                        if dialogButton ~= 0 then
                            if dialogListItem == 0 then
                                Data.Main.fontFlags = 0
                            elseif dialogListItem == 1 then
                                if FCR_BOLD == 1 then
                                    Data.Main.fontFlags = Data.Main.fontFlags - 1
                                else
                                    Data.Main.fontFlags = Data.Main.fontFlags + 1
                                end
                            elseif dialogListItem == 2 then
                                if FCR_ITALICS == 1 then
                                    Data.Main.fontFlags = Data.Main.fontFlags - 2
                                else
                                    Data.Main.fontFlags = Data.Main.fontFlags + 2
                                end
                            elseif dialogListItem == 3 then
                                if FCR_BORDER == 1 then
                                    Data.Main.fontFlags = Data.Main.fontFlags - 4
                                else
                                    Data.Main.fontFlags = Data.Main.fontFlags + 4
                                end
                            elseif dialogListItem == 4 then
                                if FCR_SHADOW == 1 then
                                    Data.Main.fontFlags = Data.Main.fontFlags - 8
                                else
                                    Data.Main.fontFlags = Data.Main.fontFlags + 8
                                end
                            elseif dialogListItem == 5 then
                                if FCR_UNDERLINE == 1 then
                                    Data.Main.fontFlags = Data.Main.fontFlags - 16
                                else
                                    Data.Main.fontFlags = Data.Main.fontFlags + 16
                                end
                            elseif dialogListItem == 6 then
                                if FCR_STRIKEOUT == 1 then
                                    Data.Main.fontFlags = Data.Main.fontFlags - 32
                                else
                                    Data.Main.fontFlags = Data.Main.fontFlags + 32
                                end
                            end
                            inicfg.save(Data, "CapinfoCheck")
                            renderReleaseFont(Font)
                            Font = renderCreateFont(Data.Main.fontName, Data.Main.fontSize, Data.Main.fontFlags)
                            goto FontSetFlags
                        else
                            goto FontSet
                        end
                    end
                else
                    goto Main
                end
            end
        end
    end
   
    function async_http_request(method, url, args, resolve, reject)
        if not _G["lanes.async_http"] then
            local linda = lanes.linda()
            local lane_gen = lanes.gen("*", {package = {path = package.path, cpath = package.cpath}}, function()
                local requests = require("requests")
                while true do
                    local key, val = linda:receive(50 / 1000, "request")
                    if key == "request" then
                        local ok, result = pcall(requests.request, val.method, val.url, val.args)
                        if ok then
                            result.json, result.xml = nil, nil
                            linda:send("response", result)
                        else linda:send("error", result) end
                    end
                end
            end)
            _G["lanes.async_http"] = {lane = lane_gen(), linda = linda}
        end
        local lanes_http = _G["lanes.async_http"]
        lanes_http.linda:send("request", {method = method, url = url, args = args})
        lua_thread.create(function(linda)
            while true do
                local key, val = linda:receive(0, "response", "error")
                if key == "response" then return resolve(val)
                elseif key == "error" then return reject(val) end
                wait(0)
            end
        end, lanes_http.linda)
    end
   
    function urlencode(str)
       if (str) then
          str = string.gsub (str, "\n", "\r\n")
          str = string.gsub (str, "([^%w ])",
             function (c) return string.format ("%%%02X", string.byte(c)) end)
          str = string.gsub (str, " ", "+")
       end
       return str
    end
 

Вложения

  • CheckerOnline.lua
    36.2 KB · Просмотры: 15
Последнее редактирование:

Petr_Sergeevich

Известный
Проверенный
707
296
imgui.SetCursorPos(imgui.ImVec2(x, y))
Ничего, что тут нет imgui? А скрипт просто пиздец, если честно..
Вот функция для выравнивания текста, используй её.
Lua:
function renderFontDrawTextAlign(font, text, x, y, color, align)
    if not align or align == 1 then -- слева
        renderFontDrawText(font, text, x, y, color)
    end

    if align == 2 then -- по центру
        renderFontDrawText(font, text, x - renderGetFontDrawTextLength(font, text) / 2, y, color)
    end

    if align == 3 then -- справа
        renderFontDrawText(font, text, x - renderGetFontDrawTextLength(font, text), y, color)
    end
end
 

Dima_CODEX32

Новичок
Автор темы
9
0
Ничего, что тут нет imgui? А скрипт просто пиздец, если честно..
Вот функция для выравнивания текста, используй её.
Lua:
function renderFontDrawTextAlign(font, text, x, y, color, align)
    if not align or align == 1 then -- слева
        renderFontDrawText(font, text, x, y, color)
    end

    if align == 2 then -- по центру
        renderFontDrawText(font, text, x - renderGetFontDrawTextLength(font, text) / 2, y, color)
    end

    if align == 3 then -- справа
        renderFontDrawText(font, text, x - renderGetFontDrawTextLength(font, text), y, color)
    end
end
Спасибо за помощь, но еще не все. Я не очень хорошо разбираюсь в Lua, не мог бы ты меня ткнуть носом, куда именно нужно это вставлять?
Скрипт писал не я, но как работает меня устраивает, кроме одного - выравнивание текста.

Вот как скрипт отображается на экране, мне нужно чтобы текст выравнивался по правой стороне.
Кликабельно
sa-mp-040.png
 
Последнее редактирование: