Jump to content
Sign in to follow this  
5133p39

class userActions - how to?

Recommended Posts

I made a config addon of car derived from the Landrover class.

I need an action for locking/unlocking the vehicle, like i had in my Psycho Slayer addon for OFP.

But it doesn't work - i don't see the menu item.

Here is my usersAction definition:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class UserActions {

class Unlock {

displayNameDefault="$STR_MORS_UNLOCK_CAR";

displayName="$STR_MORS_UNLOCK_CAR";

position="osavolantkon";

radius=2.5;

onlyForPlayer = 1;

condition="true";

statement="[this] exec ""events\request_vehicle_unlock.sqs""";

};

class Lock {

displayNameDefault="$STR_MORS_LOCK_CAR";

displayName="$STR_MORS_LOCK_CAR";

position="osavolantkon";

radius=2.5;

onlyForPlayer = 1;

condition="true";

statement="[this] exec ""events\request_vehicle_lock.sqs""";

};

};

Could anyone please show me how to do it right or what is wrong with my definition?

I think the problem may be, that the position osavolantkon cannot be used for some reason unknown to me, but what is the "right" position then?

Share this post


Link to post
Share on other sites

Nevermind.

It was my fault - i forgot to add the STR_MORS_(UN)LOCK_CAR definition into the stringtable.csv and in ArmA those menu items cannot be seen (in OFP, the player could see something is missing, but not in ArmA), so i didn't noticed.

Share this post


Link to post
Share on other sites

does it work for weapons?, if yes, how do i use it.

I would like to add two special actions when the player has my weapon equipped.

Share this post


Link to post
Share on other sites
does it work for weapons?, if yes, how do i use it.

I would like to add two special actions when the player has my weapon equipped.

i don't think so - not this way.

You can't add userActions on weapons - only on the static ones like th artillery, etc. (which are in fact vehicles).

You can add userActions only to vehicles or static objects, but no to the weapons alone.

But you could achieve the desired effect by some scripting (depending on what exactly do you want).

You can check which weapons does the player have (hasWeapon, primaryWeapon, secondaryWeapon, weapons),

and add/remove actions (addAction) to him depending on his weapons.

Share this post


Link to post
Share on other sites

yut how would you, like add an action when a defined weapon is equiped and remove it when the weapon is taken down?

i couldn't find a satisfying even handler.

Share this post


Link to post
Share on other sites
yut how would you, like add an action when a defined weapon is equiped and remove it when the weapon is taken down?

i couldn't find a satisfying even handler.

There is no event handler for that.

Instead you must run some script which will do that.

Into the init field of the unit put this<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">sWpnChk = [this] execVM "weapons_check.sqf"and make the "weapons_check.sqf" as follows:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_u = _this select 0;

_m16Action = -1;

While{ alive _u } Do {

If( _m16Action < 0 && "M16" In Weapons _u ) Then {

_m16Action = _u AddAction["action title", "script_to_run.sqf"];

};

If( _m16Action > -1 && not ("M16" In Weapons _u) ) Then {

_u RemoveAction _m16Action;

_m16Action = -1;

};

Sleep 0.5;

};I haven't tested it, so maybe there is a bug somewhere.

This sript does not detect which is the currently selected weapon, only whether the unit does have the M16.

As far as i know, there is no command which would tell you what weapon is the unit currently using - maybe it would be possible to make some workaround with the help of the weaponDirection command, but that won't be easy.

Share this post


Link to post
Share on other sites

woah , that looks like some trouble tounge2.gif but nothing not doable...

too bad we have so few hooks...

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  

×