Pretty much all of the cargo scripts just delete the item, then assign it via a variable to the vehicle.Then later on when you "unload" it it will recreate the object. But to be honest this is not the easiest scripting tasks to start on. If you do end up doing it on your own then you need to break this up into much more manageable sections. Then work on the problems associated with those small secitons.
But since your using ACE you should probaly just use this:
http://wiki.ace-mod.net/wagn/Cargo
or this:
http://www.armaholic.com/page.php?id=9285