forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
260aa8dcff
commit
812c710ac4
1 changed files with 16 additions and 9 deletions
|
@ -21,7 +21,7 @@ local function GetModelNameFromHash(hash)
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
end
|
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 function IsPlayerAtCorrectPosition(entity, containerType)
|
||||||
local playerPos = GetEntityCoords(PlayerPedId())
|
local playerPos = GetEntityCoords(PlayerPedId())
|
||||||
local entityPos = GetEntityCoords(entity)
|
local entityPos = GetEntityCoords(entity)
|
||||||
|
@ -50,8 +50,8 @@ local function IsPlayerAtCorrectPosition(entity, containerType)
|
||||||
-- For trailers, player should be at the rear (negative dot product)
|
-- For trailers, player should be at the rear (negative dot product)
|
||||||
return forwardDot < -0.7 -- Threshold to ensure player is behind the trailer
|
return forwardDot < -0.7 -- Threshold to ensure player is behind the trailer
|
||||||
else
|
else
|
||||||
-- For containers, player should be at the door (negative dot product, as doors are typically at the rear)
|
-- For containers, player should be at the front/door (positive dot product)
|
||||||
return forwardDot < -0.7 -- Threshold to ensure player is at the door end of the container
|
return forwardDot > 0.7 -- Threshold to ensure player is at the front/door of the container
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ local function IsNearValidContainer()
|
||||||
if distance <= 5.0 and distance < closestDistance then
|
if distance <= 5.0 and distance < closestDistance then
|
||||||
for _, containerType in pairs(Config.ContainerTypes) do
|
for _, containerType in pairs(Config.ContainerTypes) do
|
||||||
if model == GetHashKey(containerType.model) then
|
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
|
if IsPlayerAtCorrectPosition(object, containerType) then
|
||||||
foundEntity = object
|
foundEntity = object
|
||||||
foundType = containerType
|
foundType = containerType
|
||||||
|
@ -83,7 +83,7 @@ local function IsNearValidContainer()
|
||||||
else
|
else
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = Config.Notifications.title,
|
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'
|
type = 'error'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -254,9 +254,16 @@ local function StartContainerRobbery(container, containerType)
|
||||||
local offsetCoords
|
local offsetCoords
|
||||||
local playerHeading
|
local playerHeading
|
||||||
|
|
||||||
-- Both trailers and containers should position player at the rear
|
-- 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)
|
offsetCoords = GetOffsetFromEntityInWorldCoords(container, 0.0, -(containerLength/2 + 1.0), 0.0)
|
||||||
playerHeading = containerHeading + 180.0 -- Face the rear of the trailer/container
|
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
|
-- Set player position and heading
|
||||||
SetEntityCoords(PlayerPedId(), offsetCoords.x, offsetCoords.y, offsetCoords.z)
|
SetEntityCoords(PlayerPedId(), offsetCoords.x, offsetCoords.y, offsetCoords.z)
|
||||||
|
@ -599,7 +606,7 @@ RegisterNetEvent('container_heist:client:policeAlert', function(coords, streetNa
|
||||||
title = alertTitle,
|
title = alertTitle,
|
||||||
description = string.format(Config.Notifications.policeMessage, streetName),
|
description = string.format(Config.Notifications.policeMessage, streetName),
|
||||||
type = 'inform',
|
type = 'inform',
|
||||||
position = 'top',
|
position = 'right',
|
||||||
icon = alertIcon,
|
icon = alertIcon,
|
||||||
iconColor = '#ff0000'
|
iconColor = '#ff0000'
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue