Jump to content
Sign in to follow this  
SouthSaturnDelta

addaction to specific unit in a vehicle

Recommended Posts

Hi guys,

  I need to addaction to a specific player so only he can use a script when in a vehicle.

At the mo I just use

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">COM1 = AIR2 addaction ["do this...","somescript.sqs"]

which is cool for SP, but when MP comes along then anyone in,or near to AIR2 can use this option as well which will lead to bedlam.

The unit in question will be called,for example 'Jim', and only he may be allowed to use the action when in the vehicle 'AIR2'.

Any ways around this chaps?

Many thanks,

SSD

Share this post


Link to post
Share on other sites

I had a similar problem, and it was discussed at this thread in OFPEC:

http://www.ofpec.com/index.p....29498.0

When you add an action to a unit (or any object), anyone (player or AI) that is near that unit (or object) can execute the action. Even worse, when player is squad leader, and the player wishes to have an AI team mate execute an action, the action shows in the action list for every member of the squad (when you would want them to show up for only the squad member who the action was originally added to).

For my case, I created a radio trigger that was hardwired to the particular unit that needed the action. In your case, you could also add code at the beginning of the script that checks to see if Jim is in the chopper. If not, it can do nothing (or display "Jim must be in chopper before doing this".)

Hmmmmm, you could also control when you add the action. Detect when Jim is in the chopper, and add the action. Then remove the action when Jim exits the chopper. The action would only appear while Jim is in chopper.

Share this post


Link to post
Share on other sites

Create a repeating trigger with "none" as the drop down box.

Trigger:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Cond: (local player and player == driver heli)

onact: act1 = heli addaction ["Action", "something.sqs"]

ondeact: heli removeAction act1

Or:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Cond: (local player and player in crew heli1)

onact: act1 = heli addaction ["Action", "something.sqs"]

ondeact: heli removeAction act1

wink_o.gif

Also try adding this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Cond: not alive heli1

onact: heli removeAction act1

Share this post


Link to post
Share on other sites

nullsystems

This would make any units outside the chopper able to use those actions too I'm afraid, as you assign it to the chopper-object.

However, if its possible to add the action to jim when he is IN the chopper it would atleast limit the action to the ones currently in the chopper.

I'll play around with this for a bit, got nothing better todo xD

[edit]

It seems that adding actions to units in a vehicle isn't possible...

The action wont show up in the list of actions available. confused_o.gif

Share this post


Link to post
Share on other sites

Thanks for the posts guys.

Yeah, see this is my problem.When addaction to a vehicle,everyone can use it unless its an eventhandler in the config where only a pilot has options ect.Thats not an option obviously so I'm kinda stuck.

Unless when 'jim' starts initial script,these addactions are a sep script run from that.

he is noted as a variable,and when anyone in the chopper trys to run it,a clause is added so that if he isnt 'jim' then they wont work?

The options would still appear to everyone in the chopper,but only 'jim' could get em to work.

Gonna try working along those lines as it'll at least limit the availablity of use which is what I need to work.

Share this post


Link to post
Share on other sites

Passed to action

[unit, caller, ID](old style)

[unit, caller, ID,additional argument(s)] (new style)

so

_caller = _this select 1;

Will be the one who called the action

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if(_caller == jim) then{

//Do it

};

You have probably found that out wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]This would make any units outside the chopper able to use those actions too I'm afraid, as you assign it to the chopper-object.

Hmm, well I have 3 of my own scripts working on my current map with those exact settings, they work in multiplayer and with a combination of gunner, commander, crew and driver settings.. I can set addAction to anyone in the vehicle, and only them.

I do not understand why you say it would allow people outside the chopper to view?

player == driver heli1

^^ That in itself makes it driver only.

Share this post


Link to post
Share on other sites

Hmm, well I have 3 of my own scripts working on my current map with those exact settings, they work in multiplayer and with a combination of gunner, commander, crew and driver settings.. I can set addAction to anyone in the vehicle, and only them.

They surly works in mp, the other online players wont see the actions.

But, I think you misunderstand me and JohnnyBoy.

I'll explain below.

I do not understand why you say it would allow people outside the chopper to view?

JohnnyBoy and I are talking about AI units.

They are local to you in a MP game.

See:

Action added to vehicle

As you can see, my #2, in the yellow box, has the "added" action in his action-list seen in the green box.

My action(or rather the vehicle) can be seen in the blue box.

And, as mentioned, AI can use actions from 2,3 light years away.

And it's very annoying to have the actions in their list if you want to rearm-heal and etc.

I would like to believe you when you say you can add actions to the units IN the vehicle, but, unfortunately I do not. sad_o.gif

Action added to unit

See, no actions?

changing "(driver car)" to "player" doesn't work either.

So I'm curious to know how you did it?

Share this post


Link to post
Share on other sites

From the original post, here is what I understand:

1. If you are driver, you get new action.

2. If you are NOT driver, you get nothing new.

3. This must work for human players in MP.

I dont see anything else anywhere about AI apart from Taurus post.

The code I gave works 100%.

Create a simple trigger, with "none" as the setting. The rest filled in as I gave.

As soon as you are driver (player == driver whatever) : It executes the addaction command. Upon deactivation, it removes it.

Have you tried it Taurus? Because myself and other members from our clan are using it as I write this on our maps.

I also have the same system, but in a radius #loop.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#loop

@ player distance car < 4

?!alive car : car removeaction act;exit

?isEngineOn car : car removeaction act;exit

act = car addAction ["action","action.sqf"]

@ player != driver car

car removeaction act1

?isEngineOn car : car removeaction act;exit

@ player distance car > 4

?!alive car : car removeaction _act;exit

car removeaction act

~1

goto "loop"

^^ That also works, but is more messy

Share this post


Link to post
Share on other sites

I'm sure you can limit when the action is assigned to the player via nullsystems' approach (i.e., only add the action when the player is in the car).

And I am also sure that once you add the action to the player, that action will also appear as a valid action under any commanded AI's action lists (which is very annoying).  So if I am player, and have the new action available, and I have an AI unit 1 mile away, I can choose this action for the AI, and he will then travel the mile to get to the player, and then execute the action script.  This is annoying.

Even if you have all human players, this can be a problem.  If you add an action to one player, other players can execute the action if they are close enough to the player that owns the action.  I'm reasonably sure this is true if players are on foot.  

I do not know if this holds true if the player owning the action is in a vehicle...

Share this post


Link to post
Share on other sites
As soon as you are driver (player == driver whatever) : It executes the addaction command. Upon deactivation, it removes it.

Have you tried it Taurus? Because myself and other members from our clan are using it as I write this on our maps.

Yes I did, look at my linked pictures?

I'll try with the "old" way of adding the action confused_o.gif

And, yes, the thing about AI was a bit off-topic...

I'll leave this now as we don't talk about the same thing.

Good day.

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  

×