├── config.lua ├── sql.sql ├── fxmanifest.lua ├── locales.lua ├── README.md ├── client.lua └── server.lua /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | Config.Locale = 'en' -- en/cz 3 | Config.Price = 5000 -- amount of car locks replace at Locksmith -------------------------------------------------------------------------------- /sql.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `owned_vehicles` 2 | ADD COLUMN `peopleWithKeys` LONGTEXT NULL DEFAULT '[]'; 3 | 4 | -- IF you got errors while executing the query above, use the one bellow 5 | ALTER TABLE `owned_vehicles` 6 | ADD COLUMN `peopleWithKeys` LONGTEXT NULL; -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | game 'gta5' 2 | fx_version 'cerulean' 3 | 4 | author 'Squizer#3020' 5 | description 'Script that allows you to lock vehicles.' 6 | version '1.0.0' 7 | 8 | shared_scripts { 9 | '@es_extended/locale.lua', 10 | 'locales.lua', 11 | 'config.lua' 12 | } 13 | 14 | client_scripts { 15 | 'client.lua', 16 | } 17 | server_scripts { 18 | '@mysql-async/lib/MySQL.lua', 19 | 'server.lua' 20 | } -------------------------------------------------------------------------------- /locales.lua: -------------------------------------------------------------------------------- 1 | Locales['cz'] = { 2 | ['spz_not_found'] = 'Nepodařilo se najít SPZ vozidla', 3 | ['no_keys'] = 'Od tohoto auta nemáš klíče', 4 | ['not_yours_vehicle'] = 'Toto vozidlo není tvoje', 5 | ['locks_replaced'] = 'Zámky úspěšně vyměněny', 6 | ['paid_for_locks'] = 'Zaplatil jsi %s$ za nové zámky', 7 | ['not_enough_money'] = 'Nemáš na zaplacení nových zámků', 8 | ['wait_new_locks'] = 'Nyní počkej půl minuty na nové zámky', 9 | ['installing_new_locks'] = 'Probíhá instalace nových zámků', 10 | ['received_keys'] = 'Dostal jsi klíče od vozidla s SPZ: %s', 11 | ['gave_keys'] = 'Dal jsi klíče od vozidla s SPZ: %s', 12 | ['locksmith'] = 'Locksmith', 13 | ['must_in_vehicle'] = 'Musíš sedět ve vozidle', 14 | ['change_locks_for'] = '[E] Pro výměnu zámků za %s$', 15 | ['vehicle_locked'] = 'Vozidlo bylo úspěšně zamčeno', 16 | ['vehicle_unlocked'] = 'Vozidlo bylo úspěšně odemčeno', 17 | ['lock_vehicle'] = 'Zamknout vozidlo', 18 | ['no_vehicle_found'] = 'Žádné vozidlo nebylo nalezeno' 19 | } 20 | 21 | Locales['en'] = { 22 | ['spz_not_found'] = 'We were unable to find the vehicle\'s SPZ', 23 | ['no_keys'] = 'You do not have keys of this vehicle', 24 | ['not_yours_vehicle'] = 'This vehicle is not yours', 25 | ['locks_replaced'] = 'The locks have been successfuly replaced', 26 | ['paid_for_locks'] = 'You have paid %s$ for the new locks', 27 | ['not_enough_money'] = 'You do not have enough money to buy a locks replacement', 28 | ['wait_new_locks'] = 'Wait a half of minute until the locks get replaced', 29 | ['installing_new_locks'] = 'The locks are being replaced', 30 | ['received_keys'] = 'You have received keys of a vehicle with a license plate: %s', 31 | ['gave_keys'] = 'You have given keys of a vehicle with a license plate: %s', 32 | ['locksmith'] = 'Locksmith', 33 | ['must_in_vehicle'] = 'You must be sitting in a vehicle', 34 | ['change_locks_for'] = '[E] To replace vehicle locks %s$', 35 | ['vehicle_locked'] = 'Vehicle has been successfuly locked', 36 | ['vehicle_unlocked'] = 'Vehicle has been successfuly unlocked', 37 | ['lock_vehicle'] = 'Toggle vehicle locks', 38 | ['no_vehicle_found'] = 'There is no vehicle nearby' 39 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | # 🌐 **Host Smarter with Fusiora.com!** 🚀 4 | 5 | Fusiora Logo 6 | 7 | 🖥️ **Premium hardware** in **Netherlands**, **Miami**, & **Germany**. 8 | 🛡️ **DDoS protection** for **any game**. 9 | 💸 Use **`CODELY`** for **10% OFF**! 10 | 11 | ## 🔗 [**Start Hosting Now**](https://fusiora.com) 12 | 13 |
14 | 15 | # SQZ_CARKEYS SCRIPT 16 | 17 | Modern, simple, clear script for locking player vehicles. Optimized server + client side, possibility to give keys to another players, supports society owned vehicles, Locksmith for resetting vehicle keys and much more! All is working with OneSync Infinity/Legacy, as much as possible is handled server, all events are protected againts hackers. 18 | 19 | # Features 20 | - Lock personaly/society owned vehicles 21 | - Give vehicle keys to other players 22 | - Reset vehicle keys at Locksmith (place on the map) 23 | - Give temporarily keys of vehicle 24 | - Optimized client & server side 25 | 26 | # Controls 27 | - /givekeys - Give keys to a player 28 | - /lockvehicle or F10 - Lock closest vehicle 29 | 30 | # Exports 31 | - Server side 32 | - - `resetPlate(plate)` - Resets a vehicle plate's cache 33 | - - `giveTempKeys(plate, identifier, timeout)` - Adds temporarily keys to a player (until the server), timeout is an optional param, time in ms until the key is reset 34 | 35 | # Other Scripts made by Squizer 36 | * [sqz_anticheat](https://forum.cfx.re/t/anticheat-revolutionary-anticheat/4802102) - Higly effective cheap FiveM anticheat 37 | * [sqz_unijob](https://forum.cfx.re/t/esx-sqz-unijob-advanced-system-for-easy-adding-jobs/2100467) - Script for adding multiple jobs into 1 script just by edditing config 38 | * [sqz_drugs](https://forum.cfx.re/t/esx-sqz-drugs-advanced-drug-system/2167691) - Complete system for drugs, planting, harvesting, watering, processing and dealing drugs 39 | * [sqz_duty](https://forum.cfx.re/t/release-esx-sqz-duty-advanced-duty-script/3354791) - Advanced duty system which counts time spent in duty 40 | * [sqz_robbery](https://forum.cfx.re/t/release-sqz-robbery-advanced-robbery-script/4773035) - All in one robbery system 41 | * [sqz_chatenhancements](https://forum.cfx.re/t/sqz-chatenhancements-status-here-roll-commands/4804562) - Commands /status, /here and /roll for your chat 42 | * [sqz_switchjob](https://github.com/czsquizer/switchjob) - Script for switching and having multiple jobs 43 | * [sqz_carmenu](https://github.com/czsquizer/sqz_carmenu) - Script for all the car features you would ever need 44 | * [sqz_hospital](https://github.com/czsquizer/sqz_hospital) - Script that allows player heal themselves in the hospital in case there are no doctors on your server 45 | * [sqz_banlist](https://github.com/czsquizer/sqz_banlist) - List with cheaters with mod menu opened. Prevent cheating on your server! 46 | * [sqz_carkeys](https://github.com/czsquizer/sqz_carkeys) - FiveM vehicle Keys scripts with giving and saving keys in the database. 47 | * [sqz_rental](https://github.com/czsquizer/sqz_rental) - Quality rental system with all types of vehicles and an insurace! 48 | * [sqz_itemwhitelist](https://github.com/czsquizer/sqz_itemwhitelist) - Prop and vehicle whitelist/blacklist to prevent hackers spamming your server with entities 49 | * [others](https://github.com/czsquizer?tab=repositories) - You can find there my forks of other scripts, check them as well 50 | 51 | # Instalation 52 | - Drop the script into your resources folder and start it in your `server.cfg` 53 | - Run the sql.sql file 54 | - For optional modifications & exports check docs 55 | 56 | __You can read the docs here__ 57 | [![Docs](https://img.shields.io/badge/docs-passing-brightgreen)](https://docs.squizer.cz) 58 | 59 | # Visit Squizer's "social media" 60 | * [Tebex](https://sqz.tebex.io/) 61 | * [Page](https://squizer.cz) 62 | * [Cfx.re Forum](https://forum.cfx.re/u/squizer/) 63 | * [Discord](https://discord.gg/FVXAu2F) 64 | * [GitHub](https://github.com/czsquizer/) 65 | 66 | ### Made by Squizer#3020 67 | ### You can edit this script as yours, but do NOT take it as yours, republish it, resell it as Mr. Cryzysek (ProjectX server owner) did it with sqz_switchjob. 68 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | ESX = exports["es_extended"]:getSharedObject() 2 | 3 | RegisterCommand('lockvehicle', function() 4 | 5 | local vehicle, dist = ESX.Game.GetClosestVehicle() 6 | 7 | if dist < 10 and vehicle > 0 then 8 | ClearPedTasks(PlayerPedId()) 9 | Wait(100) 10 | TriggerServerEvent('carkeys:RequestVehicleLock', VehToNet(vehicle), GetVehicleDoorLockStatus(vehicle)) 11 | else 12 | ESX.ShowNotification(_U('no_vehicle_found')) 13 | end 14 | end) 15 | RegisterKeyMapping('lockvehicle', _U('lock_vehicle'), 'keyboard', 'f10') 16 | 17 | RegisterNetEvent('carlock:CarLockedEffect', function(netId, lockStatus) 18 | local vehicle = NetToVeh(netId) 19 | if DoesEntityExist(vehicle) then 20 | local ped = PlayerPedId() 21 | 22 | local prop = GetHashKey('p_car_keys_01') 23 | RequestModel(prop) 24 | while not HasModelLoaded(prop) do 25 | Citizen.Wait(10) 26 | end 27 | local keyObj = CreateObject(prop, 1.0, 1.0, 1.0, 1, 1, 0) 28 | AttachEntityToEntity(keyObj, ped, GetPedBoneIndex(ped, 57005), 0.08, 0.039, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true) 29 | 30 | local dict = "anim@mp_player_intmenu@key_fob@" 31 | RequestAnimDict(dict) 32 | while not HasAnimDictLoaded(dict) do 33 | Citizen.Wait(0) 34 | end 35 | 36 | if not IsPedInAnyVehicle(PlayerPedId(), true) then 37 | TaskPlayAnim(ped, dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false) 38 | end 39 | 40 | PlayVehicleDoorCloseSound(vehicle, 1) 41 | SetVehicleDoorsLockedForAllPlayers(vehicle, lockStatus) 42 | if lockStatus then 43 | ESX.ShowNotification(_U('vehicle_locked')) 44 | else 45 | ESX.ShowNotification(_U('vehicle_unlocked')) 46 | end 47 | 48 | SetVehicleLights(vehicle, 2) 49 | Citizen.Wait(250) 50 | SetVehicleLights(vehicle, 0) 51 | Citizen.Wait(250) 52 | SetVehicleLights(vehicle, 2) 53 | Citizen.Wait(250) 54 | SetVehicleLights(vehicle, 0) 55 | Wait(600) 56 | DetachEntity(keyObj, false, false) 57 | DeleteEntity(keyObj) 58 | end 59 | end) 60 | 61 | RegisterCommand('givekeys', function() 62 | local closestP, closestD = ESX.Game.GetClosestPlayer() 63 | local vehicle, dist = ESX.Game.GetClosestVehicle() 64 | if DoesEntityExist(vehicle) and closestP ~= -1 and closestD < 4 and dist < 10 then 65 | local plate = GetVehicleNumberPlateText(vehicle) 66 | TriggerServerEvent('carkeys:GiveKeyToPerson', plate, GetPlayerServerId(closestP)) 67 | end 68 | end) 69 | 70 | function Draw3DText(x, y, z, text) 71 | SetTextScale(0.22, 0.22) 72 | SetTextFont(13) 73 | SetTextProportional(1) 74 | SetTextColour(255, 255, 255, 215) 75 | SetTextEntry("STRING") 76 | SetTextCentre(true) 77 | AddTextComponentString(text) 78 | SetDrawOrigin(x,y,z, 0) 79 | DrawText(0.0, 0.0) 80 | local factor = (string.len(text)) / 370 81 | DrawRect(0.0, 0.0+0.0125, 0.015+ factor, 0.03, 0, 0, 0, 75) 82 | ClearDrawOrigin() 83 | end 84 | 85 | local centralPos = vector3(-25.94, -624.51, 35.5) 86 | Citizen.CreateThread(function() 87 | while true do 88 | Wait(0) 89 | local playerPed = PlayerPedId() 90 | local dist = #(GetEntityCoords(playerPed) - centralPos) 91 | 92 | if dist < 15.0 then 93 | Draw3DText(centralPos.x, centralPos.y, centralPos.z, _U('change_locks_for', Config.Price)) 94 | if dist < 2 then 95 | if IsControlJustPressed(0, 38) then 96 | local veh = GetVehiclePedIsIn(playerPed) 97 | if DoesEntityExist(veh) then 98 | TriggerServerEvent('carkeys:NewLocks', GetVehicleNumberPlateText(veh)) 99 | Wait(5000) 100 | else 101 | ESX.ShowNotification(_U('must_in_vehicle')) 102 | end 103 | end 104 | end 105 | else 106 | Wait(500) 107 | end 108 | end 109 | end) 110 | 111 | Citizen.CreateThread(function() 112 | 113 | local blip = AddBlipForCoord(centralPos) 114 | 115 | SetBlipSprite (blip, 186) 116 | SetBlipDisplay(blip, 4) 117 | SetBlipScale (blip, 0.9) 118 | SetBlipColour (blip, 73) 119 | SetBlipAsShortRange(blip, true) 120 | 121 | BeginTextCommandSetBlipName("STRING") 122 | AddTextComponentString(AddTextComponentString(_U('locksmith'))) 123 | EndTextCommandSetBlipName(blip) 124 | 125 | end) -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | ESX = exports["es_extended"]:getSharedObject() 2 | 3 | local vehiclesCache = {} 4 | 5 | exports('resetPlate', function(plate) 6 | 7 | vehiclesCache[plate] = nil 8 | 9 | end) 10 | 11 | exports('giveTempKeys', function(plate, identifier, timeout) 12 | 13 | if not vehiclesCache[plate] then 14 | vehiclesCache[plate] = {} 15 | end 16 | 17 | vehiclesCache[plate][identifier] = true 18 | 19 | if timeout then 20 | Citizen.SetTimeout(timeout, function() 21 | if vehiclesCache[plate] and vehiclesCache[plate][identifier] then 22 | vehiclesCache[plate][identifier] = nil 23 | end 24 | end) 25 | end 26 | end) 27 | 28 | RegisterNetEvent('carkeys:RequestVehicleLock', function(netId, lockstatus) 29 | local vehicle = NetworkGetEntityFromNetworkId(netId) 30 | local plate = GetVehicleNumberPlateText(vehicle) 31 | local xPlayer = ESX.GetPlayerFromId(source) 32 | if not plate then xPlayer.showNotification(_U('spz_not_found')) return end 33 | if not vehiclesCache[plate] then 34 | local result = MySQL.Sync.fetchAll('SELECT owner, peopleWithKeys FROM owned_vehicles WHERE plate = "'..plate..'"') 35 | if result and result[1] then 36 | vehiclesCache[plate] = {} 37 | vehiclesCache[plate][result[1].owner] = true 38 | local otherKeys = json.decode(result[1].peopleWithKeys) 39 | if not otherKeys then otherKeys = {} end 40 | for k, v in pairs(otherKeys) do 41 | vehiclesCache[plate][v] = true 42 | end 43 | end 44 | end 45 | if vehiclesCache[plate] and (vehiclesCache[plate][xPlayer.identifier] or vehiclesCache[plate][xPlayer.job.name]) then 46 | SetVehicleDoorsLocked(vehicle, lockstatus == 2 and 1 or 2) 47 | TriggerClientEvent('carlock:CarLockedEffect', xPlayer.source, netId, lockstatus ~= 2) 48 | else 49 | xPlayer.showNotification(_U('no_keys')) 50 | end 51 | end) 52 | 53 | RegisterNetEvent('carkeys:GiveKeyToPerson', function(plate, target) 54 | local xPlayer = ESX.GetPlayerFromId(source) 55 | local owner = MySQL.Sync.fetchScalar('SELECT owner FROM owned_vehicles WHERE plate = "'..plate..'"') 56 | if owner == xPlayer.identifier then 57 | local xTarget = ESX.GetPlayerFromId(target) 58 | local peopleWithKeys = MySQL.Sync.fetchScalar('SELECT peopleWithKeys FROM owned_vehicles WHERE plate = "'..plate..'"') 59 | local keysTable = json.decode(peopleWithKeys) or {} 60 | keysTable[xTarget.identifier] = true 61 | 62 | MySQL.Async.execute('UPDATE owned_vehicles SET peopleWithKeys = @peopleWithKeys WHERE plate = @plate', { 63 | ['@peopleWithKeys'] = json.encode(keysTable), 64 | ['@plate'] = plate 65 | }, function(rowsUpdated) 66 | if rowsUpdated > 0 then 67 | xTarget.showNotification(_U('received_keys', plate)) 68 | xPlayer.showNotification(_U('gave_keys', plate)) 69 | end 70 | end) 71 | 72 | if vehiclesCache[plate] then 73 | vehiclesCache[plate][xTarget.identifier] = true 74 | end 75 | 76 | else 77 | xPlayer.showNotification(_U('not_yours_vehicle')) 78 | end 79 | end) 80 | 81 | RegisterNetEvent('carkeys:NewLocks', function(plate) 82 | local xPlayer = ESX.GetPlayerFromId(source) 83 | local isOwned = MySQL.Sync.fetchScalar('SELECT 1 FROM owned_vehicles WHERE plate = "'..plate..'" AND owner = "'..xPlayer.identifier..'"') 84 | if isOwned then 85 | if xPlayer.getMoney() >= Config.Price then 86 | xPlayer.removeMoney(Config.Price) 87 | elseif xPlayer.getAccount('bank').money >= Config.Price then 88 | xPlayer.removeAccountMoney('bank', Config.Price) 89 | else 90 | xPlayer.showNotification(_U('not_enough_money')) 91 | return 92 | end 93 | xPlayer.showNotification(_U('paid_for_locks', Config.Price)) 94 | xPlayer.showNotification(_U('wait_new_locks')) 95 | TriggerClientEvent('progressBars:StartUI', xPlayer.source, 30000, _U('installing_new_locks')) 96 | FreezeEntityPosition(GetPlayerPed(xPlayer.source), true) 97 | local playersVeh = GetVehiclePedIsIn(GetPlayerPed(xPlayer.source)) 98 | FreezeEntityPosition(playersVeh, true) 99 | Wait(30000) 100 | FreezeEntityPosition(GetPlayerPed(xPlayer.source), false) 101 | FreezeEntityPosition(playersVeh, false) 102 | MySQL.Async.execute('UPDATE owned_vehicles SET peopleWithKeys = "[]" WHERE plate = "'..plate..'"', {}, function(rowsUpdated) 103 | if rowsUpdated > 0 then 104 | xPlayer.showNotification(_('locks_replaced')) 105 | vehiclesCache[plate] = {} 106 | vehiclesCache[plate][xPlayer.identifier] = true 107 | end 108 | end) 109 | else 110 | xPlayer.showNotification(_U('not_yours_vehicle')) 111 | end 112 | end) --------------------------------------------------------------------------------