bs-countdown is a FREE versatile, standalone timer resource for RedM. It provides a clean, modern UI for displaying countdown timers and offers a simple API for integration into other scripts. It features customizable titles, configurable time units, and optional in-game commands (for Developers).
- Standalone: No framework dependencies
- Customizable Timers: Start timers with specific amounts, units (seconds, minutes, hours), and optional titles
- Modern UI: Clean, minimalist, and immersive timer display using Vue 3
- Sound Notifications: Optional sound playback when a timer is flashing
- Multiple Timers: Supports display and management of multiple concurrent timers
- Configurable Commands: In-game commands to start and stop timers can be enabled or disabled
- Debug Mode: Verbose logging for easier troubleshooting
- Download or clone the
bs-countdownresource - Place the
bs-countdownfolder into your server'sresourcesdirectory - Add
ensure bs-countdownto yourserver.cfgfile - Restart your server or the resource
You can control the timers from your other Lua scripts using these exports.
Example: Starting a timer from another resource
-- client_script.lua in another resource
-- Start a 5-minute timer with a title
local success, timerId = exports['bs-countdown']:startTimer(5, 'min', 'My Custom Event')
if success then
print('Timer started with ID:', timerId)
else
print('Failed to start timer.')
end
-- Start a 30-second timer without a title (will default to "Countdown")
exports['bs-countdown']:startTimer(30, 'sec')Starts a new timer.
- Parameters:
amount(number): The duration of the timer (e.g., 5, 30).unit(string): The unit of time ('sec', 'min', 'hr' - as defined inConfig.TimeUnits).title(string, optional): A custom title for the timer. If nil or empty, defaults to "Countdown".
- Returns:
success(boolean):trueif the timer was started successfully,falseotherwise.timerId(number or nil): A unique ID for the timer if successful, otherwisenil. This ID is used to stop the timer.
Stops an active timer.
- Parameters:
timerId(number): The ID of the timer to stop (obtained fromstartTimer).
- Returns:
success(boolean):trueif the timer was found and stopped,falseotherwise.
Example:
local timerToStop = 1337 -- Assuming timerId 1337 exists
local stopped = exports['bs-countdown']:stopTimer(timerToStop)
if stopped then
print('Timer ' .. timerToStop .. ' stopped.')
else
print('Timer ' .. timerToStop .. ' not found or already stopped.')
endChecks if a specific timer is currently running.
- Parameters:
timerId(number): The ID of the timer to check.
- Returns:
isRunning(boolean):trueif the timer with the given ID is active,falseotherwise.
Example:
local checkTimerId = 1
local isRunning = exports['bs-countdown']:isTimerRunning(checkTimerId)
if isRunning then
print('Timer ' .. checkTimerId .. ' is currently running.')
else
print('Timer ' .. checkTimerId .. ' is not running.')
endGet informed if a timer ends. This triggers if you stop a timer by using stopTimer(timerId) or if it stops naturally by having no time left.
- Callback-Parameters:
timerId(number): The ID of the timer, which ended.wasSuccessful(boolean):trueif the timer ended naturally,falseif stopped early.
Example:
AddEventHandler("bs-countdown:timerEnded", function(timerId, wasSuccessful)
print('Timer ' .. timerId .. ' ended. Was successful? ' .. tostring(wasSuccessful))
end)If Config.EnableCommands is true, the following commands are available:
-
Start Timer:
/<start_command_name> <amount> <unit> [title]- Example:
/timer 10 sec 'Short Break' - Example:
/timer 1 min(title will default to "Countdown")
- Example:
-
Stop Timer:
/<stop_command_name> <timerId>- Example:
/stoptimer 1(stops the timer with ID 1)
- Example:
- Timer Not Appearing: Check the F8 console for Lua errors from
bs-countdownor NUI errors (JavaScript errors). - Commands Not Working: Ensure
Config.EnableCommandsistrueinconfig.lua.
This resource is licensed under the MIT License - see the LICENSE file for details.
