forked from Simnation/Main
104 lines
2.7 KiB
Lua
104 lines
2.7 KiB
Lua
|
|
function IsPlayerUnreachable()
|
|
local playerPed = PlayerPedId()
|
|
return IsPedInAnyVehicle(playerPed) or IsPedRagdoll(playerPed) or IsEntityDead(playerPed)
|
|
end
|
|
|
|
function IsVehicleLocked(vehicle)
|
|
return Contains({2, 3, 10}, GetVehicleDoorLockStatus(vehicle))
|
|
end
|
|
|
|
function CanVehicleHaveRoofbox(vehicle)
|
|
if IsVehicleAConvertible(vehicle, false) or not DoesVehicleHaveRoof(vehicle) then
|
|
return false
|
|
end
|
|
return true
|
|
end
|
|
|
|
function CanOpenRoofbox(vehicle)
|
|
return not IsVehicleLocked(vehicle)
|
|
end
|
|
|
|
function CanMoveCycles(vehicle, bike)
|
|
if GetPedInVehicleSeat(bike, -1) > 0 then
|
|
return false
|
|
end
|
|
|
|
return not IsVehicleLocked(vehicle)
|
|
end
|
|
|
|
|
|
function HasVehicleAccess(vehicle)
|
|
if not Config.removal.checkAccess or not Config.removal.checkAccess.system then
|
|
return true
|
|
end
|
|
|
|
local system = Config.removal.checkAccess.system
|
|
|
|
if system == 'qbx_vehiclekeys' or system == 'qb-vehiclekeys' then
|
|
return exports[system]:HasKeys(vehicle)
|
|
end
|
|
if system == 'vehicle_keys' then
|
|
local plate = GetVehicleNumberPlateText(vehicle)
|
|
return exports["vehicles_keys"]:doesPlayerOwnPlate(plate)
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
-- Keybinds display
|
|
local buttons = nil
|
|
local keybinds = {}
|
|
|
|
local threadRunning = false
|
|
local function StartKeybindDisplayThread()
|
|
if threadRunning then
|
|
return false
|
|
end
|
|
Citizen.CreateThread(function()
|
|
while buttons ~= nil do
|
|
local sleep = 1
|
|
|
|
DrawScaleformMovieFullscreen(buttons, 255, 255, 255, 255, 0)
|
|
|
|
Citizen.Wait(sleep)
|
|
end
|
|
|
|
threadRunning = false
|
|
end)
|
|
end
|
|
|
|
function AddKeybindDisplay(key, label)
|
|
buttons = nil
|
|
|
|
table.insert(keybinds, {
|
|
key = '~' .. key .. '~',
|
|
label = label,
|
|
})
|
|
|
|
buttons = RequestScaleformMovie("INSTRUCTIONAL_BUTTONS")
|
|
while not HasScaleformMovieLoaded(buttons) do
|
|
Wait(0)
|
|
end
|
|
|
|
BeginScaleformMovieMethod(buttons, "CLEAR_ALL")
|
|
EndScaleformMovieMethod()
|
|
|
|
for k, keybind in pairs(keybinds) do
|
|
BeginScaleformMovieMethod(buttons, "SET_DATA_SLOT")
|
|
ScaleformMovieMethodAddParamInt(k - 1)
|
|
ScaleformMovieMethodAddParamPlayerNameString(keybind.key)
|
|
PushScaleformMovieMethodParameterString(keybind.label)
|
|
EndScaleformMovieMethod()
|
|
end
|
|
|
|
BeginScaleformMovieMethod(buttons, "DRAW_INSTRUCTIONAL_BUTTONS")
|
|
EndScaleformMovieMethod()
|
|
|
|
StartKeybindDisplayThread()
|
|
end
|
|
|
|
function ClearKeybinds()
|
|
buttons = nil
|
|
keybinds = {}
|
|
end
|