[Release] VehicleTrustSystem

Version 1.0

It is here everyone! The first of it’s kind (at least I think)! A vehicle restriction script that is just for personal vehicles! You have commands such as /trust, /untrust to trust and untrust players to use the vehicle you own.

This all works via a file called whitelist.json and it keeps track of every player’s vehicles they are allowed to drive! If you run a huge huge server, this may not be the resource for you unless you have a developer capable of moving it to a database storage system… Other than that, this resource runs well for the smaller servers. I may look into adding an SQL option in the future though.

If they do not have access to your personal vehicle?:

Some examples of messages gotten by running commands:

  • Commands

/trust [playerID] [spawncode] = Trust the specified player to your vehicle if you own it.

/untrust [playerID] [spawncode] = Opposite of /trust… Lol…

/vehicles

  • Admin Commands

/setOwner [playerID] [spawncode] = Set the owner of a personal vehicle

/clear [spawncode] = Gets rid of all the specified vehicle’s data in case you messed up setOwner

  • Permissions

This gives permission to run Admin commands:

add_ace group.admin VehwlCommands.Access allow
  • Installation

Download VehicleTrustSystem

Extract the .zip and place the folder in your /resources/ of your Fivem server

Make sure you add “start VehicleTrustSystem” in your server.cfg

Enjoy :slight_smile:

  • Download

VehicleTrustSystem

Version 2.0

SQL storage possibility?

13 Likes

Special thanks to @BigYoda for help with the file configuration part of this script!

UPDATE
Added a new /vehicles command to see what vehicles a player has access to drive

Sure, kind of like a glorified Vehicle Keys system?

How do you think your resource handles multiple vehicles of the same spawn code?

I would highly suggest you go ahead and modify your resource so that it indexes vehicles via the NetworkGetNetworkIdFromEntity (https://runtime.fivem.net/doc/natives/#_0x9E35DAB6) native and then get the vehicle from the Network Id by NetworkGetEntityFromNetworkId (https://runtime.fivem.net/doc/natives/#_0x5B912C3F). You will have to do some pushing and pulling between the Client and Server, nothing you can’t handle.

Just what I thought when reviewing your source code, good luck.

1 Like

What is difference with this and using steam IDs though?

If I spawn two of the same vehicles in the same place and trust 1 player to 1 of the vehicles, they will have access to both of them since they are the same type.

Is this intentional?

There is nothing that distinguishes them between each other except the spawncode of the vehicle, which they are the same.

If the player is the owner of a spawncode, then they are the only ones that can give access to the vehicle of that type server-wide, doesnt matter if they spawned in the vehicle or not.

Yes, this is meant for add-on cars. Basically it gives access to being able to use the vehicle. So basically this isn’t like a key to a vehicle. It’s moreso a system to allow personal vehicle owners (usually donators) to trust their friends to drive the vehicles and prevent non-friends from driving them. Hope I explained that well?

Makes it much more clearer. Thanks for the clarification.

Make sense now the way it was written then.

1 Like

once again badger makes another EPIC script!!!:rofl::grinning:

1 Like

Outstanding job! This is EXACTLY what I’ve been looking for! This make everything so much easier and simpler. And, people can give people they want to have access, access! Amazing! Thank you so much for this incredible release!

EDIT: Alright, after some testing, I’ve realized that my game keeps freezing for a very small amount of time, but it is consistent. I think my game freezes because the script checks the permissions for you when you are in a car. Any way to stop the lag?

I’ll look into making it only check the car once so this wouldn’t be an issue anymore! Sorry about that!

1 Like

Thank you!

I never got any freezing whilst testing this, so that’s odd… Nonetheless, I now made it check the vehicle every 10 seconds instead of 4. Stop the script and check if it’s still happening, then you’ll know if it’s specifically the script which then I will look into more.

1 Like

So does this mean when a player leaves game or server restart, that they no longer have perms or the vehicle is no longer private…if it’s based of in game ID?

It’s based off steam ID and saves to a file. It still all works if a player gets offline. The permissions save to a flat-file.

I do know it’s your script. When I press F8, I realize that every time I freeze, logs are spammed with the checking of permissions of vehicles. If you can make it so it does only one check the second someone enters a vehicle, that would be awesome. :smiley:

Oh those logs are debug messages lol, meant to delete them… The only problem I found with checking once is if they then spawn the vehicle again (the same one), they then can bypass the restriction on it… Within these next few days, I’ll look into making a allowed and notAllowed cache which would track what vehicle spawncodes were already checked for the user. For now, I really suggest you stop the script and check for freezing, start it and check again using the “stop [resource]” and “start [resource]” commands.

Best Regards,
Badger

1 Like

Yeah. The lag only happens when you are in a vehicle and driving around. It lag slightly every time it checks to see if you have permission to be in a certain vehicle. If you can get it to only check once, and at the very start of entering a vehicle, that would be great. I can’t think up any other way to get it to work, but that’s why you are the creator of this script. You should be able to figure something out eventually. And if you don’t, then at least you tried. Either way, this is an amazing script. :slight_smile:

EDIT: What happens if you make it so it stop checking 5 times after all requirements are approved to allow someone to drive? For example, I own the car, and I get in to drive. Let’s say it checks 5 times. It will check 1 out of 5 times every 3-5 seconds (3000-5000 milliseconds). And every time a check passes all requirements, it allows the individual to drive the vehicle. But if one of those checks fail, it deletes the vehicle. Maybe?

Hey, so Im planning on testing something, but before I do, I want to know if it’ll break the script xD. So, in the whitelist.json If I set two people as owner: true on one vehicle will it break, or will it allow them both to use /trust for that vehicle?

Only allows 1 owner to be set, when you try to set another owner, it’ll bring up a message that you can’t :stuck_out_tongue: