Ошибка в скрипте с автообновлением

Fasmin

Участник
Автор темы
112
2
Версия MoonLoader
.026-beta
Когда я выпускаю другую версию на гитхабе, далее в сампе выводит сообщение, что есть новая версия и просто крашит скрипт(варнинг прилетает). То есть дальше вывода обновления ничего не происходи. Проверьте правильный ли код пожалуйста

lua:
require 'lib.moonloader'
inicfg = require 'inicfg'
dLstatus = require('moonloader').download_status
enc = require('encoding')
enc.default = 'CP1251'

local update_state = false
local script_version = 2
local script_version_text = "0.2"

local update_url = "https://raw.githubusercontent.com/FasminCode/FasminCode/main/script_update.ini"
local update_path = getWorkingDirectory() .. '/script_update.ini'

local script_url = "https://github.com/FasminCode/FasminCode/blob/main/update.luac?raw=true"
local script_path = thisScript().path

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{ff0000}update.lua {00ff00}completed {ffffff}loaded", -1)
    sampRegisterChatCommand('update', cmd_update)
    
    downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dLstatus.STATUS_ENDDOWNLOADDATA then
            updateIni = inicfg.load(nil, update_path)
            if tonumber(updateIni.info.vers) > script_version then
                sampAddChatMessage("Новая версия: " .. updateIni.info.vers_text, -1)
                update_state = true
            end
            os.remove(update_path)
        end
    end)
    while true do wait(0)
        if update_state then
            --[[downloadUrlToFile(script_url, script_path, function(id, status)
                if status == dLstatus.STATUS_ENDDOWNLOADDATA then
                    sampAddChatMessage("Обновлено!", -1)
                    thisScript():reload()
                end
            end)
            break]]
            sampAddChatMessage("ГОТОВО!!!!!!!!!!!!!!!!", -1)
        end
    end
end

function cmd_update()
    sampShowDialog(2335, "UPDATE SCRIPT V2.0", "Новое обновление!\nЧто было добавлено: ничего!", "Закрыть", "", 0)
end
 
Последнее редактирование:

Fasmin

Участник
Автор темы
112
2
Lua:
require 'lib.moonloader'
inicfg = require 'inicfg'
dLstatus = require('moonloader').download_status
enc = require('encoding')
enc.default = 'CP1251'

local update_state = false
local script_version = 2
local script_version_text = "0.2"

local update_url = "https://raw.githubusercontent.com/FasminCode/FasminCode/main/script_update.ini"
local update_path = getWorkingDirectory() .. '/script_update.ini'

local script_url = "https://github.com/FasminCode/FasminCode/blob/main/update.luac?raw=true"
local script_path = thisScript().path

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{ff0000}update.lua {00ff00}completed {ffffff}loaded", -1)
    sampRegisterChatCommand('update', cmd_update)
  
    downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dlstatus.STATUS_ENDDOWNLOADDATA then
            updateIni = inicfg.load(nil, update_path)
            if tonumber(updateIni.info.vers) > script_version then
                sampAddChatMessage("Новая версия: " .. updateIni.info.vers_text, -1)
                update_state = true
            end
            os.remove(update_path)
        end
    end)
    while true do wait(0)
        if update_state then
            downloadUrlToFile(script_url, script_path, function(id, status)
                if status == dlstatus.STATUS_ENDDOWNLOADDATA then
                    sampAddChatMessage("Обновлено!", -1)
                    thisScript():reload()
                end
            end)
            break
            sampAddChatMessage("ГОТОВО!!!!!!!!!!!!!!!!", -1)
        end
    end
end

function cmd_update()
    sampShowDialog(2335, "UPDATE SCRIPT V2.0", "Новое обновление!\nЧто было добавлено: ничего!", "Закрыть", "", 0)
end
Ты тупо переставил sampaddchatmessage? Ахах, гений просто гений.
 

FixZer

Активный
126
36
Когда я выпускаю другую версию на гитхабе, далее в сампе выводит сообщение, что есть новая версия и просто крашит скрипт(варнинг прилетает). То есть дальше вывода обновления ничего не происходи. Проверьте правильный ли код пожалуйста

lua:
require 'lib.moonloader'
inicfg = require 'inicfg'
dLstatus = require('moonloader').download_status
enc = require('encoding')
enc.default = 'CP1251'

local update_state = false
local script_version = 2
local script_version_text = "0.2"

local update_url = "https://raw.githubusercontent.com/FasminCode/FasminCode/main/script_update.ini"
local update_path = getWorkingDirectory() .. '/script_update.ini'

local script_url = "https://github.com/FasminCode/FasminCode/blob/main/update.luac?raw=true"
local script_path = thisScript().path

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{ff0000}update.lua {00ff00}completed {ffffff}loaded", -1)
    sampRegisterChatCommand('update', cmd_update)
  
    downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dLstatus.STATUS_ENDDOWNLOADDATA then
            updateIni = inicfg.load(nil, update_path)
            if tonumber(updateIni.info.vers) > script_version then
                sampAddChatMessage("Новая версия: " .. updateIni.info.vers_text, -1)
                update_state = true
            end
            os.remove(update_path)
        end
    end)
    while true do wait(0)
        if update_state then
            --[[downloadUrlToFile(script_url, script_path, function(id, status)
                if status == dLstatus.STATUS_ENDDOWNLOADDATA then
                    sampAddChatMessage("Обновлено!", -1)
                    thisScript():reload()
                end
            end)
            break]]
            sampAddChatMessage("ГОТОВО!!!!!!!!!!!!!!!!", -1)
        end
    end
end

function cmd_update()
    sampShowDialog(2335, "UPDATE SCRIPT V2.0", "Новое обновление!\nЧто было добавлено: ничего!", "Закрыть", "", 0)
end
Lua:
require 'lib.moonloader'
inicfg = require 'inicfg'
dLstatus = require('moonloader').download_status
enc = require('encoding')
enc.default = 'CP1251'

local dlstatus = require('moonloader').download_status

local update_state = false
local script_version = 2
local script_version_text = "0.2"

local update_url = "https://raw.githubusercontent.com/FasminCode/FasminCode/main/script_update.ini"
local update_path = getWorkingDirectory() .. '/script_update.ini'

local script_url = "https://github.com/FasminCode/FasminCode/blob/main/update.luac?raw=true"
local script_path = thisScript().path

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{ff0000}update.lua {00ff00}completed {ffffff}loaded", -1)
    sampRegisterChatCommand('update', cmd_update)
   
    downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dLstatus.STATUS_ENDDOWNLOADDATA then
            updateIni = inicfg.load(nil, update_path)
            if tonumber(updateIni.info.vers) > script_version then
                sampAddChatMessage("Новая версия: " .. updateIni.info.vers_text, -1)
                update_state = true
            end
            os.remove(update_path)
        end
    end)
    while true do wait(0)
        if update_state then
            downloadUrlToFile(script_url, script_path, function(id, status)
                if status == dLstatus.STATUS_ENDDOWNLOADDATA then
                    sampAddChatMessage("Обновлено!", -1)
                    thisScript():reload()
                end
            end)
            break
            sampAddChatMessage("ГОТОВО!!!!!!!!!!!!!!!!", -1)
        end
    end
end

function cmd_update()
    sampShowDialog(2335, "UPDATE SCRIPT V2.0", "Новое обновление!\nЧто было добавлено: ничего!", "Закрыть", "", 0)
end