Jump to content
Sign in to follow this  
nullsystems

Trigger, addAction for only that player

Recommended Posts

Hello,

Silly question but my brain has decided to fail me again

Trigger:

cond: blufor present

onact: addaction to this player only

onde: removeaction from this player only

How can I sort this out so the trigger only does this to one player and not everyone?

Share this post


Link to post
Share on other sites

I would avoid removing (and readding) actions as much as possible and instead use the new ability to give actions conditions:

player addAction ["Action","script.sqf",[],1,true,true,"","_this == player && <insert condition for trigger>"]

Share this post


Link to post
Share on other sites

So you could do something like this...?

player addAction ["Action","script.sqf",[],1,true,true,"","_this == player && player distance truck < 10"]

But that would still add actions to everyone?

Share this post


Link to post
Share on other sites
But that would still add actions to everyone?

Well, to everone who is closer than 10meters to the truck. Noone else.

Share this post


Link to post
Share on other sites
So you could do something like this...?

player addAction ["Action","script.sqf",[],1,true,true,"","_this == player && player distance truck < 10"]

But that would still add actions to everyone?

Well, you never specified which player.

player addAction ["Action","script.sqf",[],1,true,true,"","_this == <name of player unit> && _this distance truck < 10"]

Share this post


Link to post
Share on other sites

Right, well, I know you dont have to specific a name of a player...

Its just ANY player that goes in the trigger.

Share this post


Link to post
Share on other sites

Oh, well then in that case this is fine:

player addAction ["Action","script.sqf",[],1,true,true,"","_this == player && _this distance truck < 10"]

Share this post


Link to post
Share on other sites

The only problem is:

I need the trigger on repeat.

That version you show there wont work, as everytime someone enters the trigger, people inside will get another addaction.

Share this post


Link to post
Share on other sites

What exactly are you trying to do? What is the trigger? What is it on? Who's supposed to use it?

Share this post


Link to post
Share on other sites
The only problem is:

I need the trigger on repeat.

That version you show there wont work, as everytime someone enters the trigger, people inside will get another addaction.

No no no no no....

Wrong. Sorry this is my fault, I should have been more clear.

Don't use the addaction in the trigger. Just add the action ONCE (like in an init field), then you don't even need the trigger.

Share this post


Link to post
Share on other sites
No no no no no....

Wrong. Sorry this is my fault, I should have been more clear.

Don't use the addaction in the trigger. Just add the action ONCE (like in an init field), then you don't even need the trigger.

Ok, thats more clear ty :)

However, will this remove itself once the conditions are no longer met?

And, will they re-add the addaction if the conditions are met again?

Share this post


Link to post
Share on other sites

The action won't ever be removed, it just won't show up to anybody unless those conditions are met. So yes, if you move far away from the truck it will go away, and if you get close again it will reappear.

Edit: What's with that thumbs down... did I do that? Oops...

Share this post


Link to post
Share on other sites

This is the exact line I need:

player addAction ["UH","view.sqf",(v6)];

The method you showed does not work as "v6" is a vehicle with a respawn script.

Once the vehicle has respawned I set the name "v6" back to it, this is perfect and works fine.

However, if I meet the conditions of the addaction it cannot find "v6" anymore. PRobably something to do with the original vehicle not matching the memory location of the variable set in the init or some such.

Either way, that didnt work.

If I set and the remove the addaction in a trigger then its fine.

BUT, as I mentioned the addaction shows for everyone on the game, since it was set in a trigger :/

Share this post


Link to post
Share on other sites

It should still work, but if not you can always try this:

player addAction ["Action","script.sqf",[],1,true,true,"","_this == player && triggerActivated <triggerName>"]

Then keep your trigger with the correct condition, but don't put anything in the On Activation field. That will make the action only appear when the conditions for your trigger are met.

Share this post


Link to post
Share on other sites

I dont understand how that will help.

I have to pass an argument to the addAction script.

That argument points to a vehicle name.

When the vehicle dies, I reset its name after it respawns.

IF the addAction is not removed and a new one set ( with removeAction ) the argument no longer points to the new object so the script wont work.

By using that method, which does not remove the addAction, but just hides it, the new vehicle is never found.

Share this post


Link to post
Share on other sites

Oh, ok. Several solutions. If you just set the vehicle's name back to what it originally was after it respawns (search forums to find out how, if you can't find an existing thread create a new one since this is a different issue) it will work as is (probably the best idea, since it will make things easier if you need to reference this vehicle elsewhere). Alternatively you can pass something else that you can use to reference the vehicle, say a trigger name that detects the vehicle using some other method.

Edit: Btw, if you are adding the action to a vehicle that respawns, the action will have to be added again after it respawns.

Share this post


Link to post
Share on other sites

Forgive me if I'm late on the bandwagon or pulling up an old thread - I've been working on getting an action that will appear when people are close to an "Informant" to start a "direct chat" script to "collect information". While I want ANYONE to be able to talk to him, I ONLY want one particular player to be present to actually get the information from him....

For the player I want to be able to question the "informant I would put something like....

player addAction ["Greet Informant","script.sqf",[],1,true,true,"","_this == <PL> && _this distance informant < 5"]

and for everyone else it would be like...

player addAction ["Hello","script_general.sqf",[],1,true,true,"","_this == player && player distance informant < 5"]

So it would look like player addAction ["Hello","script_general.sqf",[],1,true,true,"","_this == player && player distance informant < 5"]; player addAction ["Greet Informant","script.sqf",[],1,true,true,"","_this == <PL> && _this distance informant < 5"]; - in the "informants" init line?

is that what I understand correct? Then when the PL is within 5m it will show him "Greet Informant" but everyone else gets "Hello"?

Share this post


Link to post
Share on other sites

Just add the "Hello" script to the informant and the "Greet" action to the player in question. Both could them use the same distance check "player distance informant < 5".

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  

×