diff --git a/TruckHUD.lua b/TruckHUD.lua index e005a54..86e691e 100755 --- a/TruckHUD.lua +++ b/TruckHUD.lua @@ -4212,14 +4212,16 @@ function luChecker.checkerLoad(playerId, data, position) -- if luChecker.truckers[playerId]["trailerData"]["trailerId"] ~= data["trailerId"] then sampAddChatMessage(data["trailerId"],-1) if getLocalPlayerId() ~= playerId then - local x, y, z = luChecker.load_position.x, luChecker.load_position.y, luChecker.load_position.z - local local_x, local_y, local_z = getCharCoordinates(PLAYER_PED) + + local trucker_x, trucker_y, trucker_z = position.x, position.y, position.z + local key, x, y, z = getKeysPoint(trucker_x, trucker_y, trucker_z) + + local local_x, local_y, local_z = getCharCoordinates(PLAYER_PED) local dist_localPlayer_storage = getDistanceBetweenCoords3d(local_x, local_y, local_z, x, y, z) local dist_trucker_storage = getDistanceBetweenCoords3d(trucker_x, trucker_y, trucker_z, x, y, z) if dist_localPlayer_storage <= 120.0 and dist_trucker_storage <= 50.0 then - local key = getKeysPoint(trucker_x, trucker_y, trucker_z) if key == "ls" or key == "sf" then if inifiles.Settings.luCheckerCargo >= 1 and inifiles.Settings.luCheckerCargo <= 3 then key = key..cargo_replace[inifiles.Settings.luCheckerCargo] @@ -4326,14 +4328,18 @@ end function getKeysPoint(x, y, z) local minDist, minResult = 1000000, "" + local resX, resY, resZ = 0.0, 0.0, 0.0 for name, cord in pairs(location_keys) do - local distance = getDistanceBetweenCoords3d(x, y, z, cord.x, cord.y, cord.z) - if distance < minDist then - minDist = distance - minResult = name + if not name:find("Аренда") and not name:find("Порт") then + local distance = getDistanceBetweenCoords3d(x, y, z, cord.x, cord.y, cord.z) + if distance < minDist then + minDist = distance + minResult = name + resX, resY, resZ = cord.x, cord.y, cord.z + end end end - return minResult + return minResult, resX, resY, resZ end