Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nwvh authored Aug 5, 2023
1 parent f4d3184 commit 5ce6d0b
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
ESX = exports["es_extended"]:getSharedObject()
local ped = PlayerPedId()

-- Ox_Target stuff

local options = {
name = 'wx_carlock:target',
icon = 'fa-solid fa-lock',
icon = wx.targetIcon,
label = wx.Locale["TargetLabel"],
onSelect = function()
ToggleLock()
onSelect = function(data)
ToggleLock(data.entity)
end
}

if wx.targetSupport then exports.ox_target:addGlobalVehicle(options) end

-- Main functions

function ToggleLock()
local function vehLights(vehicle)
SetVehicleLights(vehicle, 2)
Wait(200)
SetVehicleLights(vehicle, 0)
Wait(150)
SetVehicleLights(vehicle, 2)
Wait(500)
SetVehicleLights(vehicle, 0)
end
local function vehHorn(vehicle)
StartVehicleHorn(vehicle, 200, "HELDDOWN", false)
Wait(300)
StartVehicleHorn(vehicle, 150, "HELDDOWN", false)
end

function ToggleLock(entity)
local vehicle
local ped = PlayerPedId()
local x,y,z = table.unpack(GetEntityCoords(ped))



if IsPedInAnyVehicle(ped, false) then
vehicle = GetVehiclePedIsIn(ped, false)
if not entity then
if IsPedInAnyVehicle(ped, false) then
vehicle = GetVehiclePedIsIn(ped, false)
else
vehicle = GetClosestVehicle(x,y,z, 8.0, 0, 71)
end
else
vehicle = GetClosestVehicle(x,y,z, wx.checkRadius, 0, 71)
vehicle = entity
end
if not DoesEntityExist(vehicle) then
if wx.Notifications.NoNearbyVehicles then
Expand All @@ -42,8 +59,8 @@ function ToggleLock()
icon = 'triangle-exclamation',
iconColor = '#f38ba8'
})
return
end
return
end

ESX.TriggerServerCallback('wx_carlock:getVeh', function(Owned)
Expand All @@ -62,9 +79,8 @@ function ToggleLock()
canCancel = false,
disable = wx.ToDisable,
anim = wx.Anim,
})
if wx.Sounds then PlaySoundFromCoord(-1,"PIN_BUTTON",x,y,z,"ATM_SOUNDS", true, 5, false) end

})
if wx.Notifications.Locked then
lib.notify({
title = wx.Locale["NotifyTitle"],
Expand All @@ -81,6 +97,8 @@ function ToggleLock()
iconColor = '#f38ba8'
})
end
if wx.Sounds then PlaySoundFromCoord(-1,"PIN_BUTTON",x,y,z,"ATM_SOUNDS", true, 5, false) end
vehLights(vehicle)
elseif lockStatus == 2 then -- Vehicle is locked
SetVehicleDoorsLocked(vehicle, 1)
ExecuteCommand(wx.commandOnUnLock)
Expand All @@ -92,9 +110,8 @@ function ToggleLock()
canCancel = false,
disable = wx.ToDisable,
anim = wx.Anim,
})
if wx.Sounds then PlaySoundFromCoord(-1,"PIN_BUTTON",x,y,z,"ATM_SOUNDS", true, 5, false) end

})
if wx.Notifications.Unlocked then
lib.notify({
title = wx.Locale["NotifyTitle"],
Expand All @@ -111,6 +128,9 @@ function ToggleLock()
iconColor = '#a6e3a1'
})
end
if wx.Sounds then PlaySoundFromCoord(-1,"PIN_BUTTON",x,y,z,"ATM_SOUNDS", true, 5, false) end
if wx.Horn then vehHorn(vehicle) end
if wx.Lights then vehLights(vehicle) end
end
else
if wx.Notifications.NotYourVehicle then
Expand Down Expand Up @@ -140,9 +160,9 @@ end
Citizen.CreateThread(function ()
while true do
Wait(0)
if IsPedInAnyVehicle(ped,false) and GetVehicleDoorLockStatus(GetVehiclePedIsIn(ped,false)) == 2 then
if IsPedInAnyVehicle(PlayerPedId(),false) and GetVehicleDoorLockStatus(GetVehiclePedIsIn(PlayerPedId(),false)) == 2 then
DisableControlAction(0,75,true)
elseif not IsPedInAnyVehicle(ped,false) then
elseif not IsPedInAnyVehicle(PlayerPedId(),false) then
EnableControlAction(0,75,true)
else
EnableControlAction(0,75,true)
Expand All @@ -151,8 +171,8 @@ Citizen.CreateThread(function ()
end)



RegisterCommand('carlock',function ()
ToggleLock()
Citizen.Wait(300)
end,false)
RegisterKeyMapping('carlock', 'Lock or Unlock your personal vehicle', 'keyboard', 'l')

0 comments on commit 5ce6d0b

Please sign in to comment.