local hook = require 'lib.samp.events'
local inicfg = require 'inicfg'
require 'lib.moonloader'
function main()
while not isSampAvailable() do wait(0) end
if not doesDirectoryExist("moonloader/config") then createDirectory("moonloader/config") end
Data = inicfg.load({
Settings = {
DisplayToggle = true,
BezOtkataDisplayToggle = true,
ChatMessage = true,
Audio = true,
fontName = "sansation",
fontSize = 10,
fontFlags = 4,
FirstColor = 0xFFFFFF,
SecondColor = 0x00B4FF,
PosX = 5,
PosY = 400,
inicfg.save(Data, "mgtData")
Font = renderCreateFont(Data.Settings.fontName, Data.Settings.fontSize, Data.Settings.fontFlags)
Timer = lua_thread.create_suspended(TimerFunc)
Dialog = lua_thread.create_suspended(DialogFunc)
sound = lua_thread.create_suspended(soundFunc)
sampRegisterChatCommand("/mg", mgtCMD)
while not sampIsLocalPlayerSpawned() do wait(0) end
timeLeftM = timeLeftFunc()
Timer:run(timeLeftM)
wait(-1)
function soundFunc()
clearMissionAudio(1)
loadMissionAudio(1, 43001)
wait(100)
playMissionAudio(1)
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
if Data.Settings.DisplayToggle and sampIsChatVisible() and not sampIsScoreboardOpen() then
local timeSeconds = timeLeft % 60
local timeMinutes = ((timeLeft - timeSeconds) % 3600) / 60
local timeHours = (timeLeft - (timeSeconds + (timeMinutes * 60))) / 3600
timerString = string.format("{%06X}/materials get {%06X}|{%06X} %02d{%06X}:{%06X}%02d{%06X}:{%06X}%02d", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor, timeHours, Data.Settings.SecondColor, Data.Settings.FirstColor, timeMinutes, Data.Settings.SecondColor, Data.Settings.FirstColor, timeSeconds)
renderFontDrawText(Font, timerString, Data.Settings.PosX, Data.Settings.PosY, 0xFFFFFFFF)
if Data.Settings.ChatMessage then
sampAddChatMessage(string.format("/* {%06X}weirdclvn {%06X}*/ {%06X}Откат на /materials get прошел.", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor), Data.Settings.SecondColor)
end
if Data.Settings.Audio then
sound:run()
end
end
while true do
wait(0)
if Data.Settings.BezOtkataDisplayToggle and sampIsChatVisible() and not sampIsScoreboardOpen() then
timerString = string.format("{%06X}/materials get {%06X}|{%06X} Нет отката", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor)
renderFontDrawText(Font, timerString, Data.Settings.PosX, Data.Settings.PosY, 0xFFFFFFFF)
end
end
end
if then
if string.find(text, "^Ты получил 1500 материалов с 30 пакетов. Всего материалов:.") then
timeLeftS = 100
function mgtCMD()
Dialog:run()
end
end
if Data.Settings.DisplayToggle then DisplayToggleString = "{55FF55}Активировано" else DisplayToggleString = "{FF5555}Деактивировано" end
if Data.Settings.BezOtkataDisplayToggle then BezOtkataDisplayToggleString = "{55FF55}Активировано" else BezOtkataDisplayToggleString = "{FF5555}Деактивировано" end
if Data.Settings.ChatMessage then ChatMessageToggleString = "{55FF55}Активировано" else ChatMessageToggleString = "{FF5555}Деактивировано" end
if Data.Settings.Audio then AudioToggleString = "{55FF55}Активировано" else AudioToggleString = "{FF5555}Деактивировано" end
local DialogText = string.format("%s\n{F6DB6A}Отображение таймера отката на экране\t%s\n{F6DB6A}Отображение строки {FFFFFF}'Нет отката' {F6DB6A}на экране\t%s\n{F6DB6A}Сообщение в чат при окончании отката\t%s\n{F6DB6A}Звуковое сообщение при окончании отката\t%s\n{F6DB6A}Изменить положение таймера на экране\t{FFFFFF}X: %d Y: %d\n{F6DB6A}Настройки цвета\t{%06X}Цвет #1 {FFFFFF}| {%06X}Цвет #2\n{F6DB6A}Настроики шрифта", timeLeftString, DisplayToggleString, BezOtkataDisplayToggleString, ChatMessageToggleString, AudioToggleString, Data.Settings.PosX, Data.Settings.PosY, Data.Settings.FirstColor, Data.Settings.SecondColor)
dialogId = 1100
dialogButton = nil
dialogListItem = nil
dialogInput = nil
dialogBool = false
sampShowDialog(dialogId, string.format("{FFFFFF}/materials get timer {00B4FF}by {FF5555}Chaos.") , DialogText, "Выбрать", "Закрыть", 4)
while not dialogBool do
wait(0)
dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
end
if dialogButton ~= 0 then
if dialogListItem == 0 then
goto Main
elseif dialogListItem == 1 then
if Data.Settings.DisplayToggle then Data.Settings.DisplayToggle = false else Data.Settings.DisplayToggle = true end
inicfg.save(Data, "mgtData")
goto Main
elseif dialogListItem == 2 then
if Data.Settings.BezOtkataDisplayToggle then Data.Settings.BezOtkataDisplayToggle = false else Data.Settings.BezOtkataDisplayToggle = true end
inicfg.save(Data, "mgtData")
goto Main
elseif dialogListItem == 3 then
if Data.Settings.ChatMessage then Data.Settings.ChatMessage = false else Data.Settings.ChatMessage = true end
inicfg.save(Data, "mgtData")
goto Main
elseif dialogListItem == 4 then
if Data.Settings.Audio then Data.Settings.Audio = false else
Data.Settings.Audio = true
sound:run()
end
inicfg.save(Data, "mgtData")
goto Main
elseif dialogListItem == 5 then
sampSetCursorMode(4)
while not sampIsChatInputActive() and not sampIsDialogActive() do
wait(0)
local cursorPosX, cursorPosY = getCursorPos()
local timerStringTest = string.format("{%06X}/materials get {%06X}|{%06X} %%d{%06X}:{%06X}%%d{%06X}:{%06X}%%d", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor)
renderFontDrawText(Font, timerStringTest, cursorPosX, cursorPosY, 0xFFFFFFFF)
if isKeyJustPressed(0x01) then
Data.Settings.PosX, Data.Settings.PosY = cursorPosX, cursorPosY
inicfg.save(Data, "mgtData")
while isKeyDown(0x01) do wait(0) end
sampSetCursorMode(0)
goto Main
elseif isKeyJustPressed(0x1B) then
sampSetCursorMode(0)
goto Main
end
end
elseif dialogListItem == 6 then
::ColorSet::
local DialogText = string.format("{F6DB6A}Изменить Цвет #1\t{%06X}hex: %06X\n{F6DB6A}Изменить Цвет #2\t{%06X}hex: %06X", Data.Settings.FirstColor, Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.SecondColor)
dialogId = 1105
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
::FirstColorSet::
local DialogText = string.format("{F6DB6A}Введите Цвет #1 в формате {FFFFFF}RRGGBB\n{F6DB6A}Например: F6DB6A, 00FF00 или FFFFFF\n\n{F6DB6A}Установленное значение: {%06X}%06X", Data.Settings.FirstColor, Data.Settings.FirstColor)
dialogId = 1106
dialogButton = nil
dialogListItem = nil
dialogInput = nil
dialogBool = false
sampShowDialog(dialogId, "{FFFFFF}Изменение Цвета #1" , DialogText, "Применить", "Назад", 1)
sampSetCurrentDialogEditboxText(tostring(string.format("%06X", Data.Settings.FirstColor)))
while not dialogBool do
wait(0)
dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
end
if dialogButton ~= 0 then
if string.find(tostring(dialogInput), "^[0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF]$") and tonumber(string.format("0x%s", tostring(dialogInput))) >= 0x0 and tonumber(string.format("0x%s", tostring(dialogInput))) <= 0xFFFFFF then
Data.Settings.FirstColor = tonumber(string.format("0x%s", tostring(dialogInput)))
inicfg.save(Data, "mgtData")
goto FirstColorSet
else
sampAddChatMessage(string.format("/* {%06X}weirdclvn {%06X}*/ {%06X}Введите корректное значение.", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor), Data.Settings.SecondColor)
goto FirstColorSet
end
else
goto ColorSet
end
elseif dialogListItem == 1 then
::SecondColorSet::
local DialogText = string.format("{F6DB6A}Введите Цвет #2 в формате {FFFFFF}RRGGBB\n{F6DB6A}Например: F6DB6A, 00FF00 или FFFFFF\n\n{F6DB6A}Установленное значение: {%06X}%06X", Data.Settings.SecondColor, Data.Settings.SecondColor)
dialogId = 1107
dialogButton = nil
dialogListItem = nil
dialogInput = nil
dialogBool = false
sampShowDialog(dialogId, "{FFFFFF}Изменение Цвета #2" , DialogText, "Применить", "Назад", 1)
sampSetCurrentDialogEditboxText(tostring(string.format("%06X", Data.Settings.SecondColor)))
while not dialogBool do
wait(0)
dialogBool, dialogButton, dialogListItem, dialogInput = sampHasDialogRespond(dialogId)
end
if dialogButton ~= 0 then
if string.find(tostring(dialogInput), "^[0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF][0-9abcdefABCDEF]$") and tonumber(string.format("0x%s", tostring(dialogInput))) >= 0x0 and tonumber(string.format("0x%s", tostring(dialogInput))) <= 0xFFFFFF then
Data.Settings.SecondColor = tonumber(string.format("0x%s", tostring(dialogInput)))
inicfg.save(Data, "RobTimerData")
goto SecondColorSet
else
sampAddChatMessage(string.format("/* {%06X}weirdclvn {%06X}*/ {%06X}Введите корректное значение.", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor), Data.Settings.SecondColor)
goto SecondColorSet
end
else
goto ColorSet
end
end
else
goto Main
end
elseif dialogListItem == 7 then
::FontSet::
local DialogText = string.format("{F6DB6A}Изменить название шрифта\t'%s'\n{F6DB6A}Изменить размер шрифта\tSize: %d\n{F6DB6A}Изменить cтиль шрифта\t{FFFFFF}Flags: %d", Data.Settings.fontName, Data.Settings.fontSize, Data.Settings.fontFlags)
dialogId = 1101
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.Settings.fontName)
dialogId = 1102
dialogButton = nil
dialogListItem = nil
dialogInput = nil
dialogBool = false
sampShowDialog(dialogId, "{FFFFFF}Изменение названия шрифта" , DialogText, "Применить", "Назад", 1)
sampSetCurrentDialogEditboxText(Data.Settings.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.Settings.fontName = tostring(dialogInput)
inicfg.save(Data, "mgtData")
renderReleaseFont(Font)
Font = renderCreateFont(Data.Settings.fontName, Data.Settings.fontSize, Data.Settings.fontFlags)
goto FontSetName
else
sampAddChatMessage(string.format("/* {%06X}weirdclvn {%06X}*/ {%06X}Введите название шрифта.", Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor), Data.Settings.SecondColor)
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.Settings.fontSize)
dialogId = 1103
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.Settings.fontSize = dialogInput
inicfg.save(Data, "mgtData")
renderReleaseFont(Font)
Font = renderCreateFont(Data.Settings.fontName, Data.Settings.fontSize, Data.Settings.fontFlags)
else
sampAddChatMessage(string.format("/* {%06X}weirdclvn {%06X}*/ {%06X}Введите размер шрифта от 1 до 55.",Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor), Data.Settings.SecondColor)
end
goto FontSetSize
else
sampAddChatMessage(string.format("/* {%06X}weirdclvn {%06X}*/ {%06X}Введите размер шрифта от 1 до 55.",Data.Settings.FirstColor, Data.Settings.SecondColor, Data.Settings.FirstColor), Data.Settings.SecondColor)
goto FontSetSize
end
else
goto FontSet
end
elseif dialogListItem == 2 then
::FontSetFlags::
local fontFlagsSet = Data.Settings.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 = 1104
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.Settings.fontFlags = 0
elseif dialogListItem == 1 then
if FCR_BOLD == 1 then
Data.Settings.fontFlags = Data.Settings.fontFlags - 1
else
Data.Settings.fontFlags = Data.Settings.fontFlags + 1
end
elseif dialogListItem == 2 then
if FCR_ITALICS == 1 then
Data.Settings.fontFlags = Data.Settings.fontFlags - 2
else
Data.Settings.fontFlags = Data.Settings.fontFlags + 2
end
elseif dialogListItem == 3 then
if FCR_BORDER == 1 then
Data.Settings.fontFlags = Data.Settings.fontFlags - 4
else
Data.Settings.fontFlags = Data.Settings.fontFlags + 4
end
elseif dialogListItem == 4 then
if FCR_SHADOW == 1 then
Data.Settings.fontFlags = Data.Settings.fontFlags - 8
else
Data.Settings.fontFlags = Data.Settings.fontFlags + 8
end
elseif dialogListItem == 5 then
if FCR_UNDERLINE == 1 then
Data.Settings.fontFlags = Data.Settings.fontFlags - 16
else
Data.Settings.fontFlags = Data.Settings.fontFlags + 16
end
elseif dialogListItem == 6 then
if FCR_STRIKEOUT == 1 then
Data.Settings.fontFlags = Data.Settings.fontFlags - 32
else
Data.Settings.fontFlags = Data.Settings.fontFlags + 32
end
end
inicfg.save(Data, "mgtData")
renderReleaseFont(Font)
Font = renderCreateFont(Data.Settings.fontName, Data.Settings.fontSize, Data.Settings.fontFlags)
goto FontSetFlags
else
goto FontSet
end
end
else
goto Main
end
end
end
end
end