ghandolhagen 11 Posted October 20, 2013 Hey all, running into a bug? I have a pack of civilians that I want to turn into a ragtag bunch of asshole mercs. The problem is that when I give them specific hats that I want them to wear and test the game, their hats change to a random civilian hat. Kind of hard to take a merc seriously when he is wearing a wicker fedora... Any ideas? Thanks a bunch. Share this post Link to post Share on other sites
dr_strangepete 5 Posted October 20, 2013 show us the code you're using Share this post Link to post Share on other sites
ghandolhagen 11 Posted October 20, 2013 removeAllAssignedItems this; removeHeadgear this; removeUniform this; this addHeadgear "H_Cap_blk"; This is the code that is relevant. I start by stripping the civilian down to nothing and then start adding everything back in that I want. In this case, the above code should give the civilian a black ball cap. Every time I test the mission, the character is given a random hat out of all possible hats. It changes every time I test. Thanks for any assistance. Share this post Link to post Share on other sites
sxp2high 22 Posted October 20, 2013 You probably just need a little delay to make sure your headgear is applied last. Try this: nul = this spawn { sleep 1; removeAllAssignedItems _this; removeHeadgear _this; removeUniform _this; _this addHeadgear "H_Cap_blk"; }; Share this post Link to post Share on other sites
ghandolhagen 11 Posted October 20, 2013 (edited) Cheers! I'll give it a try. :D ---------- Post added at 19:24 ---------- Previous post was at 19:09 ---------- Hey thanks it works! Just so I understand what the code is doing would you mind walking through it? I am getting the delay of sleep 1; However I don't understand how spawn is used or rather nul in this context. Thanks again for your help! My pack of scumbag opportunists now look serious instead of ridiculous. Edited October 20, 2013 by ghandolhagen Share this post Link to post Share on other sites
sxp2high 22 Posted October 20, 2013 From the bit of code you posted, I assumed you are using a unit's init line. If you are executing this from within a script you wouldn't need the spawn. nul = Is there because spawn requires some handle when used in unit init lines. It's useless to have a handle in this case so we use a non-existing variable for it. Just because we have to assign something. spawn Is there because delays (sleep) are not allowed within the mission scope itself (vehicle/unit init lines). So we have to spawn a new thread/virtual machine to use sleep. I'm not very good at explaining things, I hope you get it. :) Share this post Link to post Share on other sites
ghandolhagen 11 Posted October 20, 2013 Thanks again. Much appreciated! Share this post Link to post Share on other sites