├── LICENSE.md ├── README.md ├── client.lua ├── fxmanifest.lua ├── server.lua └── version /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 ItzEndah 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **CarLock - Animation & Sound** 2 | ![CarLock](https://user-images.githubusercontent.com/79053058/196249611-2457890f-4209-4a63-85e8-96a0dbf8c077.png) 3 | 4 | ## :bookmark_tabs: **Description** 5 | This is a simple standalone **Car Lock** script made for **FiveM**. 6 | 7 | - **DELETE** - Save/unsave the vehicle you are in 8 | - **U** - Lock/unlock the saved car 9 | 10 | The keys can be changed in the game menu. 11 | 12 | ## :bulb: **Features** 13 | - Simple and standalone 14 | - Key fob animation 15 | - Sound effect 16 | - Flashing car lights 17 | - Configurable keys & interaction radius 18 | 19 | ## :eyes: **Preview** 20 | [Youtube](https://youtu.be/p_MImN77A0k) 21 | 22 | ## :bar_chart: **Resmon** 23 | | Context | CPU | 24 | | ------------- | ------------- | 25 | | Idle | 0.00 ms | 26 | | Peak | 0.01 ms | 27 | 28 | ## :inbox_tray: **Installation** 29 | - Rename the folder from `CarLock-main` to `CarLock` 30 | - Drag the folder to your server resource folder 31 | - Add `start CarLock` or `ensure CarLock` to your server.cfg 32 | 33 | ## :white_check_mark: **Changelog** 34 | > **v1.2** 35 | > - Added version checker 36 | 37 | > **v1.1** 38 | > - Added keybind option 39 | > - Minor tweaks 40 | > (Thanks to *cyanURP* and *Geerdodagr8*) 41 | 42 | > **v1.0** 43 | > - Initial Release 44 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | -- CONFIG 2 | local lockDistance = 30 -- The radius you have to be in to lock/unlock your vehicle. 3 | 4 | --[[ 5 | CarLock - Created by Lama 6 | For support - https://discord.gg/etkAKTw3M7 7 | Do not edit below if you don't know what you are doing 8 | ]]-- 9 | 10 | saved = false 11 | 12 | -- Request animation 13 | Citizen.CreateThread(function() 14 | local dict = "anim@mp_player_intmenu@key_fob@" 15 | RequestAnimDict(dict) 16 | while not HasAnimDictLoaded(dict) do 17 | Citizen.Wait(0) 18 | end 19 | 20 | -- Lock lights event 21 | RegisterNetEvent('lockLights') 22 | AddEventHandler('lockLights',function() 23 | local vehicle = saveVehicle 24 | SetVehicleLights(vehicle, 2) 25 | Wait (200) 26 | SetVehicleLights(vehicle, 0) 27 | Wait (200) 28 | SetVehicleLights(vehicle, 2) 29 | Wait (400) 30 | SetVehicleLights(vehicle, 0) 31 | end) 32 | 33 | -- Lock vehicle 34 | -- You can change the keybind in your game settings 35 | RegisterKeyMapping('lock', 'Lock and unlock your saved car', 'keyboard', 'u') 36 | RegisterCommand("lock", function() 37 | local vehicle = saveVehicle 38 | local vehcoords = GetEntityCoords(vehicle) 39 | local coords = GetEntityCoords(PlayerPedId()) 40 | local isLocked = GetVehicleDoorLockStatus(vehicle) 41 | if DoesEntityExist(vehicle) then 42 | if #(vehcoords - coords) < lockDistance then 43 | if (isLocked == 1) then 44 | PlaySoundFrontend(-1, "BUTTON", "MP_PROPERTIES_ELEVATOR_DOORS", 1) 45 | TaskPlayAnim(PlayerPedId(), dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false) 46 | SetVehicleDoorsLocked(vehicle, 2) 47 | ShowNotification("~b~[CarLock] ~w~Vehicle ~r~locked") 48 | TriggerEvent('lockLights') 49 | else 50 | PlaySoundFrontend(-1, "BUTTON", "MP_PROPERTIES_ELEVATOR_DOORS", 1) 51 | TaskPlayAnim(PlayerPedId(), dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false) 52 | SetVehicleDoorsLocked(vehicle,1) 53 | ShowNotification("~b~[CarLock] ~w~Vehicle ~g~unlocked") 54 | TriggerEvent('lockLights') 55 | end 56 | else 57 | ShowNotification("~b~[CarLock] ~r~You must be closer to your vehicle") 58 | end 59 | else 60 | ShowNotification("~b~[CarLock] ~r~No saved vehicle") 61 | end 62 | end) 63 | end) 64 | 65 | -- Save vehicle 66 | -- You can change the keybind in your game settings 67 | RegisterKeyMapping('save', 'Save and unsave the car you are in', 'keyboard', 'delete') 68 | RegisterCommand("save",function() 69 | local player = PlayerPedId() 70 | if GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == PlayerPedId() then 71 | if saved == true then 72 | saveVehicle = nil 73 | RemoveBlip(targetBlip) 74 | ShowNotification("~b~[CarLock] ~w~Vehicle ~r~removed~") 75 | saved = false 76 | else 77 | RemoveBlip(targetBlip) 78 | saveVehicle = GetVehiclePedIsIn(player,true) 79 | local vehicle = saveVehicle 80 | targetBlip = AddBlipForEntity(vehicle) 81 | SetBlipSprite(targetBlip,225) 82 | ShowNotification("~b~[CarLock] ~w~Vehicle ~g~saved") 83 | saved = true 84 | end 85 | end 86 | end) 87 | 88 | -- Notification function 89 | function ShowNotification(text) 90 | SetNotificationTextEntry("STRING") 91 | AddTextComponentString(text) 92 | DrawNotification(false, false) 93 | end 94 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | 4 | name 'CarLock' 5 | description 'Vehicle lock system' 6 | author 'Lama#9612' 7 | version '1.2' 8 | 9 | client_script 'client.lua' 10 | server_script 'server.lua' 11 | -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | CarLock - Created by Lama 3 | For support - https://discord.gg/etkAKTw3M7 4 | Do not edit below if you don't know what you are doing 5 | ]]-- 6 | 7 | -- version checker 8 | Citizen.CreateThread( function() 9 | updatePath = "/lama-development/CarLock" 10 | resourceName = "CarLock by Lama" 11 | 12 | function checkVersion(err, responseText, headers) 13 | -- Returns the version set in the file 14 | curVersion = GetResourceMetadata(GetCurrentResourceName(), "version") 15 | 16 | if responseText == nil or curVersion == nil then 17 | print("^1There was an error retrieving the version of " .. resourceName .. ": the version checker will be skipped.") 18 | else if tonumber(curVersion) == tonumber(responseText) then 19 | print("^2" .. resourceName .." is up to date. Enjoy.") 20 | else 21 | print("^1" .. resourceName .. " is outdated.\nLatest version: " .. responseText .. "Current version: " .. curVersion .. "\nPlease update it from: https://github.com" .. updatePath) 22 | end 23 | end 24 | end 25 | 26 | PerformHttpRequest("https://raw.githubusercontent.com" .. updatePath .. "/main/version", checkVersion, "GET") 27 | end) 28 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | 1.2 --------------------------------------------------------------------------------