Дополнить скрипт

Plavluha

Участник
Автор темы
84
22
Доброго времени суток,уважаемые.
Прошу подкорректировать скрипт точнее дополнить.
Этот скрипт записывает в текстовый файл лог откопанных кладов,хотелось бы чтобы он не только записывал их в текстовый файл,но и отсылал в группу ВК по типу вырезки из кладпоца:
Lua:
        if klad then

            for k, v in ipairs(getAllChars()) do

            local res, id = sampGetPlayerIdByCharHandle(v)

            if res then

                x, y, z = getCharCoordinates(v)

                x1, y1, z1 = getCharCoordinates(playerPed)

                if getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < 50 then

                    xui1[#xui1 + 1] = sampGetPlayerNickname(id).."\n"

                    chlenik1 = table.concat(xui1)

                end

            end

        end

        sampAddChatMessage("{808080}КладПоц {ffffff} Нашли клад [ {c21d8e}"..kladnumb.."{FFFFFF} ] Позиция [ {c21d8e} "..param.."{ffffff} ]", -1)

        mymsglol = "Сервер: "..server.."\n\nНашли клад в [ "..gorod.." ]\nКоординаты: "..param.."\n\nИгроки в радиусе 50м: \n"..chlenik1

        msg = urlencode(u8:encode(mymsglol, 'CP1251'))

        requests.get("https://api.vk.com/method/messages.send?v=5.103&access_token="..token_vk.."&chat_id=11&message="..msg.."&group_id="..groupid_vk.."&random_id="..random(1111111111, 9999999999))

        xui1 = {}

        chlenik1 = nil

    end

end
Не знаю как это работает но хочу чтобы мне помогли)
Сообщение по типу:
Был открыт клад.
Корды клада и вопрос из клада.
Могу отблагодарить пару рубликами на сбер)
Попробовал вырезать:
Lua:
local q = require('lib.samp.events')
requests = require 'requests'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

servak = {"185.169.134.3:7777", "185.169.134.4:7777", "185.169.134.43:7777", "185.169.134.44:7777", "185.169.134.45:7777", "185.169.134.5:7777", "185.169.134.59:7777", "185.169.134.61:7777", "185.169.134.107:7777", "185.169.134.109:7777", "185.169.134.166:7777", "185.169.134.171:7777", "185.169.134.172:7777"}
xui1 = {}
chlenik1 = nil
kladnumb = 0
token_vk = "" -- токен группы вк
groupid_vk = "" -- ид группы


local kladdelay = 300


function q.onSendPlayerSync(data)
    if kladik then
        local sync = samp_create_sync_data('spectator')
        sync.position = data.position
        sync.send()
        return false
    end
end
function q.onCreateObject(objectId, data)
    if klad then
        if data.modelId == 2680 then
            xx = data.position.x
            xy = data.position.y
            xz = data.position.z
            vms = math.floor(xx)..", "..math.floor(xy)..", "..math.floor(xz)
            gor = getCityPlayerIsIn(playerPed)
            if gor == 1 then
            gorod = 'Лос Сантосе' 
            end
            if gor == 2 then
            gorod = 'Сан Фиерро' 
            end
            if gor == 3 then
            gorod = 'Лас Вентурасе' 
            end
            if gor == 0 then
            gorod = 'Неизвестным местоположением' 
            end
            msgklad(vms)
        end
    return false
    end
end

function msgklad(param)
        if klad then
            for k, v in ipairs(getAllChars()) do
            local res, id = sampGetPlayerIdByCharHandle(v)
            if res then
                x, y, z = getCharCoordinates(v)
                x1, y1, z1 = getCharCoordinates(playerPed)
                if getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < 50 then
                    xui1[#xui1 + 1] = sampGetPlayerNickname(id).."\n"
                    chlenik1 = table.concat(xui1)
                end
            end
        end
        sampAddChatMessage("{808080}КладПоц {ffffff} Нашли клад [ {c21d8e}"..kladnumb.."{FFFFFF} ] Позиция [ {c21d8e} "..param.."{ffffff} ]", -1)
        mymsglol = "Сервер: "..server.."\n\nНашли клад в [ "..gorod.." ]\nКоординаты: "..param.."\n\nИгроки в радиусе 50м: \n"..chlenik1
        msg = urlencode(u8:encode(mymsglol, 'CP1251'))
        requests.get("https://api.vk.com/method/messages.send?v=5.103&access_token="..token_vk.."&chat_id=11&message="..msg.."&group_id="..groupid_vk.."&random_id="..random(1111111111, 9999999999))
        xui1 = {}
        chlenik1 = nil
    end
end
 

Вложения

  • kladpoc (1).lua
    17.2 KB · Просмотры: 5
  • TTv5byhistor.lua
    29.6 KB · Просмотры: 2