Jump to content
Sign in to follow this  
mr_shadow

Adding action to every type of object

Recommended Posts

Hello, I would like to know if this is possible to add an action for every ATM, so far I know that I can check for distance of object to player and then add it, however I would like to be sure that it will be placed on each object including the custom placed.

Share this post


Link to post
Share on other sites

In such cases I usually go the other way and instead add an action to the player that simply checks if cursorTarget is of a certain class.

In your case, the addAction code could look like this:

//ATM action
act_useATM = player addAction[
"Use ATM",
'
	private["_trg"];
	_trg = cursorTarget;

	player Sidechat format["This is one fine looking ATM! (%1)",_trg];
',
"",
10,
true,
true,
"",
'
	_show = false;
	_trg = cursorTarget;
	if ( (typeOf _trg) in ["Land_Atm_01_F","Land_Atm_02_F"] ) then {
		_show = true;
	};
	_show
'
];

Share this post


Link to post
Share on other sites

And if the ATM:s don't have a classname you need to use nearestobjects with no classname and separate the atm machine by it's p3d filename.

Share this post


Link to post
Share on other sites

Or you can just check against the type of cursortarget like Tajin's done :)

Share this post


Link to post
Share on other sites

Objects with no classnames, like ATM:s on the map, are not showing up with the cursorTarget command. Hence why I made the nearestObjects comment :)

The cursorTarget command only works if you have manually created ATM:s on the map.

Share this post


Link to post
Share on other sites

Ahh. What does typeOf cursorTarget return if you look at one of the pre-existing ATMs?

Share this post


Link to post
Share on other sites

Nothing, since the cursortarget doesn't return anything.

Share this post


Link to post
Share on other sites

typeOf cursorTarget doesn't return a string? Or you're saying that cursortarget doesn't work with ATM's (just like it doesn't with objects like razor wire)

Share this post


Link to post
Share on other sites

Apparently so.

A script that removes/replaces all ATMs on the map might do the trick.

Share this post


Link to post
Share on other sites
Apparently so.

A script that removes/replaces all ATMs on the map might do the trick.

Far easier to just check what .p3d filename ATM:s have and do some string searching from the nearestObjects results with no classnames.

Share this post


Link to post
Share on other sites
Far easier to just check what .p3d filename ATM:s have and do some string searching from the nearestObjects results with no classnames.

Do you have an example?

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  

×