script_name("click")
script_moonloader(0.21)
require "lib.moonloader"
local hook = require 'lib.samp.events'
tapactive = false
function main()
repeat wait(0) until isSampAvailable()
sampAddChatMessage("click загружен", 0xc0c24e)
sampRegisterChatCommand("click",
function()
tapactive = not tapactive
if tapactive then sampAddChatMessage("ON", 0xc0c24e)
else sampAddChatMessage("OFF", 0xc0c24e) end
end)
wait(-1)
end
-- Функция отвечающая за поиск текстравов Y, N
function hook.onShowTextDraw(textdrawId, data)
if textdrawId > 0 then
if tapactive then
if data.text:find("Y") then
sendKey(64)
elseif data.text:find("N") then
sendKey(128)
end
end
end
end
-- Функция отвечающая за отправку кнопки.
function sendKey(key)
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local data = allocateMemory(68)
sampStorePlayerOnfootData(myId, data)
setStructElement(data, 36, 1, key, false)
sampSendOnfootData(data)
freeMemory(data)
end