Вытянуть Id игрока из чата и проверить наличие в стриме

Plavluha

Участник
Автор темы
84
22
Есть сообщения в чат:
qwertyuiop Sam_Mason[228] qwertyu
qwertyuiop Farmer[229] qwertyu
qwertyuiop Conor[227] qwertyu
Как из них всех вытянуть id и проверить на наличие в зоне стрима,если есть то оповестить в чат
 
Решение
Есть сообщения в чат:
qwertyuiop Sam_Mason[228] qwertyu
qwertyuiop Farmer[229] qwertyu
qwertyuiop Conor[227] qwertyu
Как из них всех вытянуть id и проверить на наличие в зоне стрима,если есть то оповестить в чат
Lua:
local samp = require('samp.events')
local id_player = ''
function samp.onServerMessage(color, text)
    if text:find('qwertyuiop .+%[%d+%] qwertyu') then
        id_player = text:match('qwertyuiop .+%[(%d+)%] qwertyu') -- Получим ИД игрока
        if stream_check_id(id_player) then
            print('Игрок под ID: ' .. id_player .. 'сейчас в зоне стрима')
        end
    end
end

function stream_check_id(arg)
    for k, v in pairs(getAllChars()) do
        if doesCharExist(v) then
            local result, id =...

Rice.

https://t.me/riceoff
Модератор
1,689
1,433
Есть сообщения в чат:
qwertyuiop Sam_Mason[228] qwertyu
qwertyuiop Farmer[229] qwertyu
qwertyuiop Conor[227] qwertyu
Как из них всех вытянуть id и проверить на наличие в зоне стрима,если есть то оповестить в чат
Lua:
local samp = require('samp.events')
local id_player = ''
function samp.onServerMessage(color, text)
    if text:find('qwertyuiop .+%[%d+%] qwertyu') then
        id_player = text:match('qwertyuiop .+%[(%d+)%] qwertyu') -- Получим ИД игрока
        if stream_check_id(id_player) then
            print('Игрок под ID: ' .. id_player .. 'сейчас в зоне стрима')
        end
    end
end

function stream_check_id(arg)
    for k, v in pairs(getAllChars()) do
        if doesCharExist(v) then
            local result, id = sampGetPlayerIdByCharHandle(v)
            if id == tonumber(arg) then
                return true
            end
        end
    end
    return false
end
 

Plavluha

Участник
Автор темы
84
22
Lua:
local samp = require('samp.events')
local id_player = ''
function samp.onServerMessage(color, text)
    if text:find('qwertyuiop .+%[%d+%] qwertyu') then
        id_player = text:match('qwertyuiop .+%[(%d+)%] qwertyu') -- Получим ИД игрока
        if stream_check_id(id_player) then
            print('Игрок под ID: ' .. id_player .. 'сейчас в зоне стрима')
        end
    end
end

function stream_check_id(arg)
    for k, v in pairs(getAllChars()) do
        if doesCharExist(v) then
            local result, id = sampGetPlayerIdByCharHandle(v)
            if id == tonumber(arg) then
                return true
            end
        end
    end
    return false
end
Как реализовать на нескольких сразу
 

Rice.

https://t.me/riceoff
Модератор
1,689
1,433
qwertyuiop Sam_Mason(228) qwertyu
qwertyuiop Farmer(229) qwertyu
qwertyuiop Conor(227) qwertyu
=>
/hi 228
/hi 229
/hi 227
Lua:
local samp = require('samp.events')
local id_player = ''
function samp.onServerMessage(color, text)
    if text:find('qwertyuiop .+%[%d+%] qwertyu') then
        id_player = text:match('qwertyuiop .+%[(%d+)%] qwertyu') -- Получим ИД игрока
        if stream_check_id(id_player) then
            sampSendChat('/hi '..id_player)
        end
    end
end