Чекер ip в сампе

Shlepa

Потрачен
Автор темы
216
48
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Умоляю, киньте мне рабочий чекер ip в сампе(можно любого формата), что б если ты прописал команду, то он пишет тебе на каком ip в данное время ты сейчас играешь, заранее спасибо)
 
Решение
активация /testt
Lua:
local lanes = require('lanes').configure()

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('testt', function()
        async_http_request("GET", "https://api.ipify.org/?format=json", {params = {name = "test"}}, function(response)
        sampfuncsLog("you ip: "..response.text)
        sampAddChatMessage("you ip: "..response.text, -1)
        end, function(err) print(err) end)
    end)
    wait(-1)
end

function async_http_request(method, url, args, resolve, reject)
    local request_lane = lanes.gen('*', {package = {path = package.path, cpath = package.cpath}}, function()
        local requests = require 'requests'
        local ok, result = pcall(requests.request, method, url...

damag

Женюсь на официантке в моем любимом баре
Проверенный
1,152
1,193
активация /testt
Lua:
local lanes = require('lanes').configure()

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('testt', function()
        async_http_request("GET", "https://api.ipify.org/?format=json", {params = {name = "test"}}, function(response)
        sampfuncsLog("you ip: "..response.text)
        sampAddChatMessage("you ip: "..response.text, -1)
        end, function(err) print(err) end)
    end)
    wait(-1)
end

function async_http_request(method, url, args, resolve, reject)
    local request_lane = lanes.gen('*', {package = {path = package.path, cpath = package.cpath}}, function()
        local requests = require 'requests'
        local ok, result = pcall(requests.request, method, url, args)
        if ok then
            result.json, result.xml = nil, nil -- cannot be passed through a lane
            return true, result
        else
            return false, result -- return error
        end
    end)
    if not reject then reject = function() end end
    lua_thread.create(function()
        local lh = request_lane()
        while true do
            local status = lh.status
            if status == 'done' then
                local ok, result = lh[1], lh[2]
                if ok then resolve(result) else reject(result) end
                return
            elseif status == 'error' then
                return reject(lh[1])
            elseif status == 'killed' or status == 'cancelled' then
                return reject(status)
            end
            wait(0)
        end
    end)
end
 

Вложения

  • getip.lua
    1.5 KB · Просмотры: 13