fix: spillerens bil køres ikke selv hjem efter 10 min

This commit is contained in:
2026-10-19 18:41:45 +02:00
parent a935aef9d6
commit 726519b3ab
3 changed files with 18 additions and 4 deletions
+16 -3
View File
@@ -26,9 +26,11 @@ function ADPlayerClaim.isClaimed(s)
return true
end
-- Kør selv hjem nu? s = {wasClaimed, claimed, motorized, busy, atOwnPark, hasPark}
-- Kør selv hjem nu? s = {wasClaimed, claimed, motorized, busy, atOwnPark, hasPark, isCar}
-- En bil (butikskategori CARS) er spillerens transport: den bliver, hvor han satte den (in-game 19/10 18:39: "hvad skal
-- moddet bruge min bil til ??" — Pickup 2017 kørte selv til sin AD-parkering)
function ADPlayerClaim.returnAction(s)
if not s.wasClaimed or s.claimed or not s.motorized or s.busy or s.atOwnPark then return nil end
if not s.wasClaimed or s.claimed or not s.motorized or s.busy or s.atOwnPark or s.isCar then return nil end
return s.hasPark and "home" or "noPark"
end
@@ -117,6 +119,16 @@ local function isBusy(vehicle)
return ADFlowWagons ~= nil and ADFlowWagons.statusOf ~= nil and ADFlowWagons.statusOf(vehicle) ~= nil
end
local function isCar(vehicle)
if g_storeManager == nil or vehicle.configFileName == nil then return false end
local item = g_storeManager:getItemByXMLFilename(vehicle.configFileName)
if item == nil then return false end
for _, category in ipairs(type(item.categoryNames) == "table" and item.categoryNames or {item.categoryName}) do
if string.lower(tostring(category)) == "cars" then return true end
end
return false
end
local function sendHome(vehicle)
local hasRear = ADHitch ~= nil and #ADHitch.rearImplementsOf(vehicle) > 0
if hasRear and ADFlowWagons ~= nil and ADFlowWagons.homeVehicle ~= nil then
@@ -140,7 +152,8 @@ local function checkReturn(vehicle)
local motorized = vehicle.spec_motorized ~= nil
local okPark, parkId = pcall(ADFieldWork.parkMarkerId, env, vehicle)
local action = ADPlayerClaim.returnAction({wasClaimed = true, claimed = false, motorized = motorized,
busy = motorized and isBusy(vehicle), atOwnPark = motorized and atOwnPark(vehicle), hasPark = okPark and parkId ~= nil})
busy = motorized and isBusy(vehicle), atOwnPark = motorized and atOwnPark(vehicle), hasPark = okPark and parkId ~= nil,
isCar = motorized and isCar(vehicle)})
if action == "home" then
sendHome(vehicle)
elseif action == "noPark" and not loggedNoPark[vehicle] then
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.62.383.0</version>
<version>1.62.384.0</version>
<title>
<en>AD Smart Pickup</en>
</title>