Whitelist Use of Emergency Vehicles


#1

I have played in a few different servers that have a script running that blocks unauthorized users from driving emergency vehicles. It allows them to get into the vehicle but then a prompt states that they are not authorized to access this vehicle.

does anyone know where i could find a script that offers this feature? I have look on the forums and performed a google search, i apologize if i overlooked it.


#2

Just create a thread that gets the job from the player and get if it his on a vehicle and if it is a emergency model, then make the vehicle undrivable… This is easy to do


#3

May not be so “easy to do” for people who don’t know how to script.


#4

@grahamgarn So why you dont help?

I was on the phone, i try to help how i can…

Now i am at home and made something for you…

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    local ped = GetPlayerPed(-1)
    if job ~= 'police' then
      if IsPedInAnyVehicle(ped) then
        if GetVehicleClass( GetVehiclePedIsIn(ped, false ) ) == 18 then
          SetVehicleUndriveable(GetVehiclePedIsUsing(ped), true)
	end
      end
    end
  end
end)

I dont now how you get your jobs, if you use esx, or vrp or even stand alone, so replace this:

if job ~= 'police' then

with your jobs permissions…


#5

thank you very much for your help! i have limited experience with coding and most of what i have done has been picking bits and pieces of multiple scripts to build what i want, i just couldnt figure this out


#6

i use ESX for my jobs


#7

how do you get this for peds not jobs?


#8

I didnt get it, you saying Ped models?

This way:

local skins = {
	"s_m_y_cop_01",
	"s_f_y_cop_01",
	"s_m_y_hwaycop_01",
	"s_m_y_sheriff_01",
	"s_f_y_sheriff_01",
	"s_m_y_ranger_01",
	"s_f_y_ranger_01",
}
function CheckSkin(ped)
	for i = 1, #skins do
		if GetHashKey(skins[i]) == GetEntityModel(ped) then
			return true
		end
	end
	return false
end

Replace:
if job ~= 'police' then
WITH:
CheckSkin(PlayerPedId())


#9

so i dont us ESX or vRP, so i want to make it so i can create a job, like police menu, where they can get whitelisted then drive the menu. so essentially i there is a place near every hospital or fire station where the whitelisted EMS can click e and then select EMT or EMS and they can drive their respective vehicles, i know the Cops-FiveM script doesnt do this but i would love for it, or i make it so people not in cop peds cant drive the cop cars


#10

Yeah, he’s saying ped model


#11

in my case, i want only police officers/EMS to be able to drive their respective vehicles, whether my PED is in uniform or undercover in an unmarked vehicle


#12

and with this, i just place in a .lua file and thats it, like i create my own resource.lua and stuff?


#13

Create a client.lua with the code
And create a __resource.lua with:
client_script 'client.lua'


#14

and then how do i change the different vehicles, surely that would just disable all vehicles undrivable if you arent in a cop uniform?

EDIT: [sorry im not good at this stuff facepalm ]


#15

Class is 18. Are all your vehicles emergency vehicles? Lol.


#16

ah ok. so police vehicles have a class, got it


#17

Change GetVehicleClass
See the reference: https://runtime.fivem.net/doc/reference.html#_0x29439776AAA00A62

Yes surely.

@jcollins012 Just get the job with esx… and you will be okay :stuck_out_tongue_winking_eye:


#18

thanks again for all the help, how could i make this script cover 2 different classes?


#19

GetVehicleClass( GetVehiclePedIsIn(ped, false ) ) == 18 and GetVehicleClass( GetVehiclePedIsIn(ped, false ) ) == 4 then


#20

awesome! thanks, i want to restrict military and emergency vehicles to police job only