|
|
|
@ -215,7 +215,7 @@ function main() |
|
|
|
|
lua_thread.create(luChecker.checker) |
|
|
|
|
lua_thread.create(doCruise) |
|
|
|
|
|
|
|
|
|
--lua_thread.create(script_update.main) |
|
|
|
|
lua_thread.create(script_update.main) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1075,14 +1075,14 @@ function doCruise() |
|
|
|
|
printStringNow('~R~cruise control - OFF', 1500) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then |
|
|
|
|
if isCharInAnyCar(playerPed) and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then |
|
|
|
|
if not cruise and isKeyDown(vkeys["VK_W"]) and isKeyDown(vkeys[inifiles.Settings.Key4]) then |
|
|
|
|
cruise = true |
|
|
|
|
printStringNow('~G~cruise control - ON', 1500) |
|
|
|
|
repeat |
|
|
|
|
wait(100) |
|
|
|
|
until not isKeyDown(vkeys["VK_W"]) |
|
|
|
|
elseif cruise and not isKeyDown(vkeys[inifiles.Settings.Key4]) and select(1, check_press_key(additional_key_stop)) then |
|
|
|
|
elseif cruise and (isKeyDown(vkeys[inifiles.Settings.Key4]) or select(1, check_press_key(additional_key_stop))) then |
|
|
|
|
cruise = false |
|
|
|
|
printStringNow('~R~cruise control - OFF', 1500) |
|
|
|
|
end |
|
|
|
@ -4349,10 +4349,9 @@ function addChatMessage(text) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
script_update = { |
|
|
|
|
check_update = false, |
|
|
|
|
check_update_url = "http://gith.deadpoo.net/rubin/TruckHUD/raw/branch/master/version", |
|
|
|
|
auto_update = false, |
|
|
|
|
auto_update_url = "http://gith.deadpoo.net/rubin/TruckHUD/raw/branch/master/TruckHUD.lua", |
|
|
|
|
version_url = "http://gith.deadpoo.net/rubin/TruckHUD/raw/branch/master/version", |
|
|
|
|
script_url = "http://gith.deadpoo.net/rubin/TruckHUD/raw/branch/master/TruckHUD.lua", |
|
|
|
|
changelog_url = "http://gith.deadpoo.net/rubin/TruckHUD/raw/branch/master/changelog", |
|
|
|
|
address_ini = "rubin-mods-updates.ini", |
|
|
|
|
main = function() |
|
|
|
|
local name = thisScript().name |
|
|
|
@ -4362,20 +4361,22 @@ script_update = { |
|
|
|
|
auto_update = true |
|
|
|
|
} |
|
|
|
|
}, script_update.address_ini) |
|
|
|
|
script_update.check_update = ini[name].check_update |
|
|
|
|
script_update.auto_update = ini[name].auto_update |
|
|
|
|
ini[name].version_url = script_update.version_url |
|
|
|
|
ini[name].script_url = script_update.script_url |
|
|
|
|
ini[name].changelog_url = script_update.changelog_url |
|
|
|
|
ini[name].script_name = thisScript().name |
|
|
|
|
inicfg.save(ini, script_update.address_ini) |
|
|
|
|
if script_update.check_update or script_update.auto_update then |
|
|
|
|
if ini[name].check_update or ini[name].auto_update then |
|
|
|
|
local fpath = os.tmpname() |
|
|
|
|
local result, text = openURL(script_update.check_update_url, fpath) |
|
|
|
|
local result, text = 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) ) |
|
|
|
|
if script_update.auto_update then |
|
|
|
|
if ini[name].auto_update then |
|
|
|
|
addChatMessage( string.format("Àâòî-Îáíîâëåíèå ñêðèïòà âêëþ÷åíî. Ïðîöåññ çàïóùåí!") ) |
|
|
|
|
script_update.command() |
|
|
|
|
else |
|
|
|
|
local command = thisScript().name:gsub(" ", "").."-update" |
|
|
|
|
local command = (thisScript().name:gsub(" ", "").."-update"):lower() |
|
|
|
|
sampRegisterChatCommand(command, script_update.command) |
|
|
|
|
addChatMessage( string.format("Àâòî-Îáíîâëåíèå ñêðèïòà âûêëþ÷åíî. Îáíîâèòü ñàìîìó: /%s", command) ) |
|
|
|
|
end |
|
|
|
@ -4386,24 +4387,26 @@ script_update = { |
|
|
|
|
end, |
|
|
|
|
command = function() |
|
|
|
|
lua_thread.create(function() |
|
|
|
|
local fpath = os.tmpname() |
|
|
|
|
local result, text = openURL(script_update.auto_update_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 |
|
|
|
|
-- local fpath = os.tmpname() |
|
|
|
|
-- local result, text = 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 |
|
|
|
|
end) |
|
|
|
|
end, |
|
|
|
|
menu = { |
|
|
|
|
text = {}, |
|
|
|
|
dialog = {}, |
|
|
|
|
text2 = {}, |
|
|
|
|
dialog2 = {}, |
|
|
|
|
init = function() |
|
|
|
|
if not sampIsChatCommandDefined("rubin-mods") then |
|
|
|
|
sampRegisterChatCommand("rubin-mods",script_update.menu.show) |
|
|
|
@ -4412,9 +4415,23 @@ script_update = { |
|
|
|
|
local result, button, list, input = sampHasDialogRespond(2160) |
|
|
|
|
if result and button == 1 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.dialog[list+1](script_update.menu.ini[list+1]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
local result, button, list, input = sampHasDialogRespond(2162) |
|
|
|
|
if result then |
|
|
|
|
if button == 1 then |
|
|
|
|
if script_update.menu2.text[list+1] ~= nil and script_update.menu2.dialog[list+1] ~= nil then |
|
|
|
|
script_update.menu2.dialog[list+1]() |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
script_update.menu.show() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
local result, button, list, input = sampHasDialogRespond(2161) |
|
|
|
|
if result then |
|
|
|
|
script_update.menu2.show(script_update.menu2.data) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
say("Êîìàíäà çàðåãàíà") |
|
|
|
@ -4423,43 +4440,70 @@ script_update = { |
|
|
|
|
show = function() |
|
|
|
|
script_update.menu.text = {} |
|
|
|
|
script_update.menu.dialog = {} |
|
|
|
|
script_update.menu.ini = {} |
|
|
|
|
local ini = inicfg.load({}, script_update.address_ini) |
|
|
|
|
for k,v in pairs(ini) do |
|
|
|
|
script_update.menu.text[#script_update.menu.text+1] = string.format(" ") |
|
|
|
|
script_update.menu.dialog[#script_update.menu.dialog+1] = function() |
|
|
|
|
script_update.menu.show() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
script_update.menu.text[#script_update.menu.text+1] = string.format("> %s", k) |
|
|
|
|
script_update.menu.dialog[#script_update.menu.dialog+1] = function() |
|
|
|
|
script_update.menu.show() |
|
|
|
|
end |
|
|
|
|
script_update.menu.text[#script_update.menu.text+1] = string.format("\tauto update %s", (ini[k].auto_update and "{59fc30}ON" or "{ff0000}OFF")) |
|
|
|
|
script_update.menu.dialog[#script_update.menu.dialog+1] = function() |
|
|
|
|
ini[k].auto_update = not ini[k].auto_update |
|
|
|
|
inicfg.save(ini, script_update.address_ini) |
|
|
|
|
script_update.menu.show() |
|
|
|
|
end |
|
|
|
|
if not ini[k].auto_update then |
|
|
|
|
script_update.menu.text[#script_update.menu.text+1] = string.format("\tcheck update %s", (ini[k].check_update and "{59fc30}ON" or "{ff0000}OFF")) |
|
|
|
|
script_update.menu.dialog[#script_update.menu.dialog+1] = function() |
|
|
|
|
ini[k].check_update = not ini[k].check_update |
|
|
|
|
inicfg.save(ini, script_update.address_ini) |
|
|
|
|
script_update.menu.show() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
script_update.menu.text[#script_update.menu.text+1] = string.format("\tdelete update settings") |
|
|
|
|
script_update.menu.dialog[#script_update.menu.dialog+1] = function() |
|
|
|
|
ini[k] = nil |
|
|
|
|
inicfg.save(ini, script_update.address_ini) |
|
|
|
|
script_update.menu.show() |
|
|
|
|
script_update.menu.ini[#script_update.menu.ini+1] = v |
|
|
|
|
script_update.menu.text[#script_update.menu.text+1] = string.format("%s", k) |
|
|
|
|
script_update.menu.dialog[#script_update.menu.dialog+1] = function(data) |
|
|
|
|
-- script_update.menu.show() |
|
|
|
|
script_update.menu2.show(data) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
local text = "" |
|
|
|
|
for i = 1, #script_update.menu.text do |
|
|
|
|
text = text..script_update.menu.text[i].."\n" |
|
|
|
|
end |
|
|
|
|
sampShowDialog(2160,"rubin-mods update settings",text,"Enter","Exit",2) |
|
|
|
|
sampShowDialog(2160,"Îáíîâëåíèå ñêðèïòîâ: Rubin Mods",text,"Âûáðàòü","Çàêðûòü",2) |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
menu2 = { |
|
|
|
|
data = {}, |
|
|
|
|
text = {}, |
|
|
|
|
dialog = {}, |
|
|
|
|
show = function(data) |
|
|
|
|
script_update.menu2.data = data |
|
|
|
|
script_update.menu2.text = {} |
|
|
|
|
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.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() |
|
|
|
|
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.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 |
|
|
|
|
}, |
|
|
|
|
changelog = function(url, data) |
|
|
|
|
local fpath = os.tmpname() |
|
|
|
|
local result, text = openURL(url, fpath) |
|
|
|
|
if result then |
|
|
|
|
sampShowDialog(2161,"Changelog - "..thisScript().name,text,"Âûáðàòü","Íàçàä",4) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|