Somerville 0 Posted July 9, 2008 Hi guys, I've got a bit of a problem, but hopefully you can help. I've got 22 civilians, each of whom has the same actions for any player on the WEST side. Here is what I have so far in my init.sqf to add these actions: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (side player == WEST) then { c1 addaction ["Arrest Civilian", "arrest.sqs"]; c1 addaction ["Fine Civilian", "fine.sqf"]; c1 addaction ["Disarm Civilian", "disarm.sqf"]; c1 addAction ["Check Licence", "clicence.sqs"]; c2 addaction ["Arrest Civilian", "arrest.sqs"]; c2 addaction ["Fine Civilian", "fine.sqf"]; c2 addaction ["Disarm Civilian", "disarm.sqf"]; c2 addAction ["Check Licence", "clicence.sqs"]; c3 addaction ["Arrest Civilian", "arrest.sqs"]; c3 addaction ["Fine Civilian", "fine.sqf"]; c3 addaction ["Disarm Civilian", "disarm.sqf"]; c3 addAction ["Check Licence", "clicence.sqs"]; C4 addaction ["Arrest Civilian", "arrest.sqs"]; c4 addaction ["Fine Civilian", "fine.sqf"]; c4 addaction ["Disarm Civilian", "disarm.sqf"]; c4 addAction ["Check Licence", "clicence.sqs"]; C5 addaction ["Arrest Civilian", "arrest.sqs"]; c5 addaction ["Fine Civilian", "fine.sqf"]; c5 addaction ["Disarm Civilian", "disarm.sqf"]; c5 addAction ["Check Licence", "clicence.sqs"]; C6 addaction ["Arrest Civilian", "arrest.sqs"]; c6 addaction ["Fine Civilian", "fine.sqf"]; c6 addaction ["Disarm Civilian", "disarm.sqf"]; c6 addAction ["Check Licence", "clicence.sqs"]; C7 addaction ["Arrest Civilian", "arrest.sqs"]; c7 addaction ["Fine Civilian", "fine.sqf"]; c7 addaction ["Disarm Civilian", "disarm.sqf"]; c7 addAction ["Check Licence", "clicence.sqs"]; C8 addaction ["Arrest Civilian", "arrest.sqs"]; c8 addaction ["Fine Civilian", "fine.sqf"]; c8 addaction ["Disarm Civilian", "disarm.sqf"]; c8 addAction ["Check Licence", "clicence.sqs"]; C9 addaction ["Arrest Civilian", "arrest.sqs"]; c9 addaction ["Fine Civilian", "fine.sqf"]; c9 addaction ["Disarm Civilian", "disarm.sqf"]; c9 addAction ["Check Licence", "clicence.sqs"]; C10 addaction ["Arrest Civilian", "arrest.sqs"]; c10 addaction ["Fine Civilian", "fine.sqf"]; c10 addaction ["Disarm Civilian", "disarm.sqf"]; c10 addAction ["Check Licence", "clicence.sqs"]; C11 addaction ["Arrest Civilian", "arrest.sqs"]; c11 addaction ["Fine Civilian", "fine.sqf"]; c11 addaction ["Disarm Civilian", "disarm.sqf"]; c11 addAction ["Check Licence", "clicence.sqs"]; C12 addaction ["Arrest Civilian", "arrest.sqs"]; c12 addaction ["Fine Civilian", "fine.sqf"]; c12 addaction ["Disarm Civilian", "disarm.sqf"]; c12 addAction ["Check Licence", "clicence.sqs"]; C13 addaction ["Arrest Civilian", "arrest.sqs"]; c13 addaction ["Fine Civilian", "fine.sqf"]; c13 addaction ["Disarm Civilian", "disarm.sqf"]; c13 addAction ["Check Licence", "clicence.sqs"]; C14 addaction ["Arrest Civilian", "arrest.sqs"]; c14 addaction ["Fine Civilian", "fine.sqf"]; c14 addaction ["Disarm Civilian", "disarm.sqf"]; c14 addAction ["Check Licence", "clicence.sqs"]; C15 addaction ["Arrest Civilian", "arrest.sqs"]; c15 addaction ["Fine Civilian", "fine.sqf"]; c15 addaction ["Disarm Civilian", "disarm.sqf"]; c15 addAction ["Check Licence", "clicence.sqs"]; C16 addaction ["Arrest Civilian", "arrest.sqs"]; c16 addaction ["Fine Civilian", "fine.sqf"]; c16 addaction ["Disarm Civilian", "disarm.sqf"]; c16 addAction ["Check Licence", "clicence.sqs"]; C17 addaction ["Arrest Civilian", "arrest.sqs"]; c17 addaction ["Fine Civilian", "fine.sqf"]; c17 addaction ["Disarm Civilian", "disarm.sqf"]; c17 addAction ["Check Licence", "clicence.sqs"]; C18 addaction ["Arrest Civilian", "arrest.sqs"]; c18 addaction ["Fine Civilian", "fine.sqf"]; c18 addaction ["Disarm Civilian", "disarm.sqf"]; c18 addAction ["Check Licence", "clicence.sqs"]; C19 addaction ["Arrest Civilian", "arrest.sqs"]; c19 addaction ["Fine Civilian", "fine.sqf"]; c19 addaction ["Disarm Civilian", "disarm.sqf"]; c19 addAction ["Check Licence", "clicence.sqs"]; C20 addaction ["Arrest Civilian", "arrest.sqs"]; c20 addaction ["Fine Civilian", "fine.sqf"]; c20 addaction ["Disarm Civilian", "disarm.sqf"]; c20 addAction ["Check Licence", "clicence.sqs"]; C21 addaction ["Arrest Civilian", "arrest.sqs"]; c21 addaction ["Fine Civilian", "fine.sqf"]; c21 addaction ["Disarm Civilian", "disarm.sqf"]; c21 addAction ["Check Licence", "clicence.sqs"]; C22 addaction ["Arrest Civilian", "arrest.sqs"]; c22 addaction ["Fine Civilian", "fine.sqf"]; c22 addaction ["Disarm Civilian", "disarm.sqf"]; c22 addAction ["Check Licence", "clicence.sqs"]; player addaction ["Stats", "stats.sqf"]; } else { player addaction ["Hands Up", "HandsUp.sqs"]; player addaction ["Stats", "stats.sqf"]; }; However, I have an issue in trying to make these actions happen for all players, even those who join in progress. Currently, it works for all players who start the map at the same time. However, it does not work for join in progress players. Is there a way of telling ArmA "Check if the actions are already on the unit - if they are, go away, if not, add them"? I'm not sure if naming each action would help - y'know, _arrestc1 = c1 addAction ["Blah", "blah.sqs"].. but surely there's a more efficient way? Share this post Link to post Share on other sites
Sol-TK 0 Posted July 9, 2008 Hi you need a new script instead of the init.sqf. Let's call this script actions.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (side player == west) then { { _x addaction ["Arrest Civilian", "arrest.sqs"]; _x addaction ["Fine Civilian", "fine.sqf"]; _x addaction ["Disarm Civilian", "disarm.sqf"]; _x addAction ["Check Licence", "clicence.sqs"]; } foreach [c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22]; player addaction ["Stats", "stats.sqf"]; } else { player addaction ["Hands Up", "HandsUp.sqs"]; player addaction ["Stats", "stats.sqf"]; }; Now, add a trigger with the following settings: Activation: None, Once Condition: local player On Activation: temp = [] execVM "actions.sqf" P.S. you should clear the init.sqf when you have done it this way. Share this post Link to post Share on other sites
Somerville 0 Posted July 9, 2008 Ah, I see - many thanks Any thoughts as to how Join In Progress will act with regards to this? Share this post Link to post Share on other sites
Somerville 0 Posted July 10, 2008 Hi, So, basically, the above seems to be working with Join in Progress. However, it's not working when a unit dies - they respawn without the actions. I put this into my init.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addeventhandler ["killed", {_this execVM "actions.sqf"}]; So that it runs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (side player == west) then { { _x addaction ["Arrest Civilian", "arrest.sqs"]; _x addaction ["Fine Civilian", "fine.sqf"]; _x addaction ["Disarm Civilian", "disarm.sqf"]; _x addAction ["Check Licence", "clicence.sqs"]; } foreach [c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22]; player addaction ["Stats", "stats.sqf"]; } else { player addaction ["Hands Up", "HandsUp.sqs"]; player addaction ["Stats", "stats.sqf"]; }; However, the problem I can see with this is that it will add the action to all units - C1, C2, C3 etc... regardless of whether or not they have the action already. Is this the case? Is there a way around this at all? Share this post Link to post Share on other sites