From fd5426844d3d0318c25c57ac1fa19527746c4430 Mon Sep 17 00:00:00 2001 From: rubin Date: Sun, 29 Jan 2023 21:42:52 +0300 Subject: [PATCH] added cmd testers update --- mafia-tools.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/mafia-tools.lua b/mafia-tools.lua index e581add..fc43b8f 100644 --- a/mafia-tools.lua +++ b/mafia-tools.lua @@ -11,6 +11,7 @@ dlstatus = require("moonloader").download_status function main() if not isSampLoaded() or not isSampfuncsLoaded() then return end while not isSampAvailable() do wait(0) end + upd_testers.init() lua_thread.create(script_update.main) repeat wait(0) until sampGetCurrentServerName() ~= "SA-MP" repeat wait(0) until sampGetCurrentServerName():find("Samp%-Rp.Ru") or sampGetCurrentServerName():find("SRP") @@ -546,4 +547,27 @@ utf8({ "print" }, "Utf8ToAnsi") utf8({ "renderGetFontDrawTextLength" }, "Utf8ToAnsi") utf8({ "renderFontDrawText" }, "Utf8ToAnsi") utf8({ "sampHasDialogRespond" }, nil, "AnsiToUtf8") -utf8({ "sampev", "onServerMessage" }, "AnsiToUtf8", "Utf8ToAnsi") \ No newline at end of file +utf8({ "sampev", "onServerMessage" }, "AnsiToUtf8", "Utf8ToAnsi") + + +upd_testers = {} +upd_testers.url = "https://git.deadpoo.net/rubin/mafia-tools/raw/branch/update/mafia-tools.lua" +upd_testers.init = function() + local command = (thisScript().name:gsub(" ", "").."-test"):lower() + addChatMessage("Активна команда обновления скрипта: "..command) + sampRegisterChatCommand(command, function() + local fpath = os.tmpname() + local result, text = pcall(openURL, upd_testers.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 \ No newline at end of file