[ARZ] Авто пробив (недоделоный)

Timmu

Новичок
Автор темы
10
0
Версия MoonLoader
Другое
Написал код для автопробива, правда, не доделанный.

Суть скрипта в том, чтобы при нажатии клавиши 9 автоматически писались /time и /id в чат того, кто наносит по вам урон.

Убедительная просьба к тем, кто хорошо знает Lua, дописать код, так как он выдает ошибки в консоль.

id:
local sampEvents = require 'lib.samp.events'

local keyToCheck = 57 -- Номер клавиши "9"



function isKeyDown(key)

    return isKeyDown(key)

end



function sampEvents.onSendTakeDamage(playerId, damage, weapon)

    if playerId ~= 65535 and isKeyDown(keyToCheck) then

        local kd = os.clock()

        local id = playerId

        sampSendChat("/time")

        sampSendChat("/id " .. id)

    end

end
 

qdIbp

Автор темы
Проверенный
1,386
1,141
Lua:
local on = require('lib.samp.events')
local damag_status = false

function on.onSendTakeDamage(playerId, damage, weapon)
    if playerId ~= 65535 and damag_status then
        local kd = os.clock()
        local id = playerId
        sampSendChat("/time")
        sampSendChat("/id " .. id)
    end
end

function main()
    repeat wait(0) until isSampAvailable()
    
    while true do
        wait(0)
        if isKeyDown(57) then
            damag_status = not damag_status
        end
    end
end
 

Timmu

Новичок
Автор темы
10
0
Lua:
local on = require('lib.samp.events')
local damag_status = false

function on.onSendTakeDamage(playerId, damage, weapon)
    if playerId ~= 65535 and damag_status then
        local kd = os.clock()
        local id = playerId
        sampSendChat("/time")
        sampSendChat("/id " .. id)
    end
end

function main()
    repeat wait(0) until isSampAvailable()
   
    while true do
        wait(0)
        if isKeyDown(57) then
            damag_status = not damag_status
        end
    end
end
Работает автомотичски, а нужно по нажатию
 
  • Эм
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,386
1,141
Lua:
local on = require('lib.samp.events')
local damag_status = false

function on.onSendTakeDamage(playerId, damage, weapon)
    if playerId ~= 65535 and damag_status then
        local kd = os.clock()
        local id = playerId
        sampSendChat("/time")
        sampSendChat("/id " .. id)
        damag_status = false
    end
end

function main()
    repeat wait(0) until isSampAvailable()
    
    while true do
        wait(0)
        if isKeyDown(57) then
            damag_status = not damag_status
        end
    end
end
 

Timmu

Новичок
Автор темы
10
0
Lua:
local on = require('lib.samp.events')
local damag_status = false

function on.onSendTakeDamage(playerId, damage, weapon)
    if playerId ~= 65535 and damag_status then
        local kd = os.clock()
        local id = playerId
        sampSendChat("/time")
        sampSendChat("/id " .. id)
        damag_status = false
    end
end

function main()
    repeat wait(0) until isSampAvailable()
   
    while true do
        wait(0)
        if isKeyDown(57) then
            damag_status = not damag_status
        end
    end
end
спасибо