1
0
Fork 0
forked from Simnation/Main

Update main.lua

This commit is contained in:
Nordi98 2025-07-02 06:50:59 +02:00
parent 3a7652100b
commit 3c3b623d20

View file

@ -14,7 +14,7 @@ local boatOnTrailer = false
local function getTrailerOffset(trailer)
local model = GetEntityModel(trailer)
if model == `boattrailer6` then
return vector3(0.0, 4.0, 0.3) -- Adjusted values for boattrailer6 (moved forward toward hitch)
return vector3(0.0, 6.0, 0.3) -- Adjusted values for boattrailer6 (moved forward toward hitch)
else
return vector3(0.0, 1.8, 0.0) -- Original boattrailer values
end
@ -71,7 +71,7 @@ local function notify(text)
DrawNotification(true, false)
end
-- Function to check if boat is positioned over trailer
-- Replace the IsBoatOverTrailer function with this improved version
local function IsBoatOverTrailer(boat)
if not boat or not isSupportedBoat(boat) then return false end
@ -99,32 +99,54 @@ local function IsBoatOverTrailer(boat)
return foundTrailer
end
-- Add this new thread to handle E key press for securing boat
CreateThread(function()
while true do
Wait(1000)
Wait(0)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local closestVehicle, closestCoords = getClosestVehicle(playerCoords, 3.0)
if closestVehicle ~= nil and #(playerCoords - closestCoords) < 3.0 then
if not enteredCloseVehicle then
local isBoat = isSupportedBoat(closestVehicle)
-- Only check if player is in a vehicle
if IsPedInAnyVehicle(playerPed, false) then
local boat = GetVehiclePedIsIn(playerPed, false)
-- Check if it's a supported boat
if isSupportedBoat(boat) then
-- Check if boat is over a trailer
local trailer = IsBoatOverTrailer(boat)
if isTrailer(closestVehicle) then
closestTrailer = closestVehicle
elseif isBoat then
closestBoat = closestVehicle
if trailer then
-- Display help text
BeginTextCommandDisplayHelp("STRING")
AddTextComponentSubstringPlayerName("Press ~INPUT_CONTEXT~ to secure boat to trailer")
EndTextCommandDisplayHelp(0, false, true, -1)
-- Check for E key press
if IsControlJustReleased(0, 38) then -- 38 is E key
-- Exit the boat
TaskLeaveVehicle(playerPed, boat, 0)
-- Wait for player to exit
Wait(1500)
-- Attach boat to trailer
local attachOffset = getBoatAttachmentOffset(trailer)
AttachEntityToEntity(boat, trailer, 0, attachOffset.x, attachOffset.y, attachOffset.z, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
closestBoat = boat
closestTrailer = trailer
boatOnTrailer = true
notify("Boot am Anhänger befestigt")
end
end
end
enteredCloseVehicle = true
else
enteredCloseVehicle = false
Wait(1000) -- Wait longer if not in a vehicle
end
end
end)
CreateThread(function()
if GetResourceState('qb-target') == 'started' then
exports['qb-target']:AddGlobalVehicle({