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"
|
||||
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'
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue