mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
Merge pull request #79 from ND-Framework/fix/unlock-command-inconsistency
fix(server/commands): unlock command inconsistency
This commit is contained in:
@@ -266,30 +266,14 @@ lib.addCommand("unlock", {
|
|||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
}, function(source, args, raw)
|
}, function(source, args, raw)
|
||||||
local ped = GetPlayerPed(source)
|
local ped = GetPlayerPed(source)
|
||||||
local playerVeh = GetVehiclePedIsIn(ped)
|
|
||||||
local coords = GetEntityCoords(ped)
|
local coords = GetEntityCoords(ped)
|
||||||
local vehicles = GetAllVehicles()
|
local veh = lib.getClosestVehicle(coords, 2.5, true)
|
||||||
local maxDistance = 2.0
|
|
||||||
local closestVehicle
|
|
||||||
|
|
||||||
if not playerVeh or playerVeh == 0 or not DoesEntityExist(playerVeh) then
|
if not veh then return end
|
||||||
for i=1, #vehicles do
|
|
||||||
local vehicle = vehicles[i]
|
local state = Entity(veh).state
|
||||||
local vehicleCoords = GetEntityCoords(vehicle)
|
state.hotwired = true
|
||||||
local distance = #(coords-vehicleCoords)
|
state.locked = false
|
||||||
|
|
||||||
if distance < maxDistance then
|
|
||||||
maxDistance = distance
|
|
||||||
closestVehicle = vehicle
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not closestVehicle or not DoesEntityExist(closestVehicle) then return end
|
|
||||||
local state = Entity(closestVehicle).state
|
|
||||||
state.locked = false
|
|
||||||
else
|
|
||||||
local state = Entity(playerVeh).state
|
|
||||||
state.hotwired = true
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("revive", {
|
lib.addCommand("revive", {
|
||||||
|
|||||||
Reference in New Issue
Block a user