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