Trixta 0 Posted April 15, 2007 Any way of checking if a unit has at least one magazine of a certain type? Obviously hasweapon only checks the weaponslots for weapons. I'm looking to check if the unit has picked up a particular magazine (pipebomb). I'm playing about with reading the unit's magazine array slot by slot to see if pipebomb comes up but am not having much joy. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_mags=magazines uspc; _magcount=0; #getbomb ?(_mags select _magcount="pipebomb"):goto "havebomb"; _magcount=_magcount+1; goto "getbomb" #havebomb titletext ["Okay, I'm tooled up. Let's get outta here.","plain down"]; ammodumpdone=true; exit All I need to know is if unit's magazines include a pipebomb. Share this post Link to post Share on other sites
shuko 59 Posted April 15, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> { scopename magcheck; if (_x == "Pipebomb") then { titletext ["Okay, I'm tooled up. Let's get outta here.","PLAIN DOWN"]; ammodumpdone = true; breakout magcheck; }; } foreach magazines uspc; EDIT: If you insist on doing it with SQS, you have an error in your script: ?(_mags select _magcount="pipebomb"):goto "havebomb"; Needs to be ?(_mags select _magcount == "pipebomb"):goto "havebomb"; Share this post Link to post Share on other sites
Trixta 0 Posted April 15, 2007 Thanks Shuko - that's the very thing. Just for the sake of tidying up and closing the post I've pasted in the full script which I run from [] exec "havebomb.sqs" in uspc's init line. havebomb.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#getbomb {scopename magcheck;if (_x == "Pipebomb") then {ammodumpdone = true;breakout magcheck;};} foreach magazines uspc; ?(ammodumpdone):goto "havebomb"; goto "getbomb" #havebomb titletext ["Okay, I'm tooled up. Let's get outta here.","PLAIN DOWN"]; exit Share this post Link to post Share on other sites
shuko 59 Posted April 15, 2007 Ermh... does that actually work? You have mixed SQS and SQF, and created useless lines. You could have just pasted my example into a file (havebomb.sqf for example) and called it with: nul=[] execVM "havebomb.sqf"; Share this post Link to post Share on other sites
Big Dawg KS 6 Posted April 16, 2007 Why do you need a script? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_X == "Pipebomb"} count (magazines unit) > 0 Share this post Link to post Share on other sites