Skip to content

Commit d45a41f

Browse files
committed
Merge branch 'dev'
2 parents 64437f2 + 9f3762c commit d45a41f

12 files changed

Lines changed: 158 additions & 47 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.1.0] -- 2024-10-28
8+
## [0.2.0] - 2024-11-16
9+
10+
### Fixed
11+
12+
- Vehicle mod data not syncing properly when claiming.
13+
14+
### Added
15+
16+
- Sandbox option to discard previous vehicle interior when converting to pinkslip.
17+
- A warning when discarding vehicle interior.
18+
19+
## [0.1.0] - 2024-10-28
920

1021
### Added
1122

src/media/lua/client/AoqiaCarwannaExtendedClient/actions/create_pinkslip.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ end
4343

4444
function create_pinkslip:update()
4545
self.character:faceThisObject(self.vehicle)
46-
self.character:setMetabolicTarget(Metabolics.LightDomestic)
46+
self.character:setMetabolicTarget(Metabolics.LightDomestic --[[@as float]])
4747

48-
if self.character:getEmitter():isPlaying(self.sound) == false then
48+
if self.character:getEmitter():isPlaying(self.sound --[[@as string]]) == false then
4949
self.sound = self.character:playSound("CreatePinkslip")
5050
end
5151
end
@@ -121,7 +121,7 @@ function create_pinkslip:perform()
121121
local key = player_inventory:haveThisKeyId(self.vehicle:getKeyId())
122122
if key and mdata.HasKey == false then
123123
mdata.MakeKey = true
124-
player_inventory:Remove(key)
124+
player_inventory:Remove(key --[[@as string]])
125125
end
126126

127127
local parts = mdata.Parts
@@ -248,10 +248,11 @@ function create_pinkslip:perform()
248248
mdata.PartsMissing = missing_parts
249249

250250
-- Remove form item if required.
251-
if sbvars.DoRequiresAutoForm and sbvars.DoKeepAutoForm == false then
251+
if sbvars.DoRequiresAutoForm then
252252
logger:debug("Removing form from inventory...")
253253

254254
local form = player_inventory:getFirstTypeRecurse(mod_constants.MOD_ID .. ".AutoForm")
255+
--- @diagnostic disable-next-line: param-type-mismatch
255256
form:getContainer():Remove(form)
256257
end
257258

src/media/lua/client/AoqiaCarwannaExtendedClient/ui/pinkslip.lua

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,23 @@ end
6464
--- @param player IsoPlayer
6565
--- @param vehicle BaseVehicle
6666
function pinkslip.confirm_dialog(player, vehicle)
67+
local sbvars = SandboxVars[mod_constants.MOD_ID] --[[@as SandboxVarsDummy]]
68+
6769
local player_num = player:getPlayerNum()
6870

69-
local confirm_text = getText(
70-
("IGUI_%s_ConfirmText"):format(mod_constants.MOD_ID),
71-
getText("IGUI_VehicleName" .. vehicle:getScript():getName()))
71+
local interior_warning = nil
72+
if sbvars.DoCompatRvInteriors and sbvars.DoUnassignInterior and RVInterior.vehicleHasInteriorParameters(vehicle) then
73+
interior_warning = getText(("IGUI_%s_ConfirmInteriorWarning"):format(mod_constants.MOD_ID))
74+
end
75+
76+
local confirm_text = getText(("IGUI_%s_ConfirmText"):format(mod_constants.MOD_ID),
77+
getText("IGUI_VehicleName" .. vehicle:getScript():getName()))
78+
.. " <LINE> <RGB:1,0,0> "
79+
80+
if interior_warning then
81+
confirm_text = confirm_text .. interior_warning
82+
end
83+
7284
local modal = ISModalRichText:new(
7385
0,
7486
0,
@@ -400,14 +412,34 @@ function pinkslip.add_option_to_menu(player, context, vehicle)
400412
if sq_dist == nil
401413
or (sbvars.SafehouseDistance == 0 and in_safehouse_area == false)
402414
or (sbvars.SafehouseDistance > 0 and sq_dist > sbvars.SafehouseDistance) then
403-
text = text ..
404-
" <LINE> <LINE> <RGB:1,0,0> " ..
405-
getText(("Tooltip_%s_DoSafehouseOnly"):format(mod_constants
406-
.MOD_ID))
415+
text = text
416+
.. " <LINE> <LINE> <RGB:1,0,0> "
417+
.. getText(("Tooltip_%s_DoSafehouseOnly"):format(mod_constants.MOD_ID))
407418
not_available = true
408419
end
409420
end
410421

422+
-- Shouldn't be able to claim if your friends are in the interior LOL.
423+
if sbvars.DoCompatRvInteriors and RVInterior.vehicleHasInteriorParameters(vehicle) then
424+
local interior_vehicle_name = RVInterior.getVehicleName(vehicle_name)
425+
local interior_vehicle_moddata = RVInterior.getVehicleModData(vehicle,
426+
RVInterior.getInteriorParameters(interior_vehicle_name))
427+
428+
if interior_vehicle_moddata then
429+
local online_players = getOnlinePlayers()
430+
for i = 1, online_players:size() do
431+
local target = online_players:get(i - 1) --[[@as IsoPlayer]]
432+
433+
if RVInterior.playerInsideInterior(target) == interior_vehicle_name then
434+
text = text
435+
.. " <LINE> <LINE> <RGB:1,0,0> "
436+
.. getText(("Tooltip_%s_PlayersInInterior"):format(mod_constants.MOD_ID))
437+
not_available = true
438+
end
439+
end
440+
end
441+
end
442+
411443
-- Do admin override if enabled.
412444
if not_available
413445
and player:getAccessLevel() == "Admin"

src/media/lua/server/AoqiaCarwannaExtendedServer/commands.lua

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ function commands.spawn_vehicle(player, args)
3636
logger:info_server("Spawning vehicle (%s) at (%f, %f, %f).",
3737
tostring(args.FullType), x, y, z)
3838

39-
-- Check if vehicle exists
39+
-- Check if player is on Z level 0.
40+
-- The engine is limited to only spawning vehicles on Z-level 0.
41+
if z > 0 then
42+
logger:info_server("Failed to spawn vehicle as the player is not on Z-level 0.")
43+
player.setHaloNote(getText(("IGUI_%s_HaloNote_NotOnGround"):format(mod_constants.MOD_ID)),
44+
1, 0, 0, (128.0 * 4))
45+
46+
return
47+
end
48+
49+
-- Check if vehicle exists.
4050
if ScriptManager:getVehicle(args.FullType) == nil then
4151
logger:warn_server(
4252
"Failed to spawn vehicle as the vehicle does not exist.")
43-
player:setHaloNote(getText(
44-
("IGUI_%s_HaloNote_NilVehicle"):format(mod_constants.MOD_ID)
45-
))
53+
player.setHaloNote(getText(("IGUI_%s_HaloNote_NilVehicle"):format(mod_constants.MOD_ID)),
54+
1, 0, 0, (128.0 * 4))
4655

4756
return
4857
end
@@ -52,9 +61,8 @@ function commands.spawn_vehicle(player, args)
5261
and player:getInventory():containsTypeRecurse("AutoForm") == false then
5362
logger:info_server(
5463
"Failed to spawn vehicle as the player does not have an AutoForm.")
55-
player:setHaloNote(getText(
56-
("IGUI_%s_HaloNote_NoAutoForm"):format(mod_constants.MOD_ID)
57-
))
64+
player.setHaloNote(getText(("IGUI_%s_HaloNote_NoAutoForm"):format(mod_constants.MOD_ID)),
65+
1, 0, 0, (128.0 * 4))
5866

5967
return
6068
end
@@ -63,9 +71,9 @@ function commands.spawn_vehicle(player, args)
6371
if square:isVehicleIntersecting() then
6472
logger:info_server(
6573
"Failed to spawn vehicle, there is already a vehicle spawned there.")
66-
player:setHaloNote(getText(
67-
("IGUI_%s_HaloNote_VehicleIntersecting"):format(mod_constants.MOD_ID)
68-
))
74+
player.setHaloNote(
75+
getText(("IGUI_%s_HaloNote_VehicleIntersecting"):format(mod_constants.MOD_ID)),
76+
1, 0, 0, (128.0 * 4))
6977

7078
return
7179
end
@@ -166,6 +174,21 @@ function commands.spawn_vehicle(player, args)
166174
end
167175
end
168176

177+
-- Sync mod data to vehicle.
178+
if args.ModData then
179+
logger:debug_server("Syncing mod data.")
180+
181+
for k, v in pairs(args.ModData) do
182+
vehicle:getModData()[k] = v
183+
end
184+
end
185+
186+
-- Give the player the autoform back if sandbox option is on
187+
if sbvars.DoKeepAutoForm then
188+
--- @diagnostic disable-next-line: redundant-parameter
189+
player:sendObjectChange("addItem", { item = InventoryItemFactory.CreateItem("AutoForm") })
190+
end
191+
169192
local parts = args.Parts
170193
if parts == nil
171194
or parts.index == nil

src/media/lua/server/AoqiaCarwannaExtendedServer/events.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function events.on_client_command(module, command, player, args)
2727
end
2828

2929
logger:info_server("Received client command (%s) from player (%s) <%s>.", command,
30-
player:getUsername(), tostring(player:getSteamID()))
30+
player:getUsername(), tostring(getSteamIDFromUsername(player:getUsername())))
3131
commands[command](player, args)
3232
end
3333

src/media/lua/server/AoqiaCarwannaExtendedServer/recipes.lua

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,29 @@ end
3939
Recipe.OnCanPerform[mod_constants.MOD_ID].ClaimVehicle = function (recipe, player, item)
4040
--- @cast player IsoPlayer
4141

42-
local perform = true
43-
4442
local sbvars = SandboxVars[mod_constants.MOD_ID] --[[@as SandboxVarsDummy]]
4543

44+
local player_username = player:getUsername()
45+
logger:info_server("Player (%s) <%s> is trying to claim a vehicle using pinkslip!",
46+
tostring(player_username), tostring(getSteamIDFromUsername(player_username)))
47+
48+
local perform = true
49+
4650
-- If the player is not outside, don't claim it.
4751
local player_sq = player:getSquare()
4852
if player:isOutside() == false then
49-
player:setHaloNote(getText(("IGUI_%s_HaloNote_NotOutside")
50-
:format(mod_constants.MOD_ID)))
53+
player.setHaloNote(getText(("IGUI_%s_HaloNote_NotOutside"):format(mod_constants.MOD_ID)),
54+
1, 0, 0, (128.0 * 4))
55+
logger:debug_server("Failed to spawn vehicle as the player is not outside.")
5156
perform = false
5257
end
5358

5459
if player_sq:isVehicleIntersecting() then
55-
player:setHaloNote(getText(("IGUI_%s_HaloNote_VehicleIntersecting")
56-
:format(mod_constants.MOD_ID)))
60+
player.setHaloNote(
61+
getText(("IGUI_%s_HaloNote_VehicleIntersecting"):format(mod_constants.MOD_ID)),
62+
1, 0, 0, (128.0 * 4))
63+
logger:debug_server(
64+
"Failed to spawn vehicle as the player is intersecting with another vehicle.")
5765
perform = false
5866
end
5967

@@ -77,7 +85,7 @@ Recipe.OnCanPerform[mod_constants.MOD_ID].ClaimVehicle = function (recipe, playe
7785
for i = 1, safehouses:size() do
7886
local temp = safehouses:get(i - 1) --[[@as SafeHouse | nil]]
7987
if temp == nil then
80-
logger:error(
88+
logger:error_server(
8189
"Safehouse was nil while looping through the safehouse list.")
8290
break
8391
end
@@ -104,7 +112,7 @@ Recipe.OnCanPerform[mod_constants.MOD_ID].ClaimVehicle = function (recipe, playe
104112
end
105113

106114
if sq_dist == nil then
107-
logger:debug("sq_dist was nil, even after safehouse loop.")
115+
logger:debug_server("sq_dist was nil, even after safehouse loop.")
108116
end
109117

110118
-- Is the player in the safehouse area?
@@ -118,8 +126,9 @@ Recipe.OnCanPerform[mod_constants.MOD_ID].ClaimVehicle = function (recipe, playe
118126
if sq_dist == nil
119127
or (sbvars.SafehouseDistance == 0 and in_safehouse_area == false)
120128
or (sbvars.SafehouseDistance > 0 and sq_dist > sbvars.SafehouseDistance) then
121-
player:setHaloNote(getText(("IGUI_%s_HaloNote_NotInSafehouse")
122-
:format(mod_constants.MOD_ID)))
129+
player.setHaloNote(
130+
getText(("IGUI_%s_HaloNote_NotInSafehouse"):format(mod_constants.MOD_ID)),
131+
1, 0, 0, (128.0 * 4))
123132

124133
perform = false
125134
end
@@ -150,9 +159,9 @@ Recipe.OnCreate[mod_constants.MOD_ID].ClaimVehicle = function (
150159
local generated_key = false
151160
if mdata.Parts == nil then
152161
if sbvars.DoAllowGeneratedPinkslips == false then
153-
player:setHaloNote(
154-
getText(("IGUI_%s_HaloNote_NoGeneratedPinkslips")
155-
:format(mod_constants.MOD_ID)))
162+
player.setHaloNote(
163+
getText(("IGUI_%s_HaloNote_NoGeneratedPinkslips"):format(mod_constants.MOD_ID)),
164+
1, 0, 0, (128.0 * 4))
156165

157166
return
158167
end
@@ -164,20 +173,20 @@ Recipe.OnCreate[mod_constants.MOD_ID].ClaimVehicle = function (
164173
local count = 1
165174
while true do
166175
if count >= 60 then
167-
logger:error("Unable to select random vehicle due to timeout.")
176+
logger:error_server("Unable to select random vehicle due to timeout.")
168177
return
169178
end
170179

171180
vehicle_name = vehicle_names:get(ZombRand(0, vehicle_names:size() - 1)) --[[@as string]]
172181
local name_lower = vehicle_name:lower()
173-
logger:debug("Selecting random vehicle (%s).", vehicle_name)
182+
logger:debug_server("Selecting random vehicle (%s).", vehicle_name)
174183

175184
-- If vehicle not blacklisted, trailer, burnt, or smashed.
176185
if blacklist.vehicle_blacklist.index[vehicle_name] == nil
177186
and name_lower:contains("trailer") == false
178187
and name_lower:contains("burnt") == false
179188
and name_lower:contains("smashed") == false then
180-
logger:debug("Random vehicle selected.")
189+
logger:debug_server("Random vehicle selected.")
181190
break
182191
end
183192

@@ -205,6 +214,7 @@ Recipe.OnCreate[mod_constants.MOD_ID].ClaimVehicle = function (
205214
args.Hotwired = mdata.Hotwired or nil
206215
args.Rust = mdata.Rust or nil
207216
args.Skin = mdata.Skin or nil
217+
args.ModData = mdata.ModData or nil
208218

209219
args.Blood = mdata.Blood and {
210220
F = mdata.Blood.F,

src/media/lua/shared/AoqiaCarwannaExtendedShared/mod_constants.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local logger = require("AoqiaZomboidUtilsShared/logger")
99
local mod_constants = {}
1010

1111
mod_constants.MOD_ID = "AoqiaCarwannaExtended"
12-
mod_constants.MOD_VERSION = "0.1.0"
12+
mod_constants.MOD_VERSION = "0.2.0"
1313

1414
mod_constants.LOGGER = logger:new(mod_constants.MOD_ID)
1515

@@ -78,6 +78,7 @@ mod_constants.FUELTANK_NAMES = { "500FuelTank", "1000FuelTank" }
7878
--- @field DoDynamicPinkslipWeight boolean
7979
--- @field PinkslipWeight float
8080
--- @field PinkslipLootBlacklist string
81+
--- @field DoUnassignInterior boolean
8182
--- Main Vehicle Stuff
8283
--- @field DoVehicleLoot boolean
8384
--- @field DoCanHotwire boolean
@@ -100,6 +101,7 @@ mod_constants.FUELTANK_NAMES = { "500FuelTank", "1000FuelTank" }
100101
--- @field DoZedLoot boolean
101102
--- @field ZedLootChance float
102103
--- Mod Compatibility
104+
--- @field DoCompatRvInteriors boolean
103105
--- @field DoCompatTsarMod boolean
104106
--- @field DoCompatUdderlyRespawn boolean
105107
--- @field DoCompatColorExperimental boolean

src/media/lua/shared/translate/EN/IG_UI_EN.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IGUI_EN = {
44
IGUI_AoqiaCarwannaExtended_Pinkslip = "Pinkslip",
55

66
IGUI_AoqiaCarwannaExtended_ConfirmText = "Convert %1 into a Pinkslip?",
7+
IGUI_AoqiaCarwannaExtended_ConfirmInteriorWarning = "This vehicle's interior will be DELETED!",
78

89
// IGUI_AoqiaCarwannaExtended_VehicleName = "Vehicle Name: %1",
910
IGUI_AoqiaCarwannaExtended_VehicleSkin = "Body Style: %1",
@@ -19,4 +20,5 @@ IGUI_EN = {
1920
IGUI_AoqiaCarwannaExtended_HaloNote_NoGeneratedPinkslips = "Generated pinkslips are disabled!",
2021
IGUI_AoqiaCarwannaExtended_HaloNote_NotInSafehouse = "You are not in or near a safehouse!",
2122
IGUI_AoqiaCarwannaExtended_HaloNote_NotOutside = "You need to be outside to claim a vehicle!",
23+
IGUI_AoqiaCarwannaExtended_HaloNote_NotOnGround = "You need to be on the ground to claim a vehicle!",
2224
}

src/media/lua/shared/translate/EN/Sandbox_EN.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Sandbox_EN = {
1717
Sandbox_AoqiaCarwannaExtended_DoRequiresAutoForm_tooltip = "Requires an AutoForm to convert vehicles to pinkslips.",
1818

1919
Sandbox_AoqiaCarwannaExtended_DoKeepAutoForm = "Keep AutoForm",
20-
Sandbox_AoqiaCarwannaExtended_DoKeepAutoForm_tooltip = "Lets the player keep the AutoForm instead of removing it from their inventory when creating a pinkslip.",
20+
Sandbox_AoqiaCarwannaExtended_DoKeepAutoForm_tooltip = "Allows the player who claims a pinkslip to get the AutoForm used to create it.",
2121

2222
Sandbox_AoqiaCarwannaExtended_DoAutoFormLoot = "Enable AutoForm Loot",
2323
Sandbox_AoqiaCarwannaExtended_DoAutoFormLoot_tooltip = "Adds the Auto Form to the loot tables.",
@@ -43,6 +43,9 @@ Sandbox_EN = {
4343
Sandbox_AoqiaCarwannaExtended_PinkslipLootBlacklist = "Pinkslip Blacklist",
4444
Sandbox_AoqiaCarwannaExtended_PinkslipLootBlacklist_tooltip = "A list of generated pinkslip vehicles that should never spawn naturally. <LINE> Example: Base.Van;Base.SUV",
4545

46+
Sandbox_AoqiaCarwannaExtended_DoUnassignInterior = "Unassign Interior",
47+
Sandbox_AoqiaCarwannaExtended_DoUnassignInterior_tooltip = "With RV Interiors compatibility enabled, allows the pinkslip vehicle to not keep the interior assigned. <LINE> This does not delete the interior from the world itself!",
48+
4649
/* Main Vehicle Stuff --------------------- */
4750
Sandbox_AoqiaCarwannaExtended_SeparatorMainVehicleStuff = "-------- Main Vehicle Stuff --------",
4851

@@ -109,6 +112,9 @@ Sandbox_EN = {
109112
/* Mod Support Sandbox Options ------------ */
110113
Sandbox_AoqiaCarwannaExtended_SeparatorModSupport = "-------- Mod Support --------",
111114

115+
Sandbox_AoqiaCarwannaExtended_DoCompatRvInteriors = "RV Interiors Compatibility",
116+
Sandbox_AoqiaCarwannaExtended_DoCompatRvInteriors_tooltip = "Provides compatibility with RV Interiors mod.",
117+
112118
Sandbox_AoqiaCarwannaExtended_DoCompatTsarMod = "TsarLib 2.0 Compatibility",
113119
Sandbox_AoqiaCarwannaExtended_DoCompatTsawMod_tooltip = "Provides experimental support for TsarLib's vehicle modifications.",
114120

src/media/lua/shared/translate/EN/Tooltip_EN.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Tooltip_EN = {
33
Tooltip_AoqiaCarwannaExtended_Blacklisted = "This vehicle is blacklisted!",
44
Tooltip_AoqiaCarwannaExtended_HasPassengers = "This vehicle has passengers!",
55
Tooltip_AoqiaCarwannaExtended_Hotwired = "This vehicle is hotwired.",
6+
Tooltip_AoqiaCarwannaExtended_PlayersInInterior = "There are players in the interior!",
67

78
Tooltip_AoqiaCarwannaExtended_DoSafehouseOnly = "Can only be claimed in or near a safehouse protected area.",
89

0 commit comments

Comments
 (0)