[Code-Snippet] No Weapons From Policecars

Hello, this little code makes all weapons be deleted if you jump in a car, you cant bug it to get a weapon or something.

Citizen.CreateThread(function()
	while true do Citizen.Wait(100)
		if IsPedInAnyPoliceVehicle(GetPlayerPed(-1), -1) or IsPedInAnyHeli(GetPlayerPed(-1)) then
			DisablePlayerVehicleRewards(GetPlayerPed(-1))
		end
	end
end)

Just add this to client.lua in policejob or any other script.

5 Likes

maybe add a table and some checks so that vehicle rewards will be disabled only on certain cars

Ye would be possible, this is just a quick fix, I dont know any other vehicles that you would want your people to get weapons from :confused:

1 Like

Edited it only for police vehicles.

1 Like
local whitelistedmodels = {
    "modelnamehere"
}
Citizen.CreateThread(function()
    while true do 
        Citizen.Wait(0)
        if IsPedInAnyVehicle(PlayerPedId(), true) and not isCarBlacklisted(GetVehiclePedIsUsing(PlayerPedId())) then
            DisablePlayerVehicleRewards(PlayerPedId())
        end
	end
end)

function isCarBlacklisted(model)
	for _, blacklistedCar in pairs(whitelistedmodels) do
		if model == GetHashKey(blacklistedCar) then
			return false
		end
	end

	return true
end

didn’t have time to try this, so it may or may not work, but this way you should able to exclude the models you wanna get rewards from

model names may have to be in all caps

(also the function is partially from @pongo1231 's vehicle blacklist script, thank you @pongo1231 :heart: )

Or you could always just remove it from the VEHICLES.META file. That’d be pretty simple as well

Might want to simplify this by just checking for emergency class instead. Unless you want some cars to still give rewards…

2 Likes

can u show us how do we do that?