Jump to content
Spartans Home

action menu entry


Kavlarakos~SPARTA~
 Share

Recommended Posts

I encountered a problem while writing on the 2nd mission.

 

Here is the issue:

 

I want to give a chopper an action menu entry to unload an ammo box.

So I placed a global trigger and put into the condition the following syntax:

 

getpos chopper_1 select 2 < 4 && player19 in chopper_1 (player 19 is the pilot)

 

In the activation line this:

 

ammodrop1 = chopper_1 addaction ["Drop ammobox","scripts\ammodrop1.sqs"]

 

Inside the script I just changed the position of an ammobox, which I placed somewhere at the border of the map with:

 

ammobox_1 setpos getpos chopper_1;

 

Everything works fine except for one thing. Everybody who sits in the chopper gets this action menu entry. But I want only the pilot to be able to get this entry.

 

How can I do that?

 

Link to comment
Share on other sites

Its early and I've had no coffee, but try something like this:

 

if (driver this == player19) then {

ammodrop1 = chopper_1 addaction ["Drop ammobox","scripts\ammodrop1.sqs"];

};

No does not work and it is logical, because it is not the condition ("if (driver this == player19)") which is the problem. It is the activation which provides everybody in the chopper the entry.

 

What I found so far is that there are some specifications you can add after the entry. the code is:

 

unit addAction [actionentry, "scriptname"(arguments, priority, showWindow, hideonUse, shortcut, condition)]

 

But I really don´t know how to use them.

 

 

Link to comment
Share on other sites

No does not work and it is logical, because it is not the condition ("if (driver this == player19)") which is the problem. It is the activation which provides everybody in the chopper the entry.

 

What I found so far is that there are some specifications you can add after the entry. the code is:

 

unit addAction [actionentry, "scriptname"(arguments, priority, showWindow, hideonUse, shortcut, condition)]

 

But I really don´t know how to use them.

 

Try:

ammodrop1 = player19 addaction ["Drop ammobox","scripts\ammodrop1.sqs"]

 

You'll need to manually remove it when they get out though.

 

(I think that's how I used to do it anyway)

 

If that doesn't work, try setting the condition argument. (See: AddAction)

 

Edit: In fact, calling addAction on the chopper with the condition "driver _target == player" may be the best solution.

Link to comment
Share on other sites

Try:

ammodrop1 = player19 addaction ["Drop ammobox","scripts\ammodrop1.sqs"]

 

You'll need to manually remove it when they get out though.

 

(I think that's how I used to do it anyway)

 

If that doesn't work, try setting the condition argument. (See: AddAction)

 

Edit: In fact, calling addAction on the chopper with the condition "driver _target == player" may be the best solution.

 

 

This could maybe work. The problem is that I can only find out when testing at least with 2 persons.

 

But again I doubt, because when driver is player the condition again is fulfilled and will every player inside the chopper give the damn entry....!

 

These are the small nasty issues which don´t let me sleep.

 

I think this can only be solved with a script instead of a trigger.

 

 

Link to comment
Share on other sites

This could maybe work. The problem is that I can only find out when testing at least with 2 persons.

 

But again I doubt, because when driver is player the condition again is fulfilled and will every player inside the chopper give the damn entry....!

 

These are the small nasty issues which don´t let me sleep.

 

I think this can only be solved with a script instead of a trigger.

 

If you add the action to the player, in this case the pilot, only he will see the action. No one else in the chopper will.

 

Or if you use the condition in addAction, only the pilot will see it. Because that condition will return false for everyone else, thus hiding the action from them.

 

Not quite sure why you're using a trigger though. Be better to do an eventhandler for GetIn and GetOut, which would add/remove the actions respectively.

 

P.S.- Easy way to test without multiple people:

Spawn an AI unit, order him into driver position of chopper. Then get in yourself. Repeat with you as driver and AI as passenger.

Link to comment
Share on other sites

Will that allow you to fix the Artillery option on the group leader as well? I haven't looked at your code but sounds similar.

 

 

Maybe. What I did is to use this code and rewrote it into one of my triggers:

 

_actionId = _vehicle addAction ["View radar", "mission\radar\viewRadar.sqf", ["forwardRadar", 8], 1,

false, true, "teamSwitchPrev", "driver _target == player"];

 

The really imprtant fact is the "true, false" in this code which allows only the specific person which has been defined in the condition to see the action entry.

 

To be honest I really don´t know for what each of the specifications are good for but the result is that the code worked...

Link to comment
Share on other sites

Ah - right. Just looked it up and remembered what I was thinking.

 

In MP this value is different on each computer.

 

Although, that may be outdated and may have been updated in A2. For your purposes, it should be fine, since the vehicles are made local to whatever machine the driver is using, so the _vehicle driver will be the local player. Looks like a great implementation!

 

(Will keep that code snippet in mind.) :)

Link to comment
Share on other sites

 Share

×
×
  • Create New...