-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Locales ['br'] = { | ||
['message_title'] = '^3Veículo Fechado', | ||
['message_locked'] = 'fechado', | ||
['message_unlocked'] = 'aberto', | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Locales ['en'] = { | ||
['message_title'] = '^3Vehicle lock', | ||
['message_locked'] = 'locked', | ||
['message_unlocked'] = 'unlocked', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Locales ['es'] = { | ||
['message_title'] = '^3Sistema de alarma', | ||
['message_locked'] = 'Alarma Activada', | ||
['message_unlocked'] = 'Alarma Desactivada', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Locales ['fr'] = { | ||
['message_title'] = '^3Verrou véhicule', | ||
['message_locked'] = 'ouvert', | ||
['message_unlocked'] = 'fermé', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Locales ['sv'] = { | ||
['message_title'] = '^3Fordonslås', | ||
['message_locked'] = 'du låste fordonet', | ||
['message_unlocked'] = 'du låste upp fordonet', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Locales ['tr'] = { | ||
['message_title'] = '^3Araç kilidi', | ||
['message_locked'] = 'kilitli', | ||
['message_unlocked'] = 'açık', | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |