Files
Elite-Gaming-FiveM/resources/Supply-Line/cl_utils.lua
T
2025-06-04 19:16:07 -07:00

142 lines
4.9 KiB
Lua

vRP = nil
ESX = nil
if Config.Notifications.Enabled and Config.Notifications.Framework.vRP then
local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")
vRP = Proxy.getInterface("vRP")
end
if Config.Notifications.Enabled and Config.Notifications.Framework.ESX then
ESX = exports["es_extended"]:getSharedObject()
end
if Config.EnablePositioningCommand then
TriggerEvent('chat:addSuggestion', '/'.."findhosepositioning", "Find positioning of the hose/supply line on your fire truck")
RegisterCommand("findhosepositioning", function(source, args)
local ped = PlayerPedId()
local targetVehicle = GetVehiclePedIsIn(ped, false)
if targetVehicle == nil or targetVehicle == 0 then
Notify("No vehicle found!")
else
local model = `p_ld_soc_ball_01`
SetEntityAlpha(targetVehicle, 150, false)
RequestModel(model)
while not HasModelLoaded(model) do Wait(0) end
local ballProp = CreateObject(model, coords, false, false, false)
while not DoesEntityExist(ballProp) do Wait(0) end
SetModelAsNoLongerNeeded(model)
local offSet = {0.0, 0.0, 0.0}
local rotation = {0.0, 0.0, 0.0}
local offSetComplete = false
while not offSetComplete do
if targetVehicle ~= nil and targetVehicle ~= 0 then
DetachEntity(ballProp, true, false)
AttachEntityToEntity(ballProp, targetVehicle, -1, offSet[1], offSet[2], offSet[3], rotation[1], rotation[2], rotation[3], true, false, true, false, 1, true)
if not IsControlReleased(0, 207) then --page down
offSet = {offSet[1], offSet[2], offSet[3] - 0.01}
end
if not IsControlReleased(0, 208) then --page up
offSet = {offSet[1], offSet[2], offSet[3] + 0.01}
end
if not IsControlReleased(0, 173) then --arrow down
offSet = {offSet[1], offSet[2] - 0.01, offSet[3]}
end
if not IsControlReleased(0, 172) then --arrow up
offSet = {offSet[1], offSet[2] + 0.01, offSet[3]}
end
if not IsControlReleased(0, 174) then --arrow left
offSet = {offSet[1] - 0.01, offSet[2], offSet[3]}
end
if not IsControlReleased(0, 175) then --arrow right
offSet = {offSet[1] + 0.01, offSet[2], offSet[3]}
end
if IsControlJustPressed(0, 191) then -- enter - finish
offSetComplete = true
end
end
Wait(0)
end
Notify("OffSet Values are now printed in your console")
print("OffSet: {"..offSet[1]..", "..offSet[2]..", "..offSet[3].."}")
DeleteEntity(ballProp)
ResetEntityAlpha(targetVehicle)
end
end, false)
end
function Notify(text)
if not Config.Notifications.Enabled then
return
end
if Config.Notifications.Framework.ESX then
if ESX ~= nil then
ESX.ShowNotification(text)
end
elseif Config.Notifications.Framework.QBCore then
TriggerEvent('QBCore:Notify', text, 'info')
elseif Config.Notifications.Framework.QBX then
exports.qbx_core:Notify(text, 'primary')
elseif Config.Notifications.Framework.vRP then
vRP.notify(source, {text})
elseif Config.Notifications.Framework.okok then
exports['okokNotify']:Alert("Supply Line", text, 2000, 'info', true)
else
showBaseNotification(text)
end
end
function showBaseNotification(message)
-- Base game notifications
SetNotificationTextEntry("STRING")
AddTextComponentString(message)
DrawNotification(0,1)
end
function DisplayHelpText(text)
SetTextComponentFormat("STRING")
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, 0, ConfigHose.Notifications.HelpTextSound, -1)
end
function drawInstructionalText(msg, coords)
AddTextEntry('instructionalText', msg)
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z)
SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
BeginTextCommandDisplayHelp('instructionalText')
AddTextComponentSubstringPlayerName(msg)
EndTextCommandDisplayHelp(2, false, false, -1)
end
function DrawTextOnScreen(text, x, y, scale, r, g, b, a, center)
SetTextFont(0)
SetTextProportional(1)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
if center then
SetTextCentre(1)
end
AddTextComponentString(text)
DrawText(x, y)
end