[Release] Model Blacklist v1.1

I seem to have a problem.

Weapon blacklist works as it should.
When I pull out the blacklisted weapon, it disappears, and I get a message in chat saying “This weapon is blacklisted!”.

However, when I try it with a blacklisted vehicle, it doesn’t despawn and I can still drive/fly it. My chat gets spammed with “This vehicle is blacklisted!” tho.

Any idea of what the problem could be?

Regards
Szymon

This should fix that issue, replace your carblacklist.lua with this:

-- CONFIG --

-- Blacklisted vehicle models
carblacklist = {
	"RHINO"
}

-- CODE --

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

		playerPed = GetPlayerPed(-1)
		if playerPed then
			checkCar(GetVehiclePedIsIn(playerPed, false))

			x, y, z = table.unpack(GetEntityCoords(playerPed, true))
			for _, blacklistedCar in pairs(carblacklist) do
				checkCar(GetClosestVehicle(x, y, z, 100.0, GetHashKey(blacklistedCar), 70))
			end
		end
	end
end)

function checkCar(car)
	if car then
		carModel = GetEntityModel(car)
		carName = GetDisplayNameFromVehicleModel(carModel)

		if isCarBlacklisted(carModel) then
            SetEntityAsMissionEntity(car, true, true)
			DeleteVehicle(car)
			sendForbiddenMessage("This vehicle is blacklisted!")
		end
	end
end

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

	return false
end

Any way you can help out with the weapon blacklist. some of the weapons such as the RPG do not want to blacklist.

This works like a charm :D! Thank you!

Here’s the section for all Weapons hashes i’ve blacklisted if anyone wants them as well. hope it helps :slight_smile:

weaponblacklist = {
"WEAPON_SNIPERRIFLE",
"WEAPON_REMOTESNIPER",
"WEAPON_GRENADELAUNCHER",
"WEAPON_GRENADELAUNCHER_SMOKE",
"WEAPON_RPG",
"WEAPON_PASSENGER_ROCKET",
"WEAPON_AIRSTRIKE_ROCKET",
"WEAPON_STINGER",
"WEAPON_STICKYBOMB",
"WEAPON_DIGISCANNER",
"WEAPON_BRIEFCASE",
"WEAPON_BRIEFCASE_02",
"WEAPON_VEHICLE_ROCKET",
"WEAPON_BARBED_WIRE",
"WEAPON_DROWNING",
"WEAPON_DROWNING_IN_VEHICLE",
"WEAPON_BLEEDING",
"WEAPON_ELECTRIC_FENCE",
"WEAPON_FIRE",
"WEAPON_GUSENBERG",
"WEAPON_FIREWORK",
"WEAPON_MARKSMANRIFLE",
"WEAPON_HOMINGLAUNCHER",
"WEAPON_PROXMINE",
"WEAPON_RAILGUN",
"WEAPON_AIR_DEFENCE_GUN",
"WEAPON_AUTOSHOTGUN",
"WEAPON_COMPACTLAUNCHER",
"WEAPON_PIPEBOMB",
"VEHICLE_WEAPON_ROTORS",
"VEHICLE_WEAPON_TANK",
"VEHICLE_WEAPON_SPACE_ROCKET",
"VEHICLE_WEAPON_PLANE_ROCKET",
"VEHICLE_WEAPON_PLAYER_LAZER",
"VEHICLE_WEAPON_PLAYER_LASER",
"VEHICLE_WEAPON_PLAYER_BULLET",
"VEHICLE_WEAPON_PLAYER_BUZZARD",
"VEHICLE_WEAPON_PLAYER_HUNTER",
"VEHICLE_WEAPON_ENEMY_LASER",
"VEHICLE_WEAPON_SEARCHLIGHT",
"VEHICLE_WEAPON_RADAR",
"VEHICLE_WEAPON_TURRET_INSURGENT",
"VEHICLE_WEAPON_TURRET_TECHNICAL",
"VEHICLE_WEAPON_NOSE_TURRET_VALKYRIE",
"VEHICLE_WEAPON_PLAYER_SAVAGE",
"VEHICLE_WEAPON_TURRET_LIMO",
"VEHICLE_WEAPON_CANNON_BLAZER",
"VEHICLE_WEAPON_TURRET_BOXVILLE",
"VEHICLE_WEAPON_RUINER_BULLET",
"PICKUP_WEAPON_BULLPUPSHOTGUN",
"PICKUP_WEAPON_ASSAULTSMG",
"PICKUP_VEHICLE_WEAPON_ASSAULTSMG",
"PICKUP_WEAPON_PISTOL50",
"PICKUP_VEHICLE_WEAPON_PISTOL50",
"PICKUP_AMMO_BULLET_MP",
"PICKUP_AMMO_MISSILE_MP",
"PICKUP_AMMO_GRENADELAUNCHER_MP",
"PICKUP_WEAPON_ASSAULTRIFLE",
"PICKUP_WEAPON_CARBINERIFLE",
"PICKUP_WEAPON_ADVANCEDRIFLE",
"PICKUP_WEAPON_MG",
"PICKUP_WEAPON_COMBATMG",
"PICKUP_WEAPON_SNIPERRIFLE",
"PICKUP_WEAPON_HEAVYSNIPER",
"PICKUP_WEAPON_MICROSMG",
"PICKUP_WEAPON_SMG",
"PICKUP_ARMOUR_STANDARD",
"PICKUP_WEAPON_RPG",
"PICKUP_WEAPON_MINIGUN",
"PICKUP_HEALTH_STANDARD",
"PICKUP_WEAPON_PUMPSHOTGUN",
"PICKUP_WEAPON_SAWNOFFSHOTGUN",
"PICKUP_WEAPON_ASSAULTSHOTGUN",
"PICKUP_WEAPON_GRENADE",
"PICKUP_WEAPON_MOLOTOV",
"PICKUP_WEAPON_SMOKEGRENADE",
"PICKUP_WEAPON_STICKYBOMB",
"PICKUP_WEAPON_PISTOL",
"PICKUP_WEAPON_COMBATPISTOL",
"PICKUP_WEAPON_APPISTOL",
"PICKUP_WEAPON_GRENADELAUNCHER",
"PICKUP_MONEY_VARIABLE",
"PICKUP_WEAPON_STUNGUN",
"PICKUP_WEAPON_FIREEXTINGUISHER",
"PICKUP_WEAPON_PETROLCAN",
"PICKUP_WEAPON_KNIFE",
"PICKUP_WEAPON_NIGHTSTICK",
"PICKUP_WEAPON_HAMMER",
"PICKUP_WEAPON_BAT",
"PICKUP_WEAPON_GolfClub",
"PICKUP_WEAPON_CROWBAR",
"PICKUP_HANDCUFF_KEY",
"PICKUP_CUSTOM_SCRIPT",
"PICKUP_CAMERA",
"PICKUP_PORTABLE_PACKAGE",
"PICKUP_PORTABLE_CRATE_UNFIXED",
"PICKUP_PORTABLE_CRATE_UNFIXED_INCAR",
"PICKUP_MONEY_CASE",
"PICKUP_MONEY_WALLET",
"PICKUP_MONEY_PURSE",
"PICKUP_MONEY_DEP_BAG",
"PICKUP_MONEY_MED_BAG",
"PICKUP_MONEY_PAPER_BAG",
"PICKUP_MONEY_SECURITY_CASE",
"PICKUP_VEHICLE_WEAPON_COMBATPISTOL",
"PICKUP_VEHICLE_WEAPON_APPISTOL",
"PICKUP_VEHICLE_WEAPON_PISTOL",
"PICKUP_VEHICLE_WEAPON_GRENADE",
"PICKUP_VEHICLE_WEAPON_MOLOTOV",
"PICKUP_VEHICLE_WEAPON_SMOKEGRENADE",
"PICKUP_VEHICLE_WEAPON_STICKYBOMB",
"PICKUP_VEHICLE_HEALTH_STANDARD",
"PICKUP_VEHICLE_ARMOUR_STANDARD",
"PICKUP_VEHICLE_WEAPON_MICROSMG",
"PICKUP_VEHICLE_WEAPON_SMG",
"PICKUP_VEHICLE_WEAPON_SAWNOFF",
"PICKUP_VEHICLE_CUSTOM_SCRIPT",
"PICKUP_VEHICLE_MONEY_VARIABLE",
"PICKUP_SUBMARINE",
"PICKUP_HEALTH_SNACK",
"PICKUP_PARACHUTE",
"PICKUP_AMMO_PISTOL",
"PICKUP_AMMO_SMG",
"PICKUP_AMMO_RIFLE",
"PICKUP_AMMO_MG",
"PICKUP_AMMO_SHOTGUN",
"PICKUP_AMMO_SNIPER",
"PICKUP_AMMO_GRENADELAUNCHER",
"PICKUP_AMMO_RPG",
"PICKUP_AMMO_MINIGUN",
"PICKUP_WEAPON_BULLPUPRIFLE",
"PICKUP_WEAPON_BOTTLE",
"PICKUP_WEAPON_SNSPISTOL",
"PICKUP_WEAPON_GUSENBERG",
"PICKUP_WEAPON_HEAVYPISTOL",
"PICKUP_WEAPON_SPECIALCARBINE",
"PICKUP_WEAPON_DAGGER",
"PICKUP_WEAPON_VINTAGEPISTOL",
"PICKUP_WEAPON_FIREWORK",
"PICKUP_WEAPON_MUSKET",
"PICKUP_AMMO_FIREWORK",
"PICKUP_AMMO_FIREWORK_MP",
"PICKUP_PORTABLE_DLC_VEHICLE_PACKAGE",
"PICKUP_WEAPON_HEAVYSHOTGUN",
"PICKUP_WEAPON_MARKSMANRIFLE",
"PICKUP_GANG_ATTACK_MONEY",
"PICKUP_WEAPON_PROXMINE",
"PICKUP_WEAPON_HOMINGLAUNCHER",
"PICKUP_AMMO_HOMINGLAUNCHER",
"PICKUP_WEAPON_FLAREGUN",
"PICKUP_AMMO_FLAREGUN",
"PICKUP_WEAPON_COMBATPDW",
"PICKUP_WEAPON_KNUCKLE",
"PICKUP_WEAPON_MARKSMANPISTOL",
}
1 Like

I had a big problem where if I would spawn a blacklisted vehicle, it would delete but then spam the chat for everyone around the car that it is blacklisted. I just disabled the whole chat thing but It would be nice if it could be fixed.

I have the RPG and Grenade Launcher blacklisted but they keep spawning in.

can someone help me with this. I cant get it working for somereason

look at my code, just add like me the hash of rpg/ grenade launcher

ive done that but nothing seemed to happen. not even vehicles are blacklisting

Which is the RPG? You have not defined it.

if weapon_rpg doesn’t work use this instead : 2982836145

if model == GetHashKey(blacklistedWeapon) or model == 2210333304  or model == 2982836145 then

or yoou can convert the whole

weaponblacklist{
}

into hashes

What line do I put this on?

function isWeaponBlacklisted(model)
	for _, blacklistedWeapon in pairs(weaponblacklist) do
		if model == GetHashKey(blacklistedWeapon) or model == 2210333304 or model == 2982836145 then
			return true
		end
	end

	return false
end
1 Like

It worked. Thank you.

Would I be able to do this permissions wise, like police cars for police etc.

So currently this script only seems to block certain vehicle models. Anyone know why this is? I’ve tried using the model name and the hash (blimp for example).

So upon further testing it seems all listed vehicles are indeed blacklisted but some of them have to be entered for the system to delete and show the blacklist message while others are deleted upon spawn. Is there a way to get the script so that the listed vehicles are deleted upon spawn and do not have to be entered for the desired affect?

hi ,How do I remove cs_karen_daniels?

Im having a few issues at the moment. My ped blacklist works fine. I have not changed any code only added into the config at the top of each file. But the weapon and vehicle one are just not working at all. Here in this pastebin is both files contents. Any help is appreciated thanks. https://pastebin.com/NRisQM17