Jump to content
Sign in to follow this  
A-SUICIDAL

Removing actions

Recommended Posts

I have an action appear on the menu for player named s1 (me), then after using the action - the action is then removed using:

s1 removeAction 0;

Later the action gets added again, but to remove the action a second time, I have to use:

s1 removeAction 1;

and when the action is added again later I have to use:

s1 removeAction 2;

since the action is added many times throughout my mission, I decided to just use an .sqf file that has 60 removeAction commands for the player named s1.

So my question is... Instead of using 60 remove action commands, is there a way to script it somehow to be like:

s1 removeAction 0 through 100;

???

And if possible, how would I script it?

Share this post


Link to post
Share on other sites

Another way is to store the action id.

_id = s1 addAction [.......... ];
s1 setVariable ["TheAction", _id];

//Then later you can remove it

_id = s1 getVariable "TheAction";
s1 removeAction _id;

Share this post


Link to post
Share on other sites

You could also add it only once, and try to let the last parameter (condition field) define weather or not it is shown.

Share this post


Link to post
Share on other sites

The action ID always is transfered in the executed script with "_this select 2".

_object = _this select 0;

_action = _object addAction ["Action", "Action.sqs"];

Action.sqs

_object = _this select 0;
_id = _this select 2;

_object removeAction _id;

Another way:

_object = _this select 0;

_action = _object addAction ["Action", "Action.sqs"];

while { (alive _object) } do
{
      sleep 1;
};

_object removeAction _action;

Using it thouse way's will always remove the correct action.

Share this post


Link to post
Share on other sites

so, let say I have an 2 man coop mission, and the players are s1 and s2 and the action is "Use Med Kit" which will pop up on both players menu any time they get hit and using the action executes s1_med_kit.sqf or s2_med_kit.sqf depending on who got hit and then the action instantly vanishes from the actions menu. How would I script what you posted above?

Everything in my script is working perfectly, I just wanted to use an alternative method of removing the actions for both players. I am currently using s1_rem_action.sqf and s2_rem_action.sqf, and both remove sqf files have 60 removeAction commands, and if for some reason either player would use their medkit more than 60 times, the action would then remain on their actions menu, and even though I severely doubt either of the players would use their med kit more than 60 times,lol, I still want to get rid of the 60 removeAction commands and use what you described above instead, but I'm a total noob at scripting, so could you give an example of what you explained above for s1 and s2. And would I need to put the new scipt into my init.sqs file? Where would this stuff go?

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Whatever, I'll just leave the 60 removeAction commands. Just curious though, does it even matter to have that many commands? Meaning... doesn't the game just use the one removeAction command that it needs and ignores the rest of the commands? And then later when it runs the same script again, it would just use the next removeAction and ignore the rest. It's not like leaving 60 commands in the file is lagging me at all or anything.

Share this post


Link to post
Share on other sites

If you want to remove ALL addAction from a player you can use this:

// Remove all actions from the suspect
_action = _unit addAction["foo", "foo.sqf"];
while {_action >= 0} do	{
_unit removeAction _action;
_action = _action - 1;
};

Share this post


Link to post
Share on other sites

Here's a sample mission of what I have.

http://www.odaly.com/files/a2oa/MedKitTest.Takistan.zip

To test it, install it to your mission editing folder and open it in your editor and preview it. To test the med kit, I placed 4 ATV vehicles, just hop one and then drive straight into the wall. You wont die, but you will get hurt, so just hop off and use your med kit, then hop back on and hit the wall again if you want. The med kit works great. But it still has the 60 removeAction commands in the sqf files and I don't know how to apply the method of removing the actions as you described above without taking a completely different route of setting up the hit detection. Right now I am using 20000 radius triggers, each trigger grouped to a player and set on "repeatedly" and detects when they get hit. It was the only way I knew how to get it to work with unlimited respawns. I included a multiplayer pbo file so you can test to see that it does work online, but trust me, it does, so you don't need to bother with it. Anyway, I posted the link here so you could take a look at it in the editor and fix the 60 removeAction commands using your method instead, but only if you feel like helping me out, it would be omg very much appreciated. The way I have things set up to work is probably the way wrong route to take, but I am a noob at this stuff, although it does work and I had no help when I first created it, so I do feel like I did a good job with it for the most part. Like I said before, after a player uses his med kit more than 60 times, the action will then stay on his menu, but the chances of a player using it that many times is extremely slim, although... the real mission I am working on did take 3 hours for me and a few friends to complete and the med kit was used a lot. In any case, I could always increase the removeAction commands higher if needed, but I would prefer using your method.

I am using my med kit in a mission I am making that has unlimited respawn, no medics, no field hospitals, no place to go and heal at, and I do not use any revive scripts or first aid modules because they ruin the ability to use the med kit action when they cause you to be incapacitated. When you are incapacitated, you have no abilty to use any actions at all, which is so annoying, especially when you can still crawl and you have a med kit that you could have used if the damn first aid modules weren't in the mission. So if you use the med kit in a mission, don't use anything else that is first aid related. I hate that incapacitated stuff. As a leader of a group, you can command a wounded AI teammate to use his med kit and he will.

Also, I have the suicide script incorporated in this sample med kit test mission. I use the suicide action when I am stuck on a rock. There is a problem with the suicide script where the game tells me "Sound gunshot not found" and when I replace the sound with my sound, everything works fine except only the player suiciding can hear the pistol fire, other teammates standing near by do not hear the shot at all. Only the shooter hears the shot. So if you can figure out how to fix that, that would be really cool. Otherwise I am going to remove it from my mission completely and I really do not want to. Right now the suicide script is using an M9 sound that I recorded. The recorded sound has 1 second of silence before the fire sound occurs. I did this because the animation was out of sync with the animation. In my other mission that is using the suicide script, I removed all pistols except the M9 since I don't want players that are carrying a M9sd or G17 to hear the loud M9 shot that I added. In this test mission, some players have an M9sd, but just ignore that, lol. It's kind of hard to test the suicide script without somebody there to test with you online and tell you if they are hearing it when you suicide. Like I said before, when I tested it, only the shooter could hear the pistol fire.

Okay, that's enough ramble for me. I'll check back soon. My XFire is suicidal8000 if you wish to add me. Thanks in advance.

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

That's a pretty large wall of text for this early in the morning. Why not just have an addAction appear if they are damaged and disappear once they heal? No need for triggers or anything, just a simple addAction call.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×