I've been working on a mod to help create something the community at large has been requesting. In order to make this happen however, I'm stuck on trying to figure out the lua code needed to modify the max storage capacity of a vehicles trunk.
I've tried the following without success:
for i=1,self.vehicle:getPartCount() do
local tpart = self.vehicle:getPartByIndex(i-1)
if tpart:getId():contains("Trunk") then
local tcap = self.vehicle:getPartByIndex(i-1):getContainerCapacity() + 30;
-- other unrelated code here --
self.vehicle:getPartByIndex(i-1):setContainerCapacity(tcap)
break;
end
end
This didn't update the capacity at all (and didn't oddly enough error out either). The other method I tried was this:
local playerObj = getSpecificPlayer(self.playerNum)
sendClientCommand(playerObj, "vehicle", "setContainerCapacity", { vehicle = self.vehicle:getId(), part = self.vehicle:getPartByIndex(i-1):getId(), amount = tcap})
My mod makes it so the trunk can't be uninstalled (I don't believe it can be normally anyways but I might be mistaken so I did it just to be safe), and attempts to make upgrades to the capacity of the trunk as actions are taken.
Anyone have an idea how to make this happen?