[Release][FX] Police Object Spawner

Requested by @Dillon_Dobusz
You can spawn 3 different types of barriers.

Installation
Like any other simple script.

Config
Open server.lua
Don’t touch the code. Look at the Config.

everyoneAllowed - It is False at default.

  • True - Everyone is allowed to use the command, you do not need to add anyone to the allowed table
  • False - You need to add people to the allowed table to give them permission to use the table

allowed - Enter your steam IDs and IPs. DO NOT forget the commas and do not add a comma at the end.

Usage
/cone - spawns traffic cone
/sbarrier - spawns small barrier (orange and white)
/barrier - spawns blue barrier

Download
V 1.0
PolObjSpawner V1.0.zip (1.7 KB)
V 1.1
PolObjSpawner V1.1.zip (1.9 KB)

Changelog
V 1.0

  • Released

V 1.1

  • Made it so cones spawn with barrier and sbarrier
  • Added it so that you can make it so you can select steamids and ips that can use the command
  • Fixed bugs that stupid me created while tired
  • Fixed rotation issues

Have fun! PM me if you want something made and I’ll see what I can do (I’m still new to scripting). If you need any help or want to know about any functions of my scripts, ask me!

Extra
This would work great in with my delete object gun script! You can delete what you spawn :3 (tazers work well with it)

5 Likes

Will this stop the ai from driving over it?

The small barrier can’t be run over however the other 2 can. I’m looking into a way to fix it. It’s late and I just wanted to push this out for the guy who requested it. I’ll do my best to have it in the next update as I’m still a newb. Heheh. Stay tuned!

Edit: Nevermind, I’m stupid (+ tired). It does stop AI from running it over. Have fun! (The reason I said what I said before was because in testing I had the object set as non-dynamic which caused the AI to run it over but after setting it as dynamic they stopped running it over. I forgot I did this however. Lolz)

So, the cone spawning works perfectly! I love this script. I have encountered one minor bug and something that might be a neat feature for the future.

The bug is that both barriers spawn offset from where your character is facing. I.E if I am facing the lane I want to block, the barrier will spawn offset from where I am looking by about 45 degrees. Also, the cone and blue police barriers do not stop traffic, however I’m not sure if they were intended to.

A feature (That I’m not sure is possible to create or not) is a pick-up or delete command, so that you can easily get rid of the barriers once your scene is clear.

Thanks again for making this script, I absolutely love it and think that the roleplay opportunities are endless.

I made a script like this aswell, i fixed it by putting this:

-- Created by Murtaza
-- Requested by @Dillon_Dobusz on forum.fivem.net

-- Clientside

RegisterNetEvent('murtaza:cone')
RegisterNetEvent('murtaza:sbarrier')
RegisterNetEvent('murtaza:barrier')

AddEventHandler('murtaza:cone', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	
	RequestModel('prop_mp_cone_01')
	
	while not HasModelLoaded('prop_mp_cone_01') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_mp_cone_01', x, y, z-1, true, true, true)
	PlaceObjectOnGroundProperly(object)
	notification('~g~The cone has been placed!')
end)

AddEventHandler('murtaza:sbarrier', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local heading = GetEntityHeading(GetPlayerPed(-1))
	
	RequestModel('prop_mp_barrier_02b')
	
	while not HasModelLoaded('prop_mp_barrier_02b') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_mp_barrier_02b', x, y, z-1, true, true, true)
	PlaceObjectOnGroundProperly(object)
	SetEntityHeading(object, heading)
	notification('~g~The small barrier has been placed!')
end)

AddEventHandler('murtaza:barrier', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local heading = GetEntityHeading(GetPlayerPed(-1))
	
	RequestModel('prop_barrier_work05')
	
	while not HasModelLoaded('prop_barrier_work05') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_barrier_work05', x, y, z-1, true, true, true)
	PlaceObjectOnGroundProperly(object)
	notification('~g~The barrier has been placed!')
	SetEntityHeading(object, heading)
end)

function notification(msg)
	SetNotificationTextEntry("STRING")
	AddTextComponentString(msg)
	DrawNotification(false, false)
end

That should work as i copy pasted the heading stuff from my personal script that i made

Is there away to whitelist this? by steamid really don’t want everyone in the sever spawning stuff in you know?

-- Created by Murtaza
-- Requested by @Dillon_Dobusz on forum.fivem.net

-- Serverside
identifiers = {
	"steam:01010101010101010",
}
AddEventHandler('chatMessage', function(source, n, msg)
	local msg = string.lower(msg)
	
	if msg == '/cone' then
		CancelEvent()
		for i = 1, #identifers do
			if GetPlayerIdentifiers(source)[1] == identifiers[i] then
				TriggerClientEvent('murtaza:cone', source)
			end
		end
	elseif msg == '/sbarrier' then
		CancelEvent()
		for i = 1, #identifers do
			if GetPlayerIdentifiers(source)[1] == identifiers[i] then
				TriggerClientEvent('murtaza:sbarrier', source)
			end
		end
	elseif msg == '/barrier' then
		CancelEvent()
		for i = 1, #identifers do
			if GetPlayerIdentifiers(source)[1] == identifiers[i] then
				TriggerClientEvent('murtaza:barrier', source)
			end
		end
	end
end)

Try that, probably will work, idk.

If they are using some type of permissions for police anyway, would it be easier to just restrict use of this to that permission level?

hi @murfasa thx for your share

1 question for you
its possible to rotate prop ? for me its work so its all the same side

This actually does not do anything.

Player = GetPlayerPed(-1)

RegisterNetEvent("sasr:Cone")
AddEventHandler("sasr:Cone", function()     
	x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
    local object = CreateObject("prop_mp_cone_01", x, y, z-1.90, true, true, true)    
    PlaceObjectOnGroundProperly(object) 
end)

RegisterNetEvent("sasr:barrier")
AddEventHandler("sasr:barrier", function()   
	x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local heading = GetEntityHeading(GetPlayerPed(-1))
    local object = CreateObject("prop_mp_barrier_02b", x, y, z-1.90, true, true, true)    
    PlaceObjectOnGroundProperly(object)
    SetEntityHeading(object, heading)
end)

RegisterNetEvent("sasr:barrier2")
AddEventHandler("sasr:barrier2", function()   
	x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local heading = GetEntityHeading(GetPlayerPed(-1))
    local object = CreateObject("prop_barrier_wat_03b", x, y, z-1.90, true, true, true)    
    PlaceObjectOnGroundProperly(object)
    SetEntityHeading(object, heading)
end)

This is my script to its entirety, try figure out what you need from it since im busy making other things for my server

Fixed the rotating.

RegisterNetEvent('murtaza:cone')
RegisterNetEvent('murtaza:sbarrier')
RegisterNetEvent('murtaza:barrier')

AddEventHandler('murtaza:cone', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	
	RequestModel('prop_mp_cone_01')
	
	while not HasModelLoaded('prop_mp_cone_01') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_mp_cone_01', x, y, z-1, true, true, true)
	PlaceObjectOnGroundProperly(object)
	notification('~g~The cone has been placed!')
end)

AddEventHandler('murtaza:sbarrier', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local heading = GetEntityHeading(GetPlayerPed(-1))
	
	RequestModel('prop_mp_barrier_02b')
	
	while not HasModelLoaded('prop_mp_barrier_02b') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_mp_barrier_02b', x, y, z-1, true, true, true)
	local heading = GetEntityHeading(GetPlayerPed(-1))
	SetEntityHeading(cone, heading)
	PlaceObjectOnGroundProperly(cone)
	notification('~g~The small barrier has been placed!')
end)

AddEventHandler('murtaza:barrier', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local heading = GetEntityHeading(GetPlayerPed(-1))
	
	RequestModel('prop_barrier_work05')
	
	while not HasModelLoaded('prop_barrier_work05') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_barrier_work05', x, y, z-1, true, true, true)
	PlaceObjectOnGroundProperly(cone)
	SetEntityHeading(cone, heading)
	notification('~g~The barrier has been placed!')
end)

function notification(msg)
	SetNotificationTextEntry("STRING")
	AddTextComponentString(msg)
	DrawNotification(false, false)
end
1 Like

can you show us a demo video pls?

Can someone please link this up to vRP for Police <3

thx @PeliPorukkaRP its work fine :wink:

do you have a version for police only ?
work with jobs id exemple ?

#work on LaLife and police menu :slight_smile:

Changelog
V 1.1

  • Made it so cones spawn with barrier and sbarrier
  • Added it so that you can make it so you can select steamids and ips that can use the command
  • Fixed bugs that stupid me created while tired
  • Fixed rotation issues
1 Like

posible to build a version for jobs ID ?

thx for fix work great

What do you mean for job IDs? Thanks for the feedback! Sorry it wasn’t working too great, made it quickly xD

Next v1.2 will come with a menu …we hope !

1 Like

Fixed rotation issues???