modify update command

test-utf-8
rubin 2 years ago
parent a1c799fa10
commit 28fb199a23
  1. 14
      TruckHUD.lua

@ -4418,6 +4418,8 @@ script_update = {
ini[name].changelog_url = script_update.changelog_url ini[name].changelog_url = script_update.changelog_url
ini[name].version = thisScript().version ini[name].version = thisScript().version
ini[name].script_name = thisScript().name ini[name].script_name = thisScript().name
local command = (thisScript().name:gsub(" ", "").."-update"):lower()
sampRegisterChatCommand(command, script_update.command)
if ini[name].check_update or ini[name].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)
@ -4429,8 +4431,6 @@ script_update = {
addChatMessage( string.format("Àâòîîáíîâëåíèå ñêðèïòà âêëþ÷åíî. Ïðîöåññ çàïóùåí!") ) addChatMessage( string.format("Àâòîîáíîâëåíèå ñêðèïòà âêëþ÷åíî. Ïðîöåññ çàïóùåí!") )
script_update.command() script_update.command()
else else
local command = (thisScript().name:gsub(" ", "").."-update"):lower()
sampRegisterChatCommand(command, script_update.command)
addChatMessage( string.format("Àâòîîáíîâëåíèå ñêðèïòà âûêëþ÷åíî. Îáíîâèòü ñàìîìó: /%s", command) ) addChatMessage( string.format("Àâòîîáíîâëåíèå ñêðèïòà âûêëþ÷åíî. Îáíîâèòü ñàìîìó: /%s", command) )
end end
end end
@ -4441,6 +4441,12 @@ script_update = {
end, end,
command = function() command = function()
lua_thread.create(function() lua_thread.create(function()
local fpath = os.tmpname()
local result, text = pcall(openURL, script_update.version_url, fpath)
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) )
local fpath = os.tmpname() local fpath = os.tmpname()
local result, text = pcall(openURL, script_update.script_url, fpath) local result, text = pcall(openURL, script_update.script_url, fpath)
if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then
@ -4454,6 +4460,10 @@ script_update = {
thisScript():reload() thisScript():reload()
end end
end end
else
addChatMessage("Ó Âàñ óñòàíîâëåíà ïîñëåäíÿÿ âåðñèÿ!")
end
end
end) end)
end, end,
menu = { menu = {

Loading…
Cancel
Save