[RELEASE] TrafficAlert - A Message Broadcast System [UPDATED!]

Tonight I’m Releasing my simple little script called TrafficAlert

This simple script provides RP servers with a simple script (mostly for Police or Dispatchers) to issue Traffic and other style alerts to all players in what basically is a text message.

You may have seen something like this on the DOJ clan’s server and i will admit this is inspired from their design, but this script is in fact made by me.

Installation

    • Copy TrafficAlert to your Servers Resources folder
    • Add TrafficAlert to your server.cfg

Download

Usage:

The only command is:  /trafficalert (message)

You dont need to use a keyboard input popup anymore! it works right from the command just type your message out after the /trafficalert command!

Feel free to use this script to learn more about fivem, Rip it apart. do what you will. though I do ask you credit me if you edit and re-release this script :slight_smile:

If you need help with this script or any others please contact me. my discord information is in the Readme!

12 Likes

You are a god, in every sense of the word.

The words of a true hero. :mascot:

6 Likes

Anyone got a list of icons
kinda wanna make this into a mini pack for ads in my server thanks for creating this my hero

1 Like

Yeah I would like some for ads and what not aswell. <- Possible future update?

They are notification Pictures,

you should be able to find a list of most (if not all) from here

2 Likes

How do you make it more than 60 characters?

RegisterNetEvent("TrafficAlert")
AddEventHandler("TrafficAlert",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 60)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncTrafficAlert', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 60)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

Where is 60 in mine, yours should be 20, just change the values.
Sorry about my english,
i hope help you.

1 Like

Thank you man! <3 All good your english is fine!

60 Is not enough for me neither is the Tme I get to see it on the screen or my other officers,And I changed the command to /bolo = Be On The Lookout shorter and less chance of Spelling the command wrong.

---------------------------------
-- Created By Toni Morton      --
-- Please, Leave these credits --
---------------------------------

RegisterNetEvent("TrafficAlert")
AddEventHandler("TrafficAlert",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 200)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 5 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncTrafficAlert', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 200)
		end
		elseif UpdateOnscreenKeyboard() == 4 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayTrafficAlert')
AddEventHandler('DisplayTrafficAlert',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_LS_TOURIST_BOARD", "CHAR_LS_TOURIST_BOARD", true, 1, "~y~Traffic Information:~s~", "");
DrawNotification(false, true);

end)


---------------------------------
-- Created By Toni Morton      --
-- Please, Leave these credits --
---------------------------------

Yup I could have done that better,sorry about that but the values I am using allows for a realistic BOLO, “BOLO” Be on the look out . For a White Ferrari Heading eastbound On Panarama dr 2 White males, armed to the teeth,then it stays onscreen for like 15 seconds so all my guys see it. Great job on the script LOVE it.

just relized my 200 value is not extending it that far,still messing with it.

Love it, set ours to 120 though, works great

Okay so I would like to rework this into an Advertising script… I have everything done but I just need to know how to change the icon picture that appears, how would I go about doing that?

You would go to this code under the client script

end)
end)

RegisterNetEvent('DisplayTrafficAlert')
AddEventHandler('DisplayTrafficAlert',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_LS_TOURIST_BOARD", "CHAR_LS_TOURIST_BOARD", true, 1, "~y~Traffic Information:~s~", "");
DrawNotification(false, true);

end)
 

Then go here https://wiki.■■■■■.net/index.php/Notification_Pictures pick which picture you want to use and replace both of the "CHAR_LS_TOURIST_BOARD"s which whichever picture you choose.

1 Like

If you want a advertisement script heres one i whipped up like 4-5 hours ago

server.lua

---------------------------------
-- Created By Toni Morton      --
-- Please, Leave these credits --
---------------------------------


RegisterServerEvent("SyncTrafficAlert")
AddEventHandler('SyncTrafficAlert', function(inputText)
TriggerClientEvent('DisplayTrafficAlert', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad traffic" then
		CancelEvent()
		TriggerClientEvent("TrafficAlert", from)
	end
end)

RegisterServerEvent("SyncAmmuAd")
AddEventHandler('SyncAmmuAd', function(inputText)
TriggerClientEvent('DisplayAmmuAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad ammunation" then
		CancelEvent()
		TriggerClientEvent("AmmuAd", from)
	end
end)

RegisterServerEvent("SyncFleecaAd")
AddEventHandler('SyncFleecaAd', function(inputText)
TriggerClientEvent('DisplayFleecaAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad fleeca" then
		CancelEvent()
		TriggerClientEvent("FleecaAd", from)
	end
end)

RegisterServerEvent("SyncMBankAd")
AddEventHandler('SyncMBankAd', function(inputText)
TriggerClientEvent('DisplayMBankAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad mazebank" then
		CancelEvent()
		TriggerClientEvent("MBankAd", from)
	end
end)

RegisterServerEvent("SyncLMotorsAd")
AddEventHandler('SyncLMotorsAd', function(inputText)
TriggerClientEvent('DisplayLMotorsAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad lmotors" then
		CancelEvent()
		TriggerClientEvent("LMotorsAd", from)
	end
end)

RegisterServerEvent("SyncSAMotorsAd")
AddEventHandler('SyncSAMotorsAd', function(inputText)
TriggerClientEvent('DisplaySAMotorsAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad samotors" then
		CancelEvent()
		TriggerClientEvent("SAMotorsAd", from)
	end
end)

RegisterServerEvent("SyncLSCustomsAd")
AddEventHandler('SyncLSCustomsAd', function(inputText)
TriggerClientEvent('DisplayLSCustomsAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad lscustoms" then
		CancelEvent()
		TriggerClientEvent("LSCustomsAd", from)
	end
end)

RegisterServerEvent("SyncCabAd")
AddEventHandler('SyncCabAd', function(inputText)
TriggerClientEvent('DisplayCabAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad dcabco" then
		CancelEvent()
		TriggerClientEvent("CabAd", from)
	end
end)

RegisterServerEvent("SyncFBAd")
AddEventHandler('SyncFBAd', function(inputText)
TriggerClientEvent('DisplayFBAd', -1, inputText)
end)


AddEventHandler('chatMessage', function(from, name, message)
	if message == "/ad facebook" then
		CancelEvent()
		TriggerClientEvent("FBAd", from)
	end
end)

---------------------------------
-- Created By Toni Morton      --
-- Please, Leave these credits --
---------------------------------

client.lua

---------------------------------
-- Created By Toni Morton      --
-- Please, Leave these credits --
---------------------------------

RegisterNetEvent("TrafficAlert")
AddEventHandler("TrafficAlert",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncTrafficAlert', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayTrafficAlert')
AddEventHandler('DisplayTrafficAlert',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_LS_TOURIST_BOARD", "CHAR_LS_TOURIST_BOARD", true, 1, "~y~LS Traffic~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("AmmuAd")
AddEventHandler("AmmuAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncAmmuAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayAmmuAd')
AddEventHandler('DisplayAmmuAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_AMMUNATION", "CHAR_AMMUNATION", true, 1, "~y~Ammunation~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("AmmuAd")
AddEventHandler("AmmuAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncAmmuAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayAmmuAd')
AddEventHandler('DisplayAmmuAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_AMMUNATION", "CHAR_AMMUNATION", true, 1, "~y~Ammunation~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("FleecaAd")
AddEventHandler("FleecaAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncFleecaAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayFleecaAd')
AddEventHandler('DisplayFleecaAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", true, 1, "~y~Fleeca Bank~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("MBankAd")
AddEventHandler("MBankAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncMBankAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayMBankAd')
AddEventHandler('DisplayMBankAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_BANK_MAZE", "CHAR_BANK_MAZE", true, 1, "~y~Maze Bank~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("LMotorsAd")
AddEventHandler("LMotorsAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncLMotorsAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayLMotorsAd')
AddEventHandler('DisplayLMotorsAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_CARSITE", "CHAR_CARSITE", true, 1, "~y~Legendary Motorsports~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("SAMotorsAd")
AddEventHandler("SAMotorsAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncSAMotorsAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplaySAMotorsAd')
AddEventHandler('DisplaySAMotorsAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_CARSITE2", "CHAR_CARSITE2", true, 1, "~y~San Andreas Motorsports~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("LSCustomsAd")
AddEventHandler("LSCustomsAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncLSCustomsAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayLSCustomsAd')
AddEventHandler('DisplayLSCustomsAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_LS_CUSTOMS", "CHAR_LS_CUSTOMS", true, 1, "~y~LS Customs~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("CabAd")
AddEventHandler("CabAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncCabAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayCabAd')
AddEventHandler('DisplayCabAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_TAXI", "CHAR_TAXI", true, 1, "~y~Downtown Cab Co.~s~", "");
DrawNotification(false, true);

end)

RegisterNetEvent("FBAd")
AddEventHandler("FBAd",function()
		DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		local input = true
		Citizen.CreateThread(function()
		while input do
		if input == true then
		HideHudAndRadarThisFrame()
		if UpdateOnscreenKeyboard() == 3 then
		input = false
		elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
		TriggerServerEvent('SyncFBAd', inputText)
		input = false
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 150)
		end
		elseif UpdateOnscreenKeyboard() == 2 then
		input = false
		end
		end
		 Citizen.Wait(0)
		 end
			
end)
end)

RegisterNetEvent('DisplayFBAd')
AddEventHandler('DisplayFBAd',function(inputText)

SetNotificationTextEntry("STRING");
AddTextComponentString(inputText);
SetNotificationMessage("CHAR_FACEBOOK", "CHAR_FACEBOOK", true, 1, "~y~Facebook~s~", "");
DrawNotification(false, true);

end)

---------------------------------
-- Created By Toni Morton      --
-- Please, Leave these credits --
---------------------------------

__resource.lua

client_script 'client.lua'
server_script 'server.lua'
1 Like

do i have permission to make this into a advert pack and a 911 script too and then release it with full credits from you

1 Like

Ahhh thanks man! You are great

thanks man, this is super helpful. :slight_smile:

Hey, im trying to add a 247 i got it working but whats the picture code and how would i change it to the 247

1 Like

I actually haven’t figured that out just yet i was wondering the same thing.