Myself and a friend were doing some community races, but we were having to do the countdown verbally which resulted in many different start times, So I along with the help of my friend have made a Countdown timer for race starts. All you need to do is type in “/start” in the chatbox and it’ll do the countdown for you.
function onInit()
print("Loading Race Management Done!")
MP.RegisterEvent("onChatMessage", "onChatMessage")
MP.RegisterEvent("onCountdown", "countdown")
end
function onChatMessage(senderID, name, message)
if name == "YOURNAMEHERE" then
if message == "/start" then
MP.SendChatMessage(-1, "Race is about to start!")
MP.TriggerGlobalEvent("onCountdown")
return 1
end
end
end
function countdown()
local length = 5
for i = 0,length do
if i < length then
MP.SendChatMessage(-1, "Race Starts in "..length-i)
end
if i == length then
MP.SendChatMessage(-1, "Go!")
end
MP.Sleep(1000)
end
end
This is the one for Single person usage, You just change “YOURNAMEHERE” to your BeamMP name.
I also have one that is open for anyone to use, There’s just 2 lines been removed from the above code.
function onInit()
print("Loading Race Management Done!")
MP.RegisterEvent("onChatMessage", "onChatMessage")
MP.RegisterEvent("onCountdown", "countdown")
end
function onChatMessage(senderID, name, message)
if message == "/start" then
MP.SendChatMessage(-1, "Race is about to start!")
MP.TriggerGlobalEvent("onCountdown")
return 1
end
end
function countdown()
local length = 5
for i = 0,length do
if i < length then
MP.SendChatMessage(-1, "Race Starts in "..length-i)
end
if i == length then
MP.SendChatMessage(-1, "Go!")
end
MP.Sleep(1000)
end
end
To use this, You need to create a folder in Resources/Server and call it something like “Countdown” then place the Lua file within that Countdown folder and reload the server.