LockSystem, advanced lock system for vehicles.
Version 3.1 - Updated the 07/16/2018.
Github Repository
Latest version (3.1) here
ESX Version (thank's to @xseba360) : https://github.com/Xseba360/esx_locksystem
Old version (2.1) here (With the comma !)
(Changelog at the end of post)
Thank you, but i won't develop on FiveM anymore for now
After a long waiting time, here is the new (and last) version of the LockSystem script. I won't work on it anymore because i stopped developing on FiveM. The code is Open Source and I invite you to contribute to the project on Github. You will find the contribution guide directly on the Github README page.
What is LockSystem
LockSystem is a script allowing to :
- Recover the keys of a vehicle with a percentage of success and customizable messages
- Lock / Unlock the cars that belong to you
- Give your keys with a chat command (Not tested, i can't do this alone)
- Recover your keys when disconnecting and reconnecting (reset keys when server restarts)
- Disable (or not) NPC cars
- Provide a mini API to help developers work with it
How it works
When you enter a vehicle (any vehicle), you can try to retrieve the keys by pressing the U key (default). A percentage success rate can be configured. If you find the keys, you can lock and open the vehicle and give your keys to someone else..
Installation
- Download and install the script
- Move the LockSystem folder in your FiveM resources
- Add start LockSystem in your server.cfg file
Configuration overview
You can find the configuration in config/shared.lua.
The sounds are in the html/sounds/ folder.
The give keys command
Here is the command for give the keys. I haven't tried i, i hope it works. Otherwise, feel free to solve the problems and contribute to the project on Github.
/givekey <player id> <plate>
Mini API
You will find all the necessary information in the files client_api.lua and server_api.lua.
Changelog
Version 3.1 (07/16/2018)
Trunk problem should be resolved
50 Likes
work fine thx 
its possible to you to add a toggle engin ON/OFF ?
thx for your script its appreciate
Sorry, I am french and I don’t see what you mean by toggle engine. You can quickly describe what you want me to add ?
Thanks you, glad you like it 
Edit : Delete or display the text, is that?
1 Like
im french to xDDD im pm you x)
Future update :
- Disable engine when vehicle is locked
- Add parameters for the text
- Try to add custom external sound when lock/unlock
Tell me if you have any other suggestions
2 Likes
here a french to !
Nice script and thanks u for the non command use. Yes if you can add the toggle engine this will be cool (like your are in our out your vehicle and u can turn off ur engine) Thank for sharing
I know this isnt related but you can also make a script to disable car when it crashes for set amount of secs the one we have is broken.
Maybe a command would be useful! (/lock and /unlock)
I can add a command even if I find that it ruins the RP a little, the option will be disabled for those who don’t want 
Don’t lock a different vehicle or it bugs out and says you don’t have a vehicle anymore and you can’t get back in
Update here !
Thank’s @SPJESTER, I will see what I can do but as long as I don’t use a database then you can only have one vehicle.
EDIT : You can change the vehicle if the last was unlocked.
Why don’t you move
local player = GetPlayerPed(-1)
local car = SetPlayersLastVehicle(GetVehiclePedIsIn(player, true))
if car ~= 0 then
posCar = GetEntityCoords(car, false)
carX, carY, carZ = posCar.x, posCar.y, posCar.z
posPlayer = GetEntityCoords(player, false)
playerX, playerY, playerZ = posPlayer.x, posPlayer.y, posPlayer.z
end
Inside
if IsControlJustPressed(1, key) then
so the script won’t constantly update variables?
Because I think it’s better to have predefined values and not wait to press the key, but you can edit the script as you like 
The problem here is that it will eat client resources without any need. It will pull data and update values every frame (60 times a second average), that can lead to memory leak/unnecessary CPU load.
So you just removing that line or what? I’d like just a button not the controller tripping it out lol
@SPJESTER You have to do what he said, like that :
if IsControlJustPressed(1, key) then
local player = GetPlayerPed(-1)
local car = SetPlayersLastVehicle(GetVehiclePedIsIn(player, true))
if car ~= 0 then
posCar = GetEntityCoords(car, false)
carX, carY, carZ = posCar.x, posCar.y, posCar.z
posPlayer = GetEntityCoords(player, false)
playerX, playerY, playerZ = posPlayer.x, posPlayer.y, posPlayer.z
end
1 Like
MiDooM
17
Hi, work fine! thx for the release.
I have a suggestion to make you if you want
It would be to replace the chat message by a notification at the top of the radar
What is the call for that instead of chatMessage? i think it used to be like sendNotification
1 Like
(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)
Scott
21
Very nice integration with InteractSound. 
2 Likes