fixed thanks brotherYou or whoever created this, are registering command inside while true loop
its a mod which types /captureturf the tog command is /tcap why this spamming on my sampfuncs
cant fix that?You or whoever created this, are registering command inside while true loop
I couldn't ignore how terrible that code wasfixed thanks brother
-- AutoCap Script
-- Author: Dallaz
-- Load necessary module
require "lib.sampfuncs"
local sampev = require "lib.samp.events"
local captog = false
function main()
-- Wait for SA-MP to become available
while not isSampAvailable() do
wait(100)
end
-- Display instructions to the user
sampAddChatMessage("{0000FF}~~~~~~ [LUA] AutoCapture ~~~~~~ {FFFFFF}/tcap to start spam and /stopcap to stop", -1)
-- Register commands
sampRegisterChatCommand("tcap", toggleCapture)
-- Main loop
while true do
wait(0)
-- Check if capture toggle is active
if captog then
-- Spam capture command while toggle is active
sampSendChat("/captureturf")
wait(2500)
end
end
end
-- Function to toggle capture spam
function toggleCapture()
captog = not captog
sampAddChatMessage(captog and "{FFFF00}Starting capture spam..." or "{FFFF00}Stopping capture spam...", -1)
end
-- Event handler for server messages
function sampev.onServerMessage(color, text)
if text:find("The time is now") then
lua_thread.create(function()
wait(100) -- introduced a delay, to prevent timing issues
sampSendChat("/captureturf")
wait(100)-- introduced a delay, to prevent timing issues
sampSendChat("/capture")
end)
end
end
tyI couldn't ignore how terrible that code was
Heres the same code, but revisioned
JavaScript:-- AutoCap Script -- Author: Dallaz -- Load necessary module require "lib.sampfuncs" local sampev = require "lib.samp.events" local captog = false function main() -- Wait for SA-MP to become available while not isSampAvailable() do wait(100) end -- Display instructions to the user sampAddChatMessage("{0000FF}~~~~~~ [LUA] AutoCapture ~~~~~~ {FFFFFF}/tcap to start spam and /stopcap to stop", -1) -- Register commands sampRegisterChatCommand("tcap", toggleCapture) -- Main loop while true do wait(0) -- Check if capture toggle is active if captog then -- Spam capture command while toggle is active sampSendChat("/captureturf") wait(2500) end end end -- Function to toggle capture spam function toggleCapture() captog = not captog sampAddChatMessage(captog and "{FFFF00}Starting capture spam..." or "{FFFF00}Stopping capture spam...", -1) end -- Event handler for server messages function sampev.onServerMessage(color, text) if text:find("The time is now") then lua_thread.create(function() wait(100) -- introduced a delay, to prevent timing issues sampSendChat("/captureturf") wait(100)-- introduced a delay, to prevent timing issues sampSendChat("/capture") end) end end