Помогите со скриптом

SUNDU4OK

Новичок
Автор темы
13
2
Увидел скрипт который мне нужен, без опыта смог вырезать текст на экране, активацию по моей команде, а как сделать активацию/деактивацию по клавише не понял
скрипт ниже
local samp = require 'samp.events'

local state = false
local counter = {}

function main()
while not isSampAvailable() do wait(0) end wait(1)
wait(1300)
sampAddChatMessage("{FFFFFF}[{4b8078}Concept Car Luxury lovec{FFFFFF}] - {4b6980}Loaded",-1)
sampRegisterChatCommand('timet', function()
state = not state
end)

sampRegisterChatCommand('rstream', function()
for _, ped in ipairs(getAllChars()) do
if doesCharExist(ped) and ped ~= PLAYER_PED then
removePlayer(select(2, sampGetPlayerIdByCharHandle(ped)))
end
end
end)

while true do wait(0)
if state then
for k, v in ipairs(counter) do
if (os.clock() - v) > 1.0 then
table.remove(counter, k)
end
end
setGameKeyState(21, 255)
wait(100)
setGameKeyState(21, 0)
end
end
end

function samp.onServerMessage(clr, msg)
if state and msg:find('^%s*Вы были телепортированы администратором (.*)_(.*)') then
state = false
sampAddChatMessage("{FFFFFF}[{4b8078}Concept Car Luxury lovec{FFFFFF}] {257699}Администратор тепнул, скрипт выключен.",-1)
end
if state and msg:find('^%s*Администратор (.*) телепортировал вас на координаты: (.+)') then
state = false
sampAddChatMessage("{FFFFFF}[{4b8078}Concept Car Luxury lovec{FFFFFF}] {257699}Администратор тепнул, скрипт выключен.",-1)
end
end

function samp.onShowDialog(id, style, title, but_1, but_2, text)
if state and id == 25190 or title:find('Concept Car Luxury') then
sampSendDialogResponse(id, 1, nil, nil)
counter[#counter + 1] = os.clock()
return false
end
if state and id == 0 then
sampSendDialogResponse(id, 1, nil, nil)
counter[#counter + 1] = os.clock()
return false
end
end

function removePlayer(id)
local bs = raknetNewBitStream()
raknetBitStreamWriteInt16(bs, id)
raknetEmulRpcReceiveBitStream(163, bs)
raknetDeleteBitStream(bs)
end
 
  • Злость
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,387
1,143
Так? Активация на K(л)
Lua:
local k = require('vkeys')
local samp = require('samp.events')

local state = false
local counter = {}

function main()
    while not isSampAvailable() do wait(1300) end
        sampAddChatMessage("{FFFFFF}[{4b8078}Concept Car Luxury lovec{FFFFFF}] - {4b6980}Loaded",-1)
        sampRegisterChatCommand('timet', function()
            state = not state
            sampAddChatMessage(state and 'Активирован' or 'Деактивирован',-1)
        end)

        sampRegisterChatCommand('rstream', function()
            for _, ped in ipairs(getAllChars()) do
                if doesCharExist(ped) and ped ~= PLAYER_PED then
                    removePlayer(select(2, sampGetPlayerIdByCharHandle(ped)))
                end
            end
        end)

    while true do wait(0)
        if wasKeyPressed(k.VK_K) then
            state = not state
            sampAddChatMessage(state and 'Активирован' or 'Деактивирован',-1)
        end
        if state then
            for k, v in ipairs(counter) do
                if (os.clock() - v) > 1.0 then
                    table.remove(counter, k)
                end
            end
            setGameKeyState(21, 255)
                wait(100)
            setGameKeyState(21, 0)
        end
    end
end

function samp.onServerMessage(clr, msg)
    if state then
        if msg:find('^%s*Вы были телепортированы администратором (.*)_(.*)') or msg:find('^%s*Администратор (.*) телепортировал вас на координаты: (.+)') then
            state = false
            sampAddChatMessage("{FFFFFF}[{4b8078}Concept Car Luxury lovec{FFFFFF}] {257699}Администратор тепнул, скрипт выключен.",-1)
        end
    end
end

function samp.onShowDialog(id, style, title, b1, b2, text)
    if state then
        if id == 0 or id == 25190 or title:find('Concept Car Luxury') then
            sampSendDialogResponse(id, 1, nil, nil)
            counter[#counter + 1] = os.clock()
            return false
        end
    end
end

function removePlayer(id)
    id = tonumber( id )
    if id ~= nil then
        local bs = raknetNewBitStream()
        raknetBitStreamWriteInt16(bs, id)
        raknetEmulRpcReceiveBitStream(163, bs)
        raknetDeleteBitStream(bs)
    end
end