Jump to content
zagor64bz

[SOLVED]open/close map with onMapSingleClick help

Recommended Posts

Ok...I a little snippet where if the player is a gunner in the heli can tell the driver to move to a map-clicked location.

IF ((Gunner Viper01) == player) THEN {openMap true;onMapSingleClick "Driver Viper01 move _pos;onMapSingleClick ''; true";}

It works ok, BUT, I want to close the map after the player has chosen the destination.

I know the command is "openMap false;" and I try with this


IF ((Gunner Viper01) == player) THEN {openMap true;onMapSingleClick "Driver Viper01 move _pos; onMapSingleClick ''; true";Driver Viper01 vehiclechat "Roger, en route to destination";};
sleep 1;
openMap false;

NOT working....I know it may be simple..but...any help?

Share this post


Link to post
Share on other sites

Put the openMap false; inside of the onMapSingleClick

 

like so (hope I got it right):


IF ((Gunner Viper01) == player) THEN {openMap true;onMapSingleClick "Driver Viper01 move _pos; onMapSingleClick ''; openMap false; true";Driver Viper01 vehiclechat "Roger, en route to destination";}; 
Edited by gc8
correction

Share this post


Link to post
Share on other sites
22 minutes ago, gc8 said:

Put the openMap false; inside of the onMapSingleClick

 

like so (hope I got it right):


IF ((Gunner Viper01) == player) THEN {openMap true;onMapSingleClick "Driver Viper01 move _pos; onMapSingleClick ''; openMap false; true";Driver Viper01 vehiclechat "Roger, en route to destination";}; 

Nope..sorry.

It says "invalid number in expression"....:headscratch:

Share this post


Link to post
Share on other sites
32 minutes ago, zagor64bz said:

It says "invalid number in expression"

 

Can't see what's wrong, sorry, hope someone else can

 

is Videp01 defined? where you put the code?

 

Share this post


Link to post
Share on other sites
openMap true;
onMapSingleClick "
	openMap false;
	
	//code
	
	onMapSingleClick '';
";

This is what I've used, with all the code taken out to make it easier to read. Minus the //code, running this will literally open the map, then close it when you click.

Share this post


Link to post
Share on other sites
40 minutes ago, beno_83au said:

openMap true;
onMapSingleClick "
	openMap false;
	
	//code
	
	onMapSingleClick '';
";

This is what I've used, with all the code taken out to make it easier to read. Minus the //code, running this will literally open the map, then close it when you click.

Hey mate, thanks..your code work as you stated..BUT, if I insert the code 

openMap true;
onMapSingleClick "
	openMap false;
	Driver Viper01 move _pos;
	Driver Viper01 vehiclechat "Roger, en route to destination";
	onMapSingleClick '';
";

trows a ""error missing ; ""...what did I do wrong?

Share this post


Link to post
Share on other sites
6 minutes ago, zagor64bz said:

"Roger, en route to destination"

 

change those " quotes to the ' quote

  • Like 2

Share this post


Link to post
Share on other sites
2 minutes ago, gc8 said:

 

change those " quotes to the ' quote

 

Yep. You've already got it there with the line onMapSingleClick ' '; - just need to do the same to the vehicle chat.

  • Like 1

Share this post


Link to post
Share on other sites
22 minutes ago, gc8 said:

 

change those " quotes to the ' quote

:icon_dj: it work now..THANKS BOTH OF YOU guys...

 

So, the RIGHT code, for anyone in need is:

*Proceed to Waypoint*/
IF ((Gunner Viper01) == player) THEN {openMap true;
onMapSingleClick "
	openMap false;
	Driver Viper01 move _pos;
	Viper01 vehiclechat 'Roger, en route to destination';
	onMapSingleClick '';";
};

 

  • Like 4

Share this post


Link to post
Share on other sites

Anyone know how to "terminate" a mission event handler? I have:

 

private _mapclick = addMissionEventHandler ["MapSingleClick", { 
	params ["_units", "_pos", "_alt", "_shift"];

	**a bunch of code that works fine including a group spawn**	

	removeMissionEventHandler ["MapSingleClick", _mapclick];

}];

 

This is spawned as one of my custom functions, it runs but I can click on the map forever and it just keeps running the script over and over, including the group spawn. I need the EH to stop after a single map click LIKE IT'S STATED PURPOSE. The idea is that the player clicks on the map once, and a group is spawned with a waypoint. While the team is spawned, the player has the support option removed and cannot call it again, until the waypoint is complete or the team is dead. Anything yall got is helpful thanks!

Share this post


Link to post
Share on other sites

I guess this should work but I m not sure:

 

private _mapclick = addMissionEventHandler ["MapSingleClick", { 
	params ["_units", "_pos", "_alt", "_shift"];

	**a bunch of code that works fine including a group spawn**	

	removeMissionEventHandler ["MapSingleClick", _thisEventHandler];

}];

 

Edit:

It would also work with your variable if you would declare it global like

 

FOX_mapclick = addMissionEv...

 

thats because your local variable _mapclick is local to the script where you add the EH. At the time when EH is running its not known because the script where it was declared is not running then.

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

×