From 012e05f66c2df31558c92a4cc339b892b86f9687 Mon Sep 17 00:00:00 2001 From: fxDopa <131190297+rdopaa@users.noreply.github.com> Date: Fri, 5 May 2023 03:18:33 -0300 Subject: [PATCH] Add files via upload --- client/main.lua | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ locales/br.lua | 6 ++++ locales/en.lua | 5 +++ locales/es.lua | 5 +++ locales/fr.lua | 5 +++ locales/sv.lua | 5 +++ locales/tr.lua | 6 ++++ server/main.lua | 16 +++++++++ 8 files changed, 142 insertions(+) create mode 100644 client/main.lua create mode 100644 locales/br.lua create mode 100644 locales/en.lua create mode 100644 locales/es.lua create mode 100644 locales/fr.lua create mode 100644 locales/sv.lua create mode 100644 locales/tr.lua create mode 100644 server/main.lua diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 0000000..b422dfd --- /dev/null +++ b/client/main.lua @@ -0,0 +1,94 @@ +local isRunningWorkaround = false + +ESX = exports['es_extended']:getSharedObject() + +function StartWorkaroundTask() + if isRunningWorkaround then + return + end + local timer = 0 + local playerPed = PlayerPedId() + isRunningWorkaround = true + + while timer < 100 do + Citizen.Wait(0) + timer = timer + 1 + + local vehicle = GetVehiclePedIsTryingToEnter(playerPed) + + if DoesEntityExist(vehicle) then + local lockStatus = GetVehicleDoorLockStatus(vehicle) + + if lockStatus == 4 then + ClearPedTasks(playerPed) + end + end + end + isRunningWorkaround = false +end + +function ToggleVehicleLock() + local playerPed = PlayerPedId() + local coords = GetEntityCoords(playerPed) + local vehicle + local dict = "anim@mp_player_intmenu@key_fob@" + + Citizen.CreateThread(function() + StartWorkaroundTask() + end) + RequestAnimDict(dict) + while not HasAnimDictLoaded(dict) do + Citizen.Wait(5) + end + + if IsPedInAnyVehicle(playerPed, false) then + vehicle = GetVehiclePedIsIn(playerPed, false) + else + vehicle = GetClosestVehicle(coords, 8.0, 0, 71) + end + + if not DoesEntityExist(vehicle) then + return + end + + ESX.TriggerServerCallback('fx_vehiclelock:Cars', function(isOwnedVehicle) + if isOwnedVehicle then + local lockStatus = GetVehicleDoorLockStatus(vehicle) + local vehicleLabel = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle)) + vehicleLabel = GetLabelText(vehicleLabel) + if lockStatus == 1 then -- unlocked + SetVehicleDoorsLocked(vehicle, 2) + PlayVehicleDoorCloseSound(vehicle, 1) + StartVehicleHorn(vehicle, "NORMAL") + ESX.ShowNotification('~r~Cerraste~s~ tu ~b~'..vehicleLabel..'~b~.') + if not IsPedInAnyVehicle(PlayerPedId(), true) then + TaskPlayAnim(PlayerPedId(), dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false) + end + elseif lockStatus == 2 then -- locked + SetVehicleDoorsLocked(vehicle, 1) + PlayVehicleDoorOpenSound(vehicle, 0) + StartVehicleHorn(vehicle, "NORMAL") + ESX.ShowNotification('~g~Abriste~s~ tu ~b~'..vehicleLabel..'~b~.') + if not IsPedInAnyVehicle(PlayerPedId(), true) then + TaskPlayAnim(PlayerPedId(), dict, "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false) + end + end + end + end, ESX.Math.Trim(GetVehicleNumberPlateText(vehicle))) +end + +Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + + if IsControlJustReleased(0, 244) and IsInputDisabled(0) then + ToggleVehicleLock() + Citizen.Wait(300) + + -- D-pad down on controllers works, too! + elseif IsControlJustReleased(0, 173) and not IsInputDisabled(0) then + ToggleVehicleLock() + Citizen.Wait(300) + end + end +end) diff --git a/locales/br.lua b/locales/br.lua new file mode 100644 index 0000000..a4f531f --- /dev/null +++ b/locales/br.lua @@ -0,0 +1,6 @@ +Locales ['br'] = { + ['message_title'] = '^3Veículo Fechado', + ['message_locked'] = 'fechado', + ['message_unlocked'] = 'aberto', +} + diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 0000000..ec77fee --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,5 @@ +Locales ['en'] = { + ['message_title'] = '^3Vehicle lock', + ['message_locked'] = 'locked', + ['message_unlocked'] = 'unlocked', +} diff --git a/locales/es.lua b/locales/es.lua new file mode 100644 index 0000000..98f78e2 --- /dev/null +++ b/locales/es.lua @@ -0,0 +1,5 @@ +Locales ['es'] = { + ['message_title'] = '^3Sistema de alarma', + ['message_locked'] = 'Alarma Activada', + ['message_unlocked'] = 'Alarma Desactivada', +} diff --git a/locales/fr.lua b/locales/fr.lua new file mode 100644 index 0000000..a3cc3d9 --- /dev/null +++ b/locales/fr.lua @@ -0,0 +1,5 @@ +Locales ['fr'] = { + ['message_title'] = '^3Verrou véhicule', + ['message_locked'] = 'ouvert', + ['message_unlocked'] = 'fermé', +} diff --git a/locales/sv.lua b/locales/sv.lua new file mode 100644 index 0000000..bb01eed --- /dev/null +++ b/locales/sv.lua @@ -0,0 +1,5 @@ +Locales ['sv'] = { + ['message_title'] = '^3Fordonslås', + ['message_locked'] = 'du låste fordonet', + ['message_unlocked'] = 'du låste upp fordonet', +} diff --git a/locales/tr.lua b/locales/tr.lua new file mode 100644 index 0000000..3d0dbef --- /dev/null +++ b/locales/tr.lua @@ -0,0 +1,6 @@ +Locales ['tr'] = { + ['message_title'] = '^3Araç kilidi', + ['message_locked'] = 'kilitli', + ['message_unlocked'] = 'açık', + } + \ No newline at end of file diff --git a/server/main.lua b/server/main.lua new file mode 100644 index 0000000..a668f33 --- /dev/null +++ b/server/main.lua @@ -0,0 +1,16 @@ +ESX = exports['es_extended']:getSharedObject() + +ESX.RegisterServerCallback('fx_vehiclelock:Cars', function(source, cb, plate) + local xPlayer = ESX.GetPlayerFromId(source) + + MySQL.Async.fetchAll('SELECT owner FROM owned_vehicles WHERE owner = @owner AND plate = @plate', { + ['@owner'] = xPlayer.identifier, + ['@plate'] = plate + }, function(result) + if result[1] then + cb(result[1].owner == xPlayer.identifier) + else + cb(false) + end + end) +end) \ No newline at end of file