[Lua][ESX] IamAdren's TollBooth Script

IamAdren's Toll Booth Script

This script is a EZ-Pass type of system to your server.

Dowload
Documentation

Features

  • EZ-Pass type of payment system.
  • If a user passes through the toll with a “unregistered” or “stolen” vehicle it will alert law enforcement.
  • Discord Bot with stats command.
  • 2 Included Toll Booth YMAP’s

Dependencies

  • ESX (Version 1.0)

How to install the Script

  1. Import tollBooth.sql to your database
  2. Add this in your server.cfg:
ensure tollBooth
  1. Edit the config.lua file to your liking

How to install the Discord Bot

  1. Create a bot account at Discord Developer Portal and grab the token.
  2. Add your token into config.js
  3. Add you MySQL server connection details into config.js
  4. CD into your directory
  5. Type npm i
  6. Type node index.js

Screenshots / Preview

Route 1 Toll Booth



Highway 1 Toll Booth



Regular Payment Example



Failure to pay police alert

Stolen/Unregistered vehicle passing through the toll police alert

Credits

Flashing Light Effect - GitHub - P4NDAzzGaming/esx_speedcamera

8 Likes

hey guys having issues of this not working i cant get a discord bot to work with it

This is actually pretty cool. Does it automatically waive the tolls for emergency vehicles?

Yep here in the config, https://github.com/IamAdren/TollBooth/blob/master/FiveM%20Script/config.lua#L18

Whats your error? Or whats your problem

1 toll booth only shows up and dont know what you mean by 1. CD into your directory
2. Type npm i
3. Type node index.js
also i have made the bot its offline dont no why

So you need Node JS #1, #2 By CD into your directory I mean drag the files to your desktop and open a command prompt into the folder.

guys because i dont know a lot about servers i want to ask you something.I put esx delboys in my esx resources and i write ensure esx delboys in my server.cfg but it doesnt worked.Can you tell me what i must to do?

https://i.imgur.com/SuvRkKj.jpg who is the ymap

can you help me guys

Am i missing something. Where is the download link. I just see the speedcamera one

Hi, i add simply fix because if u pass the zone in low speed. the message of stolen vehicle and flash spam, this is the same with the pay function, if u pass with low speed u pay 4x instead of 1.

ESX = nil
local blip
local speedZone
local speedzones = {}
local CurrentAction = nil
local HasAlreadyEnteredMarker = false
local LastZone = nil
local PlayerData = {}

-- CRIS ANTI SPAM PAGO

local hadetectado = false

-- CRIS ANTI SPAM DETECTADO

local esrobado = false



Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end

	while not ESX.GetPlayerData().job do
		Citizen.Wait(10)
	end

	ESX.PlayerData = ESX.GetPlayerData()
	PlayerData = ESX.GetPlayerData()

	for k,v in ipairs(Config.BlipZones) do
		local blip = AddBlipForCoord(v.x, v.y, v.z)

		if true== true then
			SetBlipHighDetail(blip, true)
			SetBlipSprite (blip, Config.Blips.Sprite)
			SetBlipScale	(blip, Config.Blips.Scale)
			SetBlipColour (blip, Config.Blips.Color)
			SetBlipAsShortRange(blip, true)

			BeginTextCommandSetBlipName("STRING")
			AddTextComponentString(Config.Blips.Name)
			EndTextCommandSetBlipName(blip)
		end

		if v.speed == true then
			TriggerServerEvent('matt_ZoneActivated', 'New Tollbooth', Config.Speed, Config.Radius, v.x, v.y, v.z)
		end
	end
end)

RegisterNetEvent('matt_Zone')
AddEventHandler('matt_Zone', function(speed, radius, x, y, z)
	speedZone = AddSpeedZoneForCoord(x, y, z, radius, speed, false)
	table.insert(speedzones, {x, y, z, speedZone, blip})
end)

AddEventHandler('matt_hasEnteredMarker', function (zone)
  	if zone ~= nil then
    	CurrentAction = 'toll'
  	end
end)

AddEventHandler('matt_hasExitedMarker', function (zone)
	CurrentAction = nil
end)


-- ANTISPAM PAGO

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if hadetectado == true then
            Citizen.Wait(5000)
            hadetectado = false
        end
    end
end)

-- ANTISDOWN

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if esrobado == true then
            Citizen.Wait(5000)
            esrobado = false
        end
    end
end)


Citizen.CreateThread(function (source)
	while true do
		Citizen.Wait(450)

		local playerPed = GetPlayerPed(-1)
		local coords = GetEntityCoords(playerPed)

		if CurrentAction ~= nil then
			if IsPedInAnyVehicle(playerPed, false) then
				local ped = GetPlayerPed( -1 )
				local pos = GetEntityCoords( ped )
				local vehicle = GetVehiclePedIsIn( ped, false )
				local vehicleP = GetVehicleNumberPlateText(vehicle)

				for k,v in ipairs(Config.BlipZones) do
					if GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < 125 then
						ESX.TriggerServerCallback('matt_vehicleStatus', function(status)
							print(v.id)
							if status == true then
								ESX.TriggerServerCallback('matt_PayToll', function(ret)
									if ret == true and hadetectado == false then
                                        ESX.ShowNotification("<b>Notificacion de peaje:</b> Pagado ~g~125$")
                                        hadetectado = true
									else
                                        TriggerServerEvent('matt_alert', vehicleP, 'failure', v.name, v.id)
                                        hadetectado = true
									end
								end, Config.TollPrice, v.id)
							elseif status == false and esrobado == false then
								--local mugshot, mugshotStr = ESX.Game.GetPedMugshot(GetPlayerPed(-1))
								if GetVehicleClass(vehicle) == 18 then
									if Config.IgnoreEmergencyVehicles then
										return
									end
								else
									TriggerServerEvent('matt_alert', vehicleP, 'stolen', v.name, v.id)
								end
								if Config.useCameraSound == true then
									TriggerServerEvent("InteractSound_SV:PlayOnSource", "speedcamera", 0.5)
									esrobado = true
								end
								if Config.useCameraFlash == true then
									TriggerEvent('matt_openGUI')
									Citizen.Wait(100)
									TriggerEvent('matt_closeGUI')
									esrobado = true
								end
							end
						end, vehicleP)
					end
				end
			end
		end
	end
end)

Citizen.CreateThread(function ()
	while true do
		Wait(0)

		local coords = GetEntityCoords(GetPlayerPed(-1))
		local isInMarker = false
		local currentZone = nil

		for k,v in ipairs(Config.Zones) do
			if(GetDistanceBetweenCoords(coords,v.x, v.y, v.z, true) < 8) then
				isInMarker  = true
				currentZone = k

				if Config.DevMode then
					DrawMarker(21, v.x, v.y, v.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.5, 1.5, 1.0, 255, 255, 255, 255, false, true, 2, false, false, false, false)
				end
			end
		end

		if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
			HasAlreadyEnteredMarker = true
			LastZone = currentZone
			TriggerEvent('matt_hasEnteredMarker', currentZone, Location)
		end

		if not isInMarker and HasAlreadyEnteredMarker then
			HasAlreadyEnteredMarker = false
			TriggerEvent('matt_hasExitedMarker', LastZone)
		end

	end
end)

RegisterNetEvent('matt_openGUI')
AddEventHandler('matt_openGUI', function()
    SetNuiFocus(false,false)
    SendNUIMessage({type = 'openSpeedcamera'})
end)

RegisterNetEvent('matt_closeGUI')
AddEventHandler('matt_closeGUI', function()
    SendNUIMessage({type = 'closeSpeedcamera'})
end)

Copy and paste all in main.lua (CLIENT SIDE)

What does this do?

Great script brother

same for me, no Toll Booth here …

Also telling me my car is stolen, but it isn’t. Car is listed in owned_vehicles …

thanks man.

Its a custom release by VerpiMoDz’s.

could u explaine why he tells me i dont own this vehicle?

Sorry updated.

1 Like

Thank you sir