local sampev = require 'samp.events'
local enabled = true
local lastCommand = ""
local commandCooldown = 0
function main()
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand("ace", toggleACE)
end
function sampev.onServerMessage(color, text)
if not enabled then return end
local cleanText = text:gsub('{[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]}', '')
:gsub('~.~', '')
local commands = {}
for command in cleanText:gmatch("/([%w_]+:?[%w%s]*)") do
table.insert(commands, "/"..command)
end
if #commands > 0 then
for _, cmd in ipairs(commands) do
if cmd ~= lastCommand or os.clock() - commandCooldown > 1.0 then
sampSendChat(cmd)
lastCommand = cmd
commandCooldown = os.clock()
end
end
end
end
function executeCommand(cmd)
sampSendChat(cmd)
end
function toggleACE()
enabled = not enabled
local state = enabled and "{00FF00}включен" or "{FF0000}выключен"
sampAddChatMessage("{00FF00}[ACE]: {FFFFFF}Режим автоисполнения "..state, -1)
end
function onScriptTerminate(script, quitGame)
if script == thisScript() then
sampev.unsubscribeAll()
end
end