diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..80a4811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.lua working-tree-encoding=windows-1251 +changelog working-tree-encoding=windows-1251 \ No newline at end of file diff --git a/changelog b/changelog new file mode 100644 index 0000000..ff220c2 --- /dev/null +++ b/changelog @@ -0,0 +1,5 @@ +Версия от 23.01.2023 +Добавлено меню по команде /corn +Добавлена функция смены активации +Добавлен модуль автообновления +Исправлена работа на сервере Classic \ No newline at end of file diff --git a/corn-hud.lua b/corn-hud.lua index 751cf54..4db2373 100644 --- a/corn-hud.lua +++ b/corn-hud.lua @@ -116,14 +116,14 @@ function main() end if render then renderText = { - [1] = '{00D900} : '..ini.price.zerno..'$', - [2] = '{00D900} : '..ini.price.urojai..'$', + [1] = '{00D900}Цена покупки зерна: '..ini.price.zerno..'$', + [2] = '{00D900}Цена продажи урожая: '..ini.price.urojai..'$', [3] = '{00D900} ', - [4] = string.format('{00D900} 0 | : %d$ | : %d [%d$] | : %d [%d$]', ini['Farm 0'].bank, ini['Farm 0'].corn, ini['Farm 0'].cornPrice, ini['Farm 0'].product, ini['Farm 0'].productPrice), - [5] = string.format('{00D900} 1 | : %d$ | : %s [%s$] | : %s [%s$]', ini['Farm 1'].bank, ini['Farm 1'].corn, ini['Farm 1'].cornPrice, ini['Farm 1'].product, ini['Farm 1'].productPrice), - [6] = string.format('{00D900} 2 | : %d$ | : %s [%s$] | : %s [%s$]', ini['Farm 2'].bank, ini['Farm 2'].corn, ini['Farm 2'].cornPrice, ini['Farm 2'].product, ini['Farm 2'].productPrice), - [7] = string.format('{00D900} 3 | : %d$ | : %s [%s$] | : %s [%s$]', ini['Farm 3'].bank, ini['Farm 3'].corn, ini['Farm 3'].cornPrice, ini['Farm 3'].product, ini['Farm 3'].productPrice), - [8] = string.format('{00D900} 4 | : %d$ | : %s [%s$] | : %s [%s$]', ini['Farm 4'].bank, ini['Farm 4'].corn, ini['Farm 4'].cornPrice, ini['Farm 4'].product, ini['Farm 4'].productPrice), + [4] = string.format('{00D900}Ферма №0 | Баланс: %d$ | Зерно: %d [%d$] | Урожай: %d [%d$]', ini['Farm 0'].bank, ini['Farm 0'].corn, ini['Farm 0'].cornPrice, ini['Farm 0'].product, ini['Farm 0'].productPrice), + [5] = string.format('{00D900}Ферма №1 | Баланс: %d$ | Зерно: %s [%s$] | Урожай: %s [%s$]', ini['Farm 1'].bank, ini['Farm 1'].corn, ini['Farm 1'].cornPrice, ini['Farm 1'].product, ini['Farm 1'].productPrice), + [6] = string.format('{00D900}Ферма №2 | Баланс: %d$ | Зерно: %s [%s$] | Урожай: %s [%s$]', ini['Farm 2'].bank, ini['Farm 2'].corn, ini['Farm 2'].cornPrice, ini['Farm 2'].product, ini['Farm 2'].productPrice), + [7] = string.format('{00D900}Ферма №3 | Баланс: %d$ | Зерно: %s [%s$] | Урожай: %s [%s$]', ini['Farm 3'].bank, ini['Farm 3'].corn, ini['Farm 3'].cornPrice, ini['Farm 3'].product, ini['Farm 3'].productPrice), + [8] = string.format('{00D900}Ферма №4 | Баланс: %d$ | Зерно: %s [%s$] | Урожай: %s [%s$]', ini['Farm 4'].bank, ini['Farm 4'].corn, ini['Farm 4'].cornPrice, ini['Farm 4'].product, ini['Farm 4'].productPrice), } local X, Y = ini.Settings.X, ini.Settings.Y for i = 1, #renderText do @@ -144,10 +144,10 @@ function main() posY = ((posY / 2.2) - (renderGetFontDrawHeight(font) * 3)) renderText = { [1] = (render and 'Corn-HUD: ON' or 'Corn-HUD: OFF'), - [2] = '', - [3] = '', - [4] = ' ', - [5] = ' ' + [2] = 'Загрузить', + [3] = 'Разгрузить', + [4] = 'Информация о ферме', + [5] = 'Обновить информацию о ферме' } for i = 1, #renderText do if drawClickableText(renderText[i], posX - (renderGetFontDrawTextLength(font, renderText[i]) / 2), posY, 0xFF00D900, 0xFFFFFFFF) then @@ -201,37 +201,37 @@ function main() end function sampev.onServerMessage(color, message) - if message:find(' : (%d+) / 1500') then - zerno = tonumber(message:match(' : (%d+) / 1500')) + if message:find(' Зерно: (%d+) / 1500') then + zerno = tonumber(message:match(' Зерно: (%d+) / 1500')) end - if message:find(' : (%d+) / 1500') then - urojai = tonumber(message:match(' : (%d+) / 1500')) + if message:find(' Урожай: (%d+) / 1500') then + urojai = tonumber(message:match(' Урожай: (%d+) / 1500')) end - if message:find(' : (%d+) / 1500') then - narko = tonumber(message:match(' : (%d+) / 1500')) + if message:find(' Наркотики: (%d+) / 1500') then + narko = tonumber(message:match(' Наркотики: (%d+) / 1500')) end end function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text) - if text:find('{FF8000} .* (%d+) ') then - ini.price.narko = text:match('{FF8000} .* (%d+) ') + if text:find('{FF8000}Разгрузка наркотиков.*Стоимость наркотиков (%d+) вирт') then + ini.price.narko = text:match('{FF8000}Разгрузка наркотиков.*Стоимость наркотиков (%d+) вирт') inicfg.save(ini, iniName) end - if text:find('{FF8000} .* (%d+) .+') then - ini.price.zerno = text:match('{FF8000} .* (%d+) .+') + if text:find('{FF8000}Загрузка зерна.*Стоимость зерна (%d+) вирт.+') then + ini.price.zerno = text:match('{FF8000}Загрузка зерна.*Стоимость зерна (%d+) вирт.+') inicfg.save(ini, iniName) end - if text:find('{FF8000} .* (%d+) ') then - ini.price.urojai = text:match('{FF8000} .* (%d+) ') + if text:find('{FF8000}Разгрузка урожая.*Стоимость урожая (%d+) вирт') then + ini.price.urojai = text:match('{FF8000}Разгрузка урожая.*Стоимость урожая (%d+) вирт') inicfg.save(ini, iniName) end end function sampev.onShowDialog(dialogId, style, title, button1, button2, text) - if text:find(".FBDD7E. :.FFFFFF.\t\t\t(%d+).+FBDD7E. :.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E. :{FFFFFF}\t\t\t(%d+) / %d+.+FBDD7E. :.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E. :.FFFFFF.\t\t\t(%d+).+FBDD7E. :.FFFFFF.\t\t\t(%d+)") then + if text:find(".FBDD7E.Баланс фермы:.FFFFFF.\t\t\t(%d+).+FBDD7E.Семена в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Урожая на поле:{FFFFFF}\t\t\t(%d+) / %d+.+FBDD7E.Продукции в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Цена за семена:.FFFFFF.\t\t\t(%d+).+FBDD7E.Цена на продукцию:.FFFFFF.\t\t\t(%d+)") then local S0 = CheckCoord() if S0 ~= '' then - ini[S0].bank, ini[S0].corn, ini[S0].product, ini[S0].cornPrice, ini[S0].productPrice = text:match(".FBDD7E. :.FFFFFF.\t\t\t(%d+).+FBDD7E. :.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E. :{FFFFFF}\t\t\t%d+ / %d+.+FBDD7E. :.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E. :.FFFFFF.\t\t\t(%d+).+FBDD7E. :.FFFFFF.\t\t\t(%d+)") + ini[S0].bank, ini[S0].corn, ini[S0].product, ini[S0].cornPrice, ini[S0].productPrice = text:match(".FBDD7E.Баланс фермы:.FFFFFF.\t\t\t(%d+).+FBDD7E.Семена в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Урожая на поле:{FFFFFF}\t\t\t%d+ / %d+.+FBDD7E.Продукции в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Цена за семена:.FFFFFF.\t\t\t(%d+).+FBDD7E.Цена на продукцию:.FFFFFF.\t\t\t(%d+)") inicfg.save(ini, iniName) if finfoCheck ~= 0 then finfoCheck = 0 @@ -239,27 +239,27 @@ function sampev.onShowDialog(dialogId, style, title, button1, button2, text) end end end - if text:find('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ .*{FFFFFF}: {0289CC}%d+ ') then - zerno = zerno + tonumber(text:match('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ .*{FFFFFF}: {0289CC}%d+ ')) + if text:find('{FFFFFF}Зерна куплено: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт.*{FFFFFF}Скидка: {0289CC}%d+ вирт') then + zerno = zerno + tonumber(text:match('{FFFFFF}Зерна куплено: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт.*{FFFFFF}Скидка: {0289CC}%d+ вирт')) print(zerno) end - if text:find('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ .*{FFFFFF} : {0289CC}%d+ ') then - zerno = zerno - tonumber(text:match('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ .*{FFFFFF} : {0289CC}%d+ ')) + if text:find('{FFFFFF}Зерна продано: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт.*{FFFFFF}Добавлено к ЗП: {0289CC}%d+ вирт') then + zerno = zerno - tonumber(text:match('{FFFFFF}Зерна продано: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт.*{FFFFFF}Добавлено к ЗП: {0289CC}%d+ вирт')) print(zerno) end - if text:find('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ ') then - urojai = urojai + tonumber(text:match('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ ')) + if text:find('{FFFFFF}Урожая куплено: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт') then + urojai = urojai + tonumber(text:match('{FFFFFF}Урожая куплено: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт')) print(urojai) end - if text:find(' : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ ') then - urojai = urojai - tonumber(text:match(' : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ ')) + if text:find('Урожая продано: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт') then + urojai = urojai - tonumber(text:match('Урожая продано: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт')) print(urojai) end - if text:find('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ ') then - narko = narko + tonumber(text:match('{FFFFFF} : {0289CC}(%d+).*{FFFFFF}: {0289CC}%d+ ')) + if text:find('{FFFFFF}Наркотиков куплено: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт') then + narko = narko + tonumber(text:match('{FFFFFF}Наркотиков куплено: {0289CC}(%d+).*{FFFFFF}Цена: {0289CC}%d+ вирт')) end - if text:find(' : {0289CC}(%d+)') then - narko = narko - tonumber(text:match(' : {0289CC}(%d+)')) + if text:find('Наркотиков продано: {0289CC}(%d+)') then + narko = narko - tonumber(text:match('Наркотиков продано: {0289CC}(%d+)')) end end @@ -301,7 +301,7 @@ menu = {} function menu.get() return { { - settings = {title = "corn-hud" ,style = 4 ,btn1 = "" ,btn2 = "" ,forward = "{ffffff}" ,backwards = "\n" ,score = true}, + settings = {title = "corn-hud" ,style = 4 ,btn1 = "Выбрать" ,btn2 = "Закрыть" ,forward = "{ffffff}" ,backwards = "\n" ,score = true}, { { title = 'HUD\t'..(render and "ON" or "OFF"), @@ -312,7 +312,7 @@ function menu.get() end }, { - title = ' \t', + title = 'Сменить позицию\t', click = function(button, list, input , outs) if button ~= 1 then return end if not render then @@ -332,7 +332,7 @@ function menu.get() end }, { - title = ' 1\t'..ini.Settings.Key1:gsub("VK_", ""), + title = 'Клавиша №1\t'..ini.Settings.Key1:gsub("VK_", ""), click = function(button, list, input , outs) if button ~= 1 then return end wait(200) @@ -340,7 +340,7 @@ function menu.get() repeat wait(0) if not sampIsDialogActive() then - sampShowDialog(0, " ", " ", "", "", 0) + sampShowDialog(0, "Смена активации", "Нажмите на любую клавишу", "Выбрать", "Закрыть", 0) end for k, v in pairs(vkeys) do if wasKeyPressed(v) and k ~= "VK_ESCAPE" and k ~= "VK_RETURN" then @@ -354,7 +354,7 @@ function menu.get() end }, { - title = ' 2\t'..ini.Settings.Key2:gsub("VK_", ""), + title = 'Клавиша №2\t'..ini.Settings.Key2:gsub("VK_", ""), click = function(button, list, input , outs) if button ~= 1 then return end wait(200) @@ -362,7 +362,7 @@ function menu.get() repeat wait(0) if not sampIsDialogActive() then - sampShowDialog(0, " ", " ", "", "", 0) + sampShowDialog(0, "Смена активации", "Нажмите на любую клавишу", "Выбрать", "Закрыть", 0) end for k, v in pairs(vkeys) do if wasKeyPressed(v) and k ~= "VK_ESCAPE" and k ~= "VK_RETURN" then @@ -470,7 +470,7 @@ function openURL(url, fpath) if (text:find("Not found") and not text:find('"Not found"')) or text == "" then text = "" - addChatMessage(" :") + addChatMessage("Не удалось скачать обновление по ссылке:") addChatMessage(url) end @@ -509,12 +509,12 @@ script_update = { if result then ini[name].server_version = text if text ~= "" and not string.find(text, thisScript().version) then - addChatMessage( string.format(" '%s'. : '%s'", text, thisScript().version) ) + addChatMessage( string.format("Вышла новая версия '%s'. Текущая: '%s'", text, thisScript().version) ) if ini[name].auto_update then - addChatMessage( string.format(" . !") ) + addChatMessage( string.format("Автообновление скрипта включено. Процесс запущен!") ) script_update.command() else - addChatMessage( string.format(" . : /%s", command) ) + addChatMessage( string.format("Автообновление скрипта выключено. Обновить самому: /%s", command) ) end end end @@ -528,7 +528,7 @@ script_update = { local result, text = pcall(openURL, script_update.version_url, fpath) if result then if text ~= "" and not string.find(text, thisScript().version) then - addChatMessage( string.format(" '%s'. : '%s'", text, thisScript().version) ) + addChatMessage( string.format("Вышла новая версия '%s'. Текущая: '%s'", text, thisScript().version) ) local fpath = os.tmpname() local result, text = pcall(openURL, script_update.script_url, fpath) if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then @@ -537,13 +537,13 @@ script_update = { file:write(text) file:flush() io.close(file) - addChatMessage(" , !") + addChatMessage("Обновление завершено, скрипт перезагружен!") wait(500) thisScript():reload() end end else - addChatMessage(" !") + addChatMessage("У Вас установлена последняя версия!") end end end) @@ -553,7 +553,7 @@ script_update = { dialog = {}, init = function() if not sampIsChatCommandDefined("rubin-mods") then - sampAddChatMessage("{667dff}[RUBIN MODS]{FFFFFF} : /rubin-mods", 0xFFFFFFFF) + sampAddChatMessage("{667dff}[RUBIN MODS]{FFFFFF} Управление обновлениями скриптов: /rubin-mods", 0xFFFFFFFF) sampRegisterChatCommand("rubin-mods",script_update.menu.show) while true do wait(0) @@ -596,7 +596,7 @@ script_update = { for i = 1, #script_update.menu.text do text = text..script_update.menu.text[i].."\n" end - sampShowDialog(2160," : Rubin Mods","\t\n"..text,"","",5) + sampShowDialog(2160,"Обновление скриптов: Rubin Mods","Скрипт\tВерсия\n"..text,"Выбрать","Закрыть",5) end }, menu2 = { @@ -609,25 +609,25 @@ script_update = { script_update.menu2.dialog = {} local ini = inicfg.load({}, script_update.address_ini) local k = data.script_name - script_update.menu2.text[#script_update.menu2.text+1] = string.format(" %s", (ini[k].auto_update and "{59fc30}ON" or "{ff0000}OFF")) + script_update.menu2.text[#script_update.menu2.text+1] = string.format("Автообновление %s", (ini[k].auto_update and "{59fc30}ON" or "{ff0000}OFF")) script_update.menu2.dialog[#script_update.menu2.dialog+1] = function() ini[k].auto_update = not ini[k].auto_update inicfg.save(ini, script_update.address_ini) script_update.menu2.show(data) end if not ini[k].auto_update then - script_update.menu2.text[#script_update.menu2.text+1] = string.format(" %s", (ini[k].check_update and "{59fc30}ON" or "{ff0000}OFF")) + script_update.menu2.text[#script_update.menu2.text+1] = string.format("Проверять обновления %s", (ini[k].check_update and "{59fc30}ON" or "{ff0000}OFF")) script_update.menu2.dialog[#script_update.menu2.dialog+1] = function() ini[k].check_update = not ini[k].check_update inicfg.save(ini, script_update.address_ini) script_update.menu2.show(data) end end - script_update.menu2.text[#script_update.menu2.text+1] = string.format(" ") + script_update.menu2.text[#script_update.menu2.text+1] = string.format("Последние изменения") script_update.menu2.dialog[#script_update.menu2.dialog+1] = function() script_update.changelog(ini[k].changelog_url) end - script_update.menu2.text[#script_update.menu2.text+1] = string.format(" ") + script_update.menu2.text[#script_update.menu2.text+1] = string.format("Удалить из списка") script_update.menu2.dialog[#script_update.menu2.dialog+1] = function() ini[k] = nil inicfg.save(ini, script_update.address_ini) @@ -638,14 +638,14 @@ script_update = { for i = 1, #script_update.menu2.text do text = text..script_update.menu2.text[i].."\n" end - sampShowDialog(2162," "..data.script_name,text,"","",2) + sampShowDialog(2162,"Настройки обновления для "..data.script_name,text,"Выбрать","Назад",2) end }, changelog = function(url, data) local fpath = os.tmpname() local result, text = pcall(openURL, url, fpath) if result then - sampShowDialog(2161,"Changelog - "..thisScript().name,text,"","",4) + sampShowDialog(2161,"Changelog - "..thisScript().name,text,"Выбрать","Назад",4) end end } \ No newline at end of file diff --git a/version b/version new file mode 100644 index 0000000..12e9912 --- /dev/null +++ b/version @@ -0,0 +1 @@ +23.01.2023 \ No newline at end of file