Help help lua

skszikri

New member
Joined
Apr 20, 2023
Messages
4
Reaction score
0
local sampev = require 'samp.events'

function waitUntilSampAvailable()
while not isSampAvailable() do
wait(0)
end
end

function main()
waitUntilSampAvailable()
end
function sampev.onServerMessage(colour, msg)
lua_thread.create(function()
local preText = string.match(msg, "%%%s*(.-)%s*has been hit with a tazer")
if preText then
sampSendChat("/cuff " .. preText)
end
end)
end

this work, but i need the /cuff only send when i press the R button
so its gonna be like
function sampev.onServerMessage(colour, msg)
lua_thread.create(function()
local preText = string.match(msg, "%%%s*(.-)%s*has been hit with a tazer")
if preText then
if wasKeyPressed(0x52) then
sampSendChat("/cuff " .. preText)
end
end)
end
any1 help me?
 

Tuzas

Active member
Joined
Nov 1, 2019
Messages
122
Reaction score
70
Location
null
JavaScript:
local sampev = require 'samp.events'
local textfound = false
local nick = ''

function main()
    while not isSampAvailable() do
        wait(0)
    end

    while true do
        wait(0)
        if textfound and wasKeyPressed(0x52) then
            wait(50)
            sampSendChat("/cuff " .. nick)
            textfound = false

        end
    end
end

function sampev.onServerMessage(colour, msg)
    if msg:find("%%%s*(.-)%s*has been hit with a tazer") then
        nick = msg:match("%%%s*(.-)%s*has been hit with a tazer")
        textfound = true
    end
end
 
Top