I've figured out what happened: on_entity_color_changed
is raised whenever an entity changes color, so before recoloring a vehicle we store vehicle.unit_number
and expected color. When the event is raised and both vehicle.unit_number
and color of the vehicle match the stored data, we skip the event – otherwise we try to set vehicle color to the color of the player who owns the vehicle (i.e. your friend). This works in single player (where the player also is the vehicle owner), but if we change vehicle.color
in multiplayer, it will be overridden with the color of the player who entered the vehicle. In this case, vehicle.color
and expected color differ, so we set vehicle.color
again which will raise another on_entity_color_changed
event, etc. – until the game crashes with a stack overflow error.
As a temporary fix, please replace lines 4721-4723 in function _common_vehicle.reset_color()
(file scripts/vehicles.lua):
if not (vehicle and vehicle.valid) then
AD.arg_err(vehicle, "vehicle")
end
with the following:
if not (vehicle and vehicle.valid) then
AD.arg_err(vehicle, "vehicle")
end
do
occupants = common_vehicle.get_occupants(vehicle)
local d = occupants and occupants.driver
local p = occupants and occupants.passenger
if (d and d.valid) or (p and p.valid) then
AD.entered_function({}, "leave", "Can't set vehicle color (player inside)!")
return
end
end
This way, vehicle won't be recolored if any player (or character connected to a player) is still inside the vehicle.