асинхронные функции

leekyrave

Известный
Автор темы
418
226
Версия MoonLoader
.026-beta
Lua:
function checkip(reg,last)
    local args = {}
    args['headers'] = {['Content-Type'] = 'application/json'}
    asyncHttpRequest('GET', 'http://api.mint-plantation.ru/amogus.php?reg='..reg..'&last='..last, args,
    function(response)
       local result = decodeJson(response.text)
       lipInfo = result
       return result
    end,
    function(err)
       print(err)
    end)
end
Почему вот такая штучка ничего не возвращает и не записываются переменные хм
 
Решение
Lua:
function checkip(reg,last,callback)
    local args = {}
    args['headers'] = {['Content-Type'] = 'application/json'}
    asyncHttpRequest('GET', 'http://api.mint-plantation.ru/amogus.php?reg='..reg..'&last='..last, args,
        function(response)
            local result = decodeJson(response.text)
            callback(result)
        end,
        function(err)
            print(err)
        end)
end
            
checkip("reg","last", function(lipinf)
    print(lipinf)
end)

neverlane

t.me/neverlane00
Друг
1,010
1,162
Lua:
function checkip(reg,last,callback)
    local args = {}
    args['headers'] = {['Content-Type'] = 'application/json'}
    asyncHttpRequest('GET', 'http://api.mint-plantation.ru/amogus.php?reg='..reg..'&last='..last, args,
        function(response)
            local result = decodeJson(response.text)
            callback(result)
        end,
        function(err)
            print(err)
        end)
end
            
checkip("reg","last", function(lipinf)
    print(lipinf)
end)
 
  • Влюблен
Реакции: leekyrave

Lamprecht

Новичок
21
1
Lua:
function checkip(reg,last,callback)
    local args = {}
    args['headers'] = {['Content-Type'] = 'application/json'}
    asyncHttpRequest('GET', 'http://api.mint-plantation.ru/amogus.php?reg='..reg..'&last='..last, args,
        function(response)
            local result = decodeJson(response.text)
            callback(result)
        end,
        function(err)
            print(err)
        end)
end
           
checkip("reg","last", function(lipinf)
    print(lipinf)
end)
Тоже такая проблема, но даже это ничего не возвращает)