[Release] LockSystem V2.0.3 (Updated the 07/03 at 11pm)

lock
unlock
system
roleplay
vehicles

#1

LockSystem, advanced lock system for vehicles.

Version 2.0.3 - Updated the 07/03 at 11pm.
Read the updates log section !

Informations:

  • The script allows you to open and close a vehicle if you have the keys.
  • To have the keys of a vehicle simply put yourself in and press the key that you have defined (U by default).
  • Compatible with all databases.

Requirement:

* **Essentialmode is no longer required ! (Read updates log).** * InteractSound.rar (70.9 KB) (modified with sounds). * The script without modifications is [here](https://forum.fivem.net/t/release-play-custom-sounds-for-interactions/8282) (Created by Scott). * You can disable the sound in **client.lua** of **LockSystem** with `soundEnable = false` .

Installation:

* Download the LockSystem_v2.0.3.rar (3.1 KB). * Unzip **LockSystem** and put it in the **resources** folder. * Unzip **InteractSound** and put it in the **resources** folder. * Add **LockSystem** and **InteractSound** to the **citmp-server.yml** file.

Settings:

  • Open client.lua file in the LockSystem folder and follow the instructions.

Change sounds:

* Go to **InteractSound/html/sounds** and replace **lock.ogg** and **unlock.ogg** by your file (it must be in **.ogg**).

Add random messages:

* Open the **server.lua** file and search at the beginning for :
local randomMsg = {	"You have found the keys on the sun-shield",
     				"You found the keys in the glove box.",
    				"You found the keys on the passenger seat.",
    				"You found the keys on the floor.",
    				"The keys were already on the contact, you took them."}
  • e.g for add a new random message :
local randomMsg = {	"You have found the keys on the sun-shield",
     				"You found the keys in the glove box.",
    				"You found the keys on the passenger seat.",
    				"You found the keys on the floor.",
    				"The keys were already on the contact, you took them.",
    				"This is my new message, Do not forget the comma above."}

Updates log:

>**07/03 (V2.0.3)** > - Several bugs were fixed. > - Vehicles shouldn't disappear after a certain period of time or if you move away from them. **(TO TEST)**. > - Adding an engine ON/OFF : >>**LOCK:** If the player is not inside the vehicle and the engine is running it's turned off. >>**UNLOCK:** If the player sits in the vehicle and the engine is switched off then it's started. >>> >>>The vehicle's engine turns off and turns on solo correctly but if someone rides in your vehicle the engine will not turn off. >>> >>>This is due to the synchronization of fivem and after 4 hours of research we can't do anything at the moment. >> > >**06/30 (V2.0.2)** > - Changing the sounds by `PlayWithinDistance`. > - Ability to change the sound distance. > - Reorganization of the code. > - Adding an engineStatus index to the array (useless at this time). > - Problem with both vehicles corrected. > - Possibility of locking NPC's vehicles with a parameter. > - Adding another method to retrieve the playerIdentifier to avoid using Essential. > >**06/12 (V2.0.1) :** > - Adding a parameter for the style of notifications. > - The player must now be inside the vehicle to find the keys. > - Added several random RP messages to find the keys. (Ref to **Add random messages** above to add more). > - The engine now turns off when the player unlocks when he is out. > >**06/12 (V2.0) :** > - Possible to have several vehicles. > - Can not have the keys of a vehicle if it is already taken. > - Impossible to unlock a locked vehicle when changing vehicle corrected. > - Vehicles are stored in a server-side table. The table is reinitialized after each restart of the script / server.

Future update

> - Possibility to give your keys to a player.

If you detect any bugs or have any suggestions, please send it to me in private message or in the comments !


[Help] I need Lock system
How to create a Lock Script for ESX
Lock Script
[REQ] Car lock script
How do i setup a proximity text chat? and a few other questions
Lock script compatible with esx vehicle inventory.?
#2

work fine thx :slight_smile:
its possible to you to add a toggle engin ON/OFF ?

thx for your script its appreciate


#3

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 :smile:

Edit : Delete or display the text, is that?


#4

im french to xDDD im pm you x)


#5

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


#6

here a french to ! :smiley: 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


#7

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.


#8

Maybe a command would be useful! (/lock and /unlock)


#9

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 :slight_smile:


#10

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


#11

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.


#12

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?


#13

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 :slight_smile:


#14

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.


#15

So you just removing that line or what? I’d like just a button not the controller tripping it out lol


#16

@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

#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


#18

What is the call for that instead of chatMessage? i think it used to be like sendNotification


#20

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


#21

Very nice integration with InteractSound. :slight_smile: