Jump to content
Sign in to follow this  
Prospero

Object and addaction commands

Recommended Posts

OK some dumb questions:

The Object command returns the object whose unique ID number is passed to it.

What's the opposite of this? I.e. what command would return the unique ID number when passed the object?

The reason I ask is I'm trying to sort out a script to make an action added to a player unit via the addAction command follow the unit around regardless of the vehicles he enters/exits. Of course if some kind person has a script snippet handy...

I'm a lazy bast at heart.

Prospero

Share this post


Link to post
Share on other sites

I'm sorry I don't understand very well what you want to do. (not good in English)

May this help you

In adaction script you have automatically 3 parameters:

_this select 0   -> owner of action

_this select 1   -> unit that call action

_this select 2   -> index of action

With 1.85 I use this for addaction to vehicle player when he gets in :

In init :

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

Vehicle1 addEventHandler  ["getIn",{_this exec "getIn.sqs"}]

Vehicle1 addEventHandler ["getOut",{_this exec "GetOut.sqs"}]

<span id='postcolor'>

You need install this on all vehicle, cause you can't add getin to men...

Getin script

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

?Name (_this select 0) != name(player) : exit

CurrentVehiclePlayer = vehicle(Player)

aDPlayer0= CurrentVehiclePlayer addaction["Select group","oneAction.sqs"]

<span id='postcolor'>

GetOut script

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

?(_this select 0) != CurrentVehiclePlayer  : exit

CurrentVehiclePlayer  removeaction aDPlayer0

CurrentVehiclePlayer = vehicle(Player)

<span id='postcolor'>

Hope this help you

Share this post


Link to post
Share on other sites

That's very helpful Uiox. Many thanks.

Prospero

PS: It's a shame those event handlers only work for the vehicles into which your getting in/out of, rather than on the person.

Share this post


Link to post
Share on other sites

Just asking, but does addAction still not return a valid value? (i.e. the bug mentioned in even the latest ComRef?)

This would make things far simpler if fixed.

Prospero

Share this post


Link to post
Share on other sites

No bug with addaction.

this works very well

_Owner = _this select 0

_id = _this select 2

_Owner removeaction _id

? HelmetCamera : aDPlayer3 = _Owner addaction ["Camera on", "helmet.sqs"] ;HelmetCamera = false ;exit

aDPlayer3 = _Owner addaction ["Camera off", "helmet.sqs"]

HelmetCamera =true

One little bug with addaction sometime player actions are not removed when he gets in a vehicle, if you manage this you double actions.

Share this post


Link to post
Share on other sites

Another alternative:

Trigger

Radius: 0,0

Condition: none (repeatedly)

Condition Field: vehicle player != player

OnActivation: action = (vehicle player) addaction ["Action","Action.sqs"]; vplyr = (vehicle player)

OnDeactivation: vplyr removeaction action

Doesn't use any of the fancy new features, but it gets the job done wink.gif

Share this post


Link to post
Share on other sites

OK, I basically wanted what Sui did there, but in script form and without using a trigger. The following seems to work nicely:

----------

_v = player

_def = _v addaction ["Action", "action.sqs"]

_ov = _v

#lp

_v = vehicle player

?(_v != _ov) && (_v != player): _a = _v addaction ["Action", "action.sqs"]

?(_v != _ov) && (_v == player): _ov removeaction _a

_ov = _v

~0.05

goto "lp"

----------

Prospero

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">OnDeactivation: vplyr removeaction action<span id='postcolor'>

Never think to do with this.

Thanks for the tip Sui smile.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Prospero @ Oct. 20 2002,11<!--emo&wow.gif)</td></tr><tr><td id="QUOTE">----------

_v = player

_def = _v addaction ["Action", "action.sqs"]

_ov = _v

#lp

_v = vehicle player

?(_v != _ov) && (_v != player): _a = _v addaction ["Action", "action.sqs"]

?(_v != _ov) && (_v == player): _ov removeaction _a

_ov = _v

~0.05

goto "lp"

----------<span id='postcolor'>

Hmmmmmmmmmm.

There seems to be a bug in this code. Can anyone spot it?

It seems to work perfectly, but just very occasionally one will get in a vehicle and there will be two copies of the action on one's Action Menu. Get out of the vehicle and it's back to normal again.

Bum.

Here's my latest version, which still suffers from the same bug:

----------

_t = "Action"

_p = player

_a = _p addaction [_t, "action.sqs"]

_o = _p

#lp

_v = vehicle player

?(_v != _o) && (_v != _p): _a = _v addaction [_t, "action.sqs"]

?(_v != _o) && (_v == _p): _o removeaction _a

_o = _v

~0.001

goto "lp"

----------

Prospero

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">One little bug with addaction sometime player actions are not removed when he gets in a vehicle, if you manage this you double actions.<span id='postcolor'>

My English is very bad, more I have forgot a word "you have double actions".

It's an old problem with OFP.

I see you really want add action to vehicle my last script for this :

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

? leader _Who != vehicle(leader _Who ) :  _InLeader = true; _cv = vehicle(leader _Who ); goto "Addaction"

? leader _Who == vehicle(leader _Who ) : _InLeader = false;  _cv = leader _Who; goto "Addaction"

#RemoveAction

_cv  removeaction _aD0

?  _InLeader : _cv = vehicle(leader _Who )

? !( _InLeader) : _cv = leader _Who

#Addaction

_aD0=  _cv addaction ["action","action.sqs"]

#MainLoop

~PauseForUpdate

? (leader _Who == vehicle(leader _Who )) and _InLeader    : _InLeader = false; Goto "RemoveAction"

? (leader _Who !=vehicle(leader _Who )) and !(_InLeader) :_InLeader = True;Goto "RemoveAction"

? condition : goto "MainLoop"

<span id='postcolor'>

Share this post


Link to post
Share on other sites

Thanks again Uiox. Here's my latest version (speediest), but I think it still suffers from the "double action problem" occasionally.

_t = "Action"

_f = "action.sqs"

_p = player

_a = _p addaction [_t, _f]

_o = _p

#lp

_v = vehicle player

?(_v != _o): goto "sb"

#rn

_o = _v

~0.01

goto "lp"

#sb

?(_v != _p): _a = _v addaction [_t, _f]

?(_v == _p): _o removeaction _a

goto "rn"

Prospero

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  

×