From 4ce7e24391bbbf99c3fa970ef29952b2e43f87da Mon Sep 17 00:00:00 2001 From: rubin Date: Tue, 11 Oct 2022 21:00:43 +0300 Subject: [PATCH] initial commit --- cannabis-keys.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 cannabis-keys.lua diff --git a/cannabis-keys.lua b/cannabis-keys.lua new file mode 100644 index 0000000..8011e70 --- /dev/null +++ b/cannabis-keys.lua @@ -0,0 +1,55 @@ +script_author('cannabis-keys') +script_author('rubin') +sampev = require 'lib.samp.events' + +txd_keys = { + { "LD_BEAT:up", 38, -1 }, + { "LD_BEAT:down", 40, -1 }, + { "LD_BEAT:left", 37, -1 }, + { "LD_BEAT:right", 39, -1 } +} + +function main() + if not isSampLoaded() or not isSampfuncsLoaded() then return end + while not isSampAvailable() do wait(100) end + while true do + wait(0) + for i = 1, #txd_keys do + if txd_keys[i][2] ~= -1 and wasKeyPressed(txd_keys[i][2]) then + sampSendClickTextdraw(txd_keys[i][3]) + end + end + end +end + +function sampev.onShowTextDraw(id, data) + if data.text:find("LD_BEAT") then + for i = 1, #txd_keys do + if data.text:find(txd_keys[i][1]) then + txd_keys[i][3] = id + end + end + end +end + +function sampev.onTextDrawHide(id) + for i = 1, #txd_keys do + if id == txd_keys[i][3] then + txd_keys[i][3] = -1 + end + end +end + +function sampev.onTextDrawSetString(id, text) + if text:find("LD_BEAT") then + for i = 1, #txd_keys do + if id == txd_keys[i][3] then + if text:find(txd_keys[i][1]) then + txd_keys[i][3] = id + else + txd_keys[i][3] = -1 + end + end + end + end +end \ No newline at end of file