|
|
|
@ -4418,6 +4418,8 @@ script_update = { |
|
|
|
|
ini[name].changelog_url = script_update.changelog_url |
|
|
|
|
ini[name].version = thisScript().version |
|
|
|
|
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 |
|
|
|
|
local fpath = os.tmpname() |
|
|
|
|
local result, text = pcall(openURL, script_update.version_url, fpath) |
|
|
|
@ -4429,8 +4431,6 @@ script_update = { |
|
|
|
|
addChatMessage( string.format("Àâòîîáíîâëåíèå ñêðèïòà âêëþ÷åíî. Ïðîöåññ çàïóùåí!") ) |
|
|
|
|
script_update.command() |
|
|
|
|
else |
|
|
|
|
local command = (thisScript().name:gsub(" ", "").."-update"):lower() |
|
|
|
|
sampRegisterChatCommand(command, script_update.command) |
|
|
|
|
addChatMessage( string.format("Àâòîîáíîâëåíèå ñêðèïòà âûêëþ÷åíî. Îáíîâèòü ñàìîìó: /%s", command) ) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -4442,16 +4442,26 @@ script_update = { |
|
|
|
|
command = function() |
|
|
|
|
lua_thread.create(function() |
|
|
|
|
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 |
|
|
|
|
local file, error = io.open(thisScript().path, "w") |
|
|
|
|
if file ~= nil then |
|
|
|
|
file:write(text) |
|
|
|
|
file:flush() |
|
|
|
|
io.close(file) |
|
|
|
|
addChatMessage("Îáíîâëåíèå çàâåðøåíî, ñêðèïò ïåðåçàãðóæåí!") |
|
|
|
|
wait(500) |
|
|
|
|
thisScript():reload() |
|
|
|
|
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 result, text = pcall(openURL, script_update.script_url, fpath) |
|
|
|
|
if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then |
|
|
|
|
local file, error = io.open(thisScript().path, "w") |
|
|
|
|
if file ~= nil then |
|
|
|
|
file:write(text) |
|
|
|
|
file:flush() |
|
|
|
|
io.close(file) |
|
|
|
|
addChatMessage("Îáíîâëåíèå çàâåðøåíî, ñêðèïò ïåðåçàãðóæåí!") |
|
|
|
|
wait(500) |
|
|
|
|
thisScript():reload() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
addChatMessage("Ó Âàñ óñòàíîâëåíà ïîñëåäíÿÿ âåðñèÿ!") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|