[Release] No more NPC/parked vehicle stealing

Description

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

  1. Download the latest version from github releases and extract the content in your resources directory
  2. Add - nocarjack in your AutoStartResources ( citmp-server.yml)
  3. Restart server

Source code

Usage

:warning: I highly recommend you to try it on a dev server before trying to apply it on your existing server.

See the wiki for complete information.

Future updates

  • Custom config file

Support and Suggestions

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 :

  • The nocarjack script version you’re running
  • All the other vehicle-control based script name
  • Console/debug log
  • A brief description of what’s happening

You can also create issues on github.

18 Likes

Please don’t tell people to spam events, especially not networked ones

2 Likes

Thanks for your job :wink:

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.

1 Like

@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.

@Nick78111
See the answer above.

Anyways, I’ve added the source code to make it more clear.

Can you please make it do the animation of a locked car rather than it do nothing? Feels odd and people may see servers as having a bug :slight_smile:

Thanks

1 Like

Also we cant get into our owned vehicles.

1 Like

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”.

Using Garages.

Yes it uses a database :slight_smile:

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.

thanks ive been looking for this for awhile :slight_smile:

Thanks for the update ! Can you explain, how can we add owned vehicle every time player take his vehicle on the garage ?

2 Likes

Hi

can you explain me what tools you use to compile your c# code.

Thanks

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

it’s just an integer in the source code but i don’t know how i can compile it ^^

1 Like

Use https://www.visualstudio.com/vs/visual-studio-express/ with the .NET development workload.

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.

4 Likes

i tried but i have errors with gta syntaxe or Debug etc so i can’t compile it

This is a slightly simpler version that can be expanded on as needed. It does two things.

  1. 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.

  2. 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)
6 Likes