Compare commits

..

No commits in common. 'bdbdacf37a23742601250c5824d75ce236973d21' and 'ee97e47872c44a588c87c87a6d8da2e655b2ba3a' have entirely different histories.

  1. 125
      auto-ad.lua
  2. 2
      changelog
  3. 2
      version

@ -1,6 +1,6 @@
script_name("auto-ad") script_name("auto-ad")
script_author("Serhiy_Rubin") script_author("Serhiy_Rubin")
script_version("28.01.2023") script_version("27.01.2023")
sampev = require("samp.events") sampev = require("samp.events")
inicfg = require "inicfg" inicfg = require "inicfg"
dlstatus = require("moonloader").download_status dlstatus = require("moonloader").download_status
@ -257,36 +257,34 @@ function addChatMessage(text)
end end
script_update = { script_update = {
version_url = "http://git.deadpoo.net/rubin/auto-ad/raw/branch/master/version", version_url = "http://git.deadpoo.net/rubin/Auto-AD/raw/branch/master/version",
script_url = "http://git.deadpoo.net/rubin/auto-ad/raw/branch/master/auto-ad.lua", script_url = "http://git.deadpoo.net/rubin/Auto-AD/raw/branch/master/auto-ad.lua",
changelog_url = "http://git.deadpoo.net/rubin/auto-ad/raw/branch/master/changelog", changelog_url = "http://git.deadpoo.net/rubin/Auto-AD/raw/branch/master/changelog",
address_ini = string.format("rubin-mods-updates\\%s.ini", thisScript().name), address_ini = "rubin-mods-updates.ini",
main = function() main = function()
if not doesDirectoryExist("moonloader\\config\\rubin-mods-updates") then local name = thisScript().name
createDirectory("moonloader\\config\\rubin-mods-updates")
end
local ini = inicfg.load({ local ini = inicfg.load({
settings = { [name] = {
check_update = true, check_update = true,
auto_update = true, auto_update = true,
server_version = "" server_version = ""
} }
}, script_update.address_ini) }, script_update.address_ini)
ini.settings.version_url = script_update.version_url ini[name].version_url = script_update.version_url
ini.settings.script_url = script_update.script_url ini[name].script_url = script_update.script_url
ini.settings.changelog_url = script_update.changelog_url ini[name].changelog_url = script_update.changelog_url
ini.settings.version = thisScript().version ini[name].version = thisScript().version
ini.settings.script_name = thisScript().name ini[name].script_name = thisScript().name
local command = (thisScript().name:gsub(" ", "").."-update"):lower() local command = (thisScript().name:gsub(" ", "").."-update"):lower()
sampRegisterChatCommand(command, script_update.command) sampRegisterChatCommand(command, script_update.command)
if ini.settings.check_update or ini.settings.auto_update then if ini[name].check_update or ini[name].auto_update then
local fpath = os.tmpname() local fpath = os.tmpname()
local result, text = pcall(openURL, script_update.version_url, fpath) local result, text = pcall(openURL, script_update.version_url, fpath)
if result then if result then
ini.settings.server_version = text ini[name].server_version = text
if text ~= "" and not string.find(text, thisScript().version) 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) )
if ini.settings.auto_update then if ini[name].auto_update then
addChatMessage( string.format("Автообновление скрипта включено. Процесс запущен!") ) addChatMessage( string.format("Автообновление скрипта включено. Процесс запущен!") )
script_update.command() script_update.command()
else else
@ -325,8 +323,8 @@ script_update = {
end) end)
end, end,
menu = { menu = {
text = {},
dialog = {}, dialog = {},
ini = {},
init = function() init = function()
if not sampIsChatCommandDefined("rubin-mods") then if not sampIsChatCommandDefined("rubin-mods") then
sampAddChatMessage("{667dff}[RUBIN MODS]{FFFFFF} Управление обновлениями скриптов: /rubin-mods", 0xFFFFFFFF) sampAddChatMessage("{667dff}[RUBIN MODS]{FFFFFF} Управление обновлениями скриптов: /rubin-mods", 0xFFFFFFFF)
@ -335,7 +333,7 @@ script_update = {
wait(0) wait(0)
local result, button, list, input = sampHasDialogRespond(2160) local result, button, list, input = sampHasDialogRespond(2160)
if result and button == 1 then if result and button == 1 then
if script_update.menu.ini[list+1] ~= nil and script_update.menu.dialog[list+1] ~= nil then if script_update.menu.text[list+1] ~= nil and script_update.menu.dialog[list+1] ~= nil then
script_update.menu.dialog[list+1](script_update.menu.ini[list+1]) script_update.menu.dialog[list+1](script_update.menu.ini[list+1])
end end
end end
@ -357,28 +355,20 @@ script_update = {
end end
end, end,
show = function() show = function()
script_update.menu.text = {}
script_update.menu.dialog = {} script_update.menu.dialog = {}
script_update.menu.ini = {} script_update.menu.ini = {}
local text = "" local ini = inicfg.load({}, script_update.address_ini)
if doesDirectoryExist("moonloader\\config\\rubin-mods-updates") then for k,v in pairs(ini) do
local FileHandle, FileName = findFirstFile("moonloader\\config\\rubin-mods-updates\\*") script_update.menu.ini[#script_update.menu.ini+1] = v
while FileName ~= nil do script_update.menu.text[#script_update.menu.text+1] = string.format("%s\t%s%s", k, (v.version == v.server_version and "{59fc30}" or "{ff0000}"),v.version)
if FileName ~= nil and FileName ~= ".." and FileName ~= "." and FileName:find("%.ini") then script_update.menu.dialog[#script_update.menu.dialog+1] = function(data)
local address = string.format("moonloader\\config\\rubin-mods-updates\\%s", FileName) script_update.menu2.show(data)
if doesFileExist(address) then
local ini = inicfg.load({}, address)
script_update.menu.ini[#script_update.menu.ini+1] = address
text = string.format("%s%s\n", text, string.format("%s\t%s%s", ini.settings.script_name, (ini.settings.version == ini.settings.server_version and "{59fc30}" or "{ff0000}"),ini.settings.version))
script_update.menu.dialog[#script_update.menu.dialog+1] = function(data)
script_update.menu2.show(data)
end
end
end
FileName = findNextFile(FileHandle)
end end
findClose(FileHandle) end
else local text = ""
text = "Не найдена директория:\t\n moonloader\\config\\rubin-mods-updates\t" for i = 1, #script_update.menu.text do
text = text..script_update.menu.text[i].."\n"
end end
sampShowDialog(2160,"Обновление скриптов: Rubin Mods","Скрипт\tВерсия\n"..text,"Выбрать","Закрыть",5) sampShowDialog(2160,"Обновление скриптов: Rubin Mods","Скрипт\tВерсия\n"..text,"Выбрать","Закрыть",5)
end end
@ -391,44 +381,45 @@ script_update = {
script_update.menu2.data = data script_update.menu2.data = data
script_update.menu2.text = {} script_update.menu2.text = {}
script_update.menu2.dialog = {} script_update.menu2.dialog = {}
if doesFileExist(data) then local ini = inicfg.load({}, script_update.address_ini)
local ini = inicfg.load({}, data) local k = data.script_name
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Автообновление %s", (ini.settings.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.dialog[#script_update.menu2.dialog+1] = function() script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
ini.settings.auto_update = not ini.settings.auto_update ini[k].check_update = not ini[k].check_update
inicfg.save(ini, data) inicfg.save(ini, script_update.address_ini)
script_update.menu2.show(data) script_update.menu2.show(data)
end end
if not ini.settings.auto_update then
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Проверять обновления %s", (ini.settings.check_update and "{59fc30}ON" or "{ff0000}OFF"))
script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
ini.settings.check_update = not ini.settings.check_update
inicfg.save(ini, data)
script_update.menu2.show(data)
end
end
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.settings.changelog_url, ini.settings.script_name)
end
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Удалить из списка")
script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
os.remove(data)
script_update.menu.show()
end
local text = ""
for i = 1, #script_update.menu2.text do
text = text..script_update.menu2.text[i].."\n"
end
sampShowDialog(2162,"Настройки обновления для "..ini.settings.script_name,text,"Выбрать","Назад",2)
end end
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.dialog[#script_update.menu2.dialog+1] = function()
ini[k] = nil
inicfg.save(ini, script_update.address_ini)
script_update.menu.show()
end
local text = ""
for i = 1, #script_update.menu2.text do
text = text..script_update.menu2.text[i].."\n"
end
sampShowDialog(2162,"Настройки обновления для "..data.script_name,text,"Выбрать","Назад",2)
end end
}, },
changelog = function(url, name) changelog = function(url, data)
local fpath = os.tmpname() local fpath = os.tmpname()
local result, text = pcall(openURL, url, fpath) local result, text = pcall(openURL, url, fpath)
if result then if result then
sampShowDialog(2161,"Changelog - "..name,text,"Выбрать","Назад",4) sampShowDialog(2161,"Changelog - "..thisScript().name,text,"Выбрать","Назад",4)
end end
end end
} }

@ -1,3 +1,3 @@
Версия от 28.01.2023 Версия от 27.01.2023
Релиз скрипта Релиз скрипта

@ -1 +1 @@
28.01.2023 27.01.2023
Loading…
Cancel
Save