Yet pretty simple, but it should be efficient against the annoying NPC car-jacking and car stealing on roleplay based severs. This will force your players to find other means to reach their destination. The ability to steal cars is based on a “luck” factor.
Features
Works on all vehicles (cars,bikes,trucks,helicopters,planes,boats,…)
Prevent parked vehicle stealing
Prevent any kind of grand theft auto (car-jacking, passenger car-jack, etc)
Vehicle stealing/car-jacking is only allowed only by a predefined threshold
Stores a vehicle history for everyplayer (up to 10 vehicles), this way a player can use multiple vehicles
Compatible with any vehicle control script
Disable/Enable script for players
Low CPU usage
Installation
Download the latest version from github releases and extract the content in your resources directory
Add - nocarjack in your AutoStartResources ( citmp-server.yml)
Restart server
Source code
Usage
I highly recommend you to try it on a dev server before trying to apply it on your existing server.
This script should be stable and work with any other vehicle control system. However, if you do have problems running my script, please provide me at least :
Couldn’t you just trigger an event when they are attempting to get into a car and if the event gets canceled, let them in. That way they don’t have to spam it, and it’s more reliable than a timer.
@helium Okay, it seems there is some general confusion over here.
The script is almost 99% client-side, the only 1% of networking there is can be found here.
What do you mean with “not to spam events”? The only called event is the one that defines if a player can escape the script for a few seconds, it doesn’t create any other request. I’m not really sure we’re talking about the same thing.
Can you provide some information about the owned vehicle? Which script is it ? Do you have a server databse with stored vehicle IDs?
It seems like you can’t enter your vehicle because as long as you didn’t enter that vehicle in some way it will give a random chance whether to let you in or not, in other words, every time you try to enter your car, the script will think “Ah this player is trying to steal this one”.
That would explain the problem. As I stated it in some previous post, the script needs to store a list that contains all the vehicle ID’s owned by the player, I will start working on it now and that list could be retrieved with an event every time the player connects.
Any chance you drop me your server IP so that I can see live action?
Oh and also, how do you store the vehicle ID? By its net handle?
I’ve updated the script. It should work correctly with multiple vehicles now.
The wiki contains detailed information on how to use it with Garages/Custom vehicles scripts.
are their options for this to change the “luck factor” to increase or decrease the chance of successful steals ? and where if so is this located. thanks
Hate to agree with helium but this seems way too complicated. What happens if the timer runs out and you have an empty history? Does the timer restart? It seems to keep adding the vehicle every tick and never checks if it already exists? I don’t use c# but don’t you need a list.contains?
I hate to shit on a mod without ever using it or fully understanding it, props for doing and sharing it, but man it feels wrong to me. I have to do the same thing in lua I’ll post it here later today maybe that will help some people too. Mods get better with lots of peer review and suggestions. I’ll add the suggestion part in a little bit.
This is a slightly simpler version that can be expanded on as needed. It does two things.
If entering a vehicle, set the driver “CanBeDraggedOut” to false, preventing car jacking. Players/peds can no longer drag someone out and steal the vehicle.
If the vehicle is locked and requires the window to be broken, lock the doors (2 vs 7), protecting the vehicle. Windows can no longer be broken to get into the vehicle. I think 80% of the vehicles spawn locked.
Citizen.CreateThread(function()
while true do
if DoesEntityExist(GetVehiclePedIsTryingToEnter(PlayerPedId())) then
local veh = GetVehiclePedIsTryingToEnter(PlayerPedId())
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
Citizen.Wait(0)
end
end)