- 3
- 0
Форматирование кода
Lua:
local sampev = require 'lib.samp.events'
local mom = false
local isKeyPressed = false
local keyPressTimer = 0
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(0) end
sampAddChatMessage("[PIDR] {00FF00}Script loaded. Use /pidr to toggle.", -1)
sampRegisterChatCommand("pidr", togglePidr)
while true do
wait(0)
-- удерживаем N 100 мс
if isKeyPressed then
keyPressTimer = keyPressTimer + 1
if keyPressTimer == 1 then
setVirtualKeyDown(0x4E, true) -- Нажать N
elseif keyPressTimer == 6 then
setVirtualKeyDown(0x4E, false) -- Отпустить N
isKeyPressed = false
keyPressTimer = 0
end
end
end
end
function togglePidr()
mom = not mom
local text = mom and "{00FF00}pidr on" or "{FF0000}pidr off"
sampAddChatMessage("[PIDR] " .. text, -1)
end
function sampev.onServerMessage(color, msg)
if mom then
local cleanMsg = msg:gsub("{........}", ""):lower()
if cleanMsg:find("пидр иди сюда") then
isKeyPressed = true
keyPressTimer = 0
end
end
end
суть, чтобы при появление нужного текста в чате нажимало на N,
хз в чем ошибка
Последнее редактирование модератором: