From 812c710ac401a0ec3d51b1fbf77b4c60db16e3eb Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Sun, 20 Jul 2025 18:37:08 +0200 Subject: [PATCH] Update main.lua --- .../nordi_containerheist/client/main.lua | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua b/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua index 523e92389..267fcc29a 100644 --- a/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua +++ b/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua @@ -21,7 +21,7 @@ local function GetModelNameFromHash(hash) return "Unknown" end --- Function to check if player is at the correct position (rear for trailers, door for containers) +-- Function to check if player is at the correct position (rear for trailers, front/door for containers) local function IsPlayerAtCorrectPosition(entity, containerType) local playerPos = GetEntityCoords(PlayerPedId()) local entityPos = GetEntityCoords(entity) @@ -50,8 +50,8 @@ local function IsPlayerAtCorrectPosition(entity, containerType) -- For trailers, player should be at the rear (negative dot product) return forwardDot < -0.7 -- Threshold to ensure player is behind the trailer else - -- For containers, player should be at the door (negative dot product, as doors are typically at the rear) - return forwardDot < -0.7 -- Threshold to ensure player is at the door end of the container + -- For containers, player should be at the front/door (positive dot product) + return forwardDot > 0.7 -- Threshold to ensure player is at the front/door of the container end end @@ -74,7 +74,7 @@ local function IsNearValidContainer() if distance <= 5.0 and distance < closestDistance then for _, containerType in pairs(Config.ContainerTypes) do if model == GetHashKey(containerType.model) then - -- Check if player is at the door for containers + -- Check if player is at the front/door for containers if IsPlayerAtCorrectPosition(object, containerType) then foundEntity = object foundType = containerType @@ -83,7 +83,7 @@ local function IsNearValidContainer() else lib.notify({ title = Config.Notifications.title, - description = "You need to stand at the door end of the container!", + description = "You need to stand at the front/door of the container!", type = 'error' }) end @@ -254,9 +254,16 @@ local function StartContainerRobbery(container, containerType) local offsetCoords local playerHeading - -- Both trailers and containers should position player at the rear - offsetCoords = GetOffsetFromEntityInWorldCoords(container, 0.0, -(containerLength/2 + 1.0), 0.0) - playerHeading = containerHeading + 180.0 -- Face the rear of the trailer/container + -- Different positioning for trailers and containers + if string.match(containerType.type, "trailer") then + -- For trailers, position at the rear + offsetCoords = GetOffsetFromEntityInWorldCoords(container, 0.0, -(containerLength/2 + 1.0), 0.0) + playerHeading = containerHeading + 180.0 -- Face the rear of the trailer + else + -- For containers, position at the front/door + offsetCoords = GetOffsetFromEntityInWorldCoords(container, 0.0, (containerLength/2 + 1.0), 0.0) + playerHeading = containerHeading -- Face the front/door of the container + end -- Set player position and heading SetEntityCoords(PlayerPedId(), offsetCoords.x, offsetCoords.y, offsetCoords.z) @@ -599,7 +606,7 @@ RegisterNetEvent('container_heist:client:policeAlert', function(coords, streetNa title = alertTitle, description = string.format(Config.Notifications.policeMessage, streetName), type = 'inform', - position = 'top', + position = 'right', icon = alertIcon, iconColor = '#ff0000' })