Secure your FiveM server with our free NPC Vehicle Lock script. This code locks vehicle doors when NPCs attempt entry and prevents removal of NPC drivers. Simply paste into your client file and restart.
Code:
Citizen.CreateThread(function()
while true do
Wait(0)
local ped = PlayerPedId()
if DoesEntityExist(GetVehiclePedIsTryingToEnter(PlayerPedId(ped))) then
local veh = GetVehiclePedIsTryingToEnter(PlayerPedId(ped))
local lock = GetVehicleDoorLockStatus(veh)
if lock == 7 then
SetVehicleDoorsLocked(veh, 2)
end
local pedd = GetPedInVehicleSeat(veh, -1)
if pedd then
SetPedCanBeDraggedOut(pedd, false)
end
end
end
end)
Last edited by a moderator: