The code is working fine.
But only one problem. Me and the players are all lagged. ( FPS FROPS ) 20 FPS…
The owner of this code is: @pongo1231 , i only changed one our two things
I think the problem is the proximity thing.
Can someone try to fix?
-- CONFIG --
-- Blacklisted vehicle models
carblacklist = {
"airbus",
"airtug",
"akuma",
"annihilator",
"armytanker",
"armytrailer",
"armytrailer2",
"asea",
"asea2",
"asterope",
"bagger",
"baletrailer",
"baller",
"baller2",
"barracks",
"barracks2",
"bati",
"bati2",
"benson",
"bfinjection",
"biff",
"bison",
"bison2",
"bison3",
"bjxl",
"blazer",
"blazer2",
"blazer3",
"blimp",
"blista",
"bmx",
"boattrailer",
"bobcatxl",
"bodhi2",
"boxville",
"boxville2",
"boxville3",
"buccaneer",
"buffalo",
"buffalo2",
"bulldozer",
"bullet",
"burrito",
"burrito2",
"burrito3",
"burrito4",
"burrito5",
"bus",
"buzzard",
"buzzard2",
"cablecar",
"caddy",
"caddy2",
"camper",
"carbonizzare",
"carbonrs",
"cargobob",
"cargobob2",
"cargobob3",
"cargoplane",
"cavalcade",
"cavalcade2",
"coach",
"cogcabrio",
"coquette",
"cruiser",
"crusader",
"cuban800",
"cutter",
"daemon",
"dilettante",
"dilettante2",
"dinghy",
"dinghy2",
"dloader",
"docktrailer",
"docktug",
"dominator",
"double",
"dubsta",
"dubsta2",
"dump",
"dune",
"dune2",
"duster",
"emperor",
"emperor2",
"emperor3",
"entityxf",
"exemplar",
"f620",
"felon2",
"firetruk",
"fixter",
"flatbed",
"forklift",
"fq2",
"freight",
"freightcar",
"freightcont1",
"freightcont2",
"freightgrain",
"freighttrailer",
"frogger",
"frogger2",
"fugitive",
"fusilade",
"futo",
"gauntlet",
"gburrito",
"graintrailer",
"granger",
"gresley",
"habanero",
"handler",
"hauler",
"hexer",
"hotknife",
"infernus",
"ingot",
"intruder",
"issi2",
"jackal",
"jb700",
"jet",
"jetmax",
"journey",
"khamelion",
"landstalker",
"lazer",
"lguard",
"luxor",
"mammatus",
"manana",
"marquis",
"maverick",
"mesa",
"mesa2",
"mesa3",
"metrotrain",
"minivan",
"mixer",
"mixer2",
"monroe",
"mower",
"mule",
"mule2",
"nemesis",
"ninef2",
"packer",
"patriot",
"pbus",
"pcj",
"penumbra",
"peyote",
"phantom",
"phoenix",
"picador",
"pony",
"pony2",
"pounder",
"predator",
"premier",
"primo",
"proptrailer",
"radi",
"raketrailer",
"rancherxl",
"rancherxl2",
"rapidgt",
"rapidgt2",
"ratloader",
"rebel",
"rebel2",
"regina",
"rentalbus",
"rhino",
"ripley",
"rocoto",
"rubble",
"ruffian",
"ruiner",
"rumpo",
"rumpo2",
"sabregt",
"sadler",
"sadler2",
"sanchez",
"sanchez2",
"sandking",
"sandking2",
"schafter2",
"schwarzer",
"scorcher",
"scrap",
"seashark",
"seashark2",
"seminole",
"sentinel2",
"serrano",
"shamal",
"skylift",
"speedo",
"speedo2",
"squalo",
"stanier",
"stingergt",
"stockade",
"stockade3",
"stratum",
"stretch",
"stunt",
"submersible",
"sultan",
"suntrap",
"superd",
"surano",
"surfer",
"surfer2",
"surge",
"taco",
"tailgater",
"tanker",
"tankercar",
"tiptruck",
"tiptruck2",
"titan",
"tornado",
"tornado2",
"tornado3",
"tornado4",
"tourbus",
"towtruck",
"towtruck2",
"tr2",
"tr3",
"tr4",
"tractor",
"tractor2",
"tractor3",
"trflat",
"tribike",
"tribike2",
"tribike3",
"tropic",
"tvtrailer",
"utillitruck",
"utillitruck2",
"utillitruck3",
"vacca",
"vader",
"velum",
"vigero",
"voltic",
"voodoo2",
"washington",
"youga",
"zion2",
"ztype"
}
-- 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, 10.0, GetHashKey(blacklistedCar), 70))
end
end
end
end)
function checkCar(car)
if car then
carModel = GetEntityModel(car)
carName = GetDisplayNameFromVehicleModel(carModel)
if isCarBlacklisted(carModel) then
SetVehicleDoorsLocked(car, 2)
end
end
end
function isCarBlacklisted(model)
for _, blacklistedCar in pairs(carblacklist) do
if model == GetHashKey(blacklistedCar) then
return true
end
end
return false
end