Jump to content
Reeveli

Disabling map screen while having GPS

Recommended Posts

So I'm working on a mission in which I would like the players to use the MicroDAGR and the Ctab tablet. Both of these devices count as (gps) terminals which enable both the side panels (I managed to find a solution to this) and the map (even when there is none in the inventory). I am not good with eventhandlers which I assume would be the prime candidates for this. Does anyone have ideas for a simple script that either prevents the player from opening the map itself or closing the map screen as soon as its opened?

Share this post


Link to post
Share on other sites

I'm sorry but as I said I have no idea how to use the eventhandlers. What would the code be like e.g. in initPlayerLocal.sqf since this would be for all players?

Share this post


Link to post
Share on other sites

Sorry for late reply.

(findDisplay 46) displayAddEventHandler ["KeyDown",
{
  params ["_display", "_key", "_shift", "_ctrl", "_alt"];
  if (_key in actionKeys "showMap" && "ItemGPS" in assignedItems player) then
  {
    hintSilent "You have a GPS";
    true;
  } else
  {
    hintSilent "You don't have a GPS";
  };
}];

This will prevent map opening if you have GPS in assigned slot.

  • Like 2

Share this post


Link to post
Share on other sites

I am sorry but as far as I can tell your code is supposed to give a hint when the map is opened while having a GPS in inventory. And on my tests it doesn't work. So I will need a another solution to this. Tried the following:

addMissionEventHandler ["Map", {
	params ["_mapIsOpened", "_mapIsForced"];
	if (_mapIsOpened) then {openMap false;}
	
}];

But it doesn't work either. I tested this event handler with hints and it does fire when the map is opened, but the openMap false -command seems not to work. Could use some moore help with this if anyone has any ideas.

Share this post


Link to post
Share on other sites

Your code is completely different? I gave you working code above.

 

EDIT: Here is an example mission. I slightly tweaked the code so the hint doesn't show if you aren't pressing the map key.

https://hazjohnson.com/ArmA/DisableMapIfNoGPS.VR.zip

(findDisplay 46) displayAddEventHandler ["KeyDown",
{
	params ["_display", "_key", "_shift", "_ctrl", "_alt"];
	if (_key in actionKeys "showMap") then
	{
		if ("ItemGPS" in assignedItems player) then
		{
			hintSilent "You have a GPS";
			true;
		} else
		{
			hintSilent "You don't have a GPS";
		};
	};
}];

Preview mission, open map, you will be able to, it'll say "You don't have a GPS", close map, open inventory and move your GPS into the slot, try to open the map, you won't be able to, you'll see "You have a GPS". I made it so the GPS has to be assigned in the slot. If you just want it anywhere, change assignedItems to items instead.

 

If you just want to always force map off then:

(findDisplay 46) displayAddEventHandler ["KeyDown",
{
	params ["_display", "_key", "_shift", "_ctrl", "_alt"];
	if (_key in actionKeys "showMap") then
	{
		hintSilent "You have a GPS";
		true;
	};
}];

 

  • Like 2

Share this post


Link to post
Share on other sites

showMap false;
addMissionEventHandler ["Map", {
   params ["_mapIsOpened", "_mapIsForced"];
     if (_mapIsOpened) then {
      hintSilent "Use your tablet";
      showGPS false;
    } else {

      showGPS true

   };
}];

  • Like 1

Share this post


Link to post
Share on other sites

I think he wants to disable map opening at all if you don't have a GPS??? Or at least according to the thread title:

Quote

Disabling map screen while having GPS

@Reeveli - Please clarify what you want exactly.

Share this post


Link to post
Share on other sites
On 1/20/2019 at 10:23 PM, HazJ said:

I think he wants to disable map opening at all if you don't have a GPS??? Or at least according to the thread title:

@Reeveli - Please clarify what you want exactly.

 

The aim is to disable the map screen entirely, thus forcing the players to use other tools (like Ctab). The newer code you provided seems to work on my tests.

waitUntil {!isNull (findDisplay 46)};

(findDisplay 46) displayAddEventHandler ["KeyDown",
{
  params ["_display", "_key", "_shift", "_ctrl", "_alt"];
	if (_key in actionKeys "showMap") then
	{
			true;
		};
}];

As I said this is sufficient, but I after getting this to work I have been thinking about other features. Is it possible to add this kind of eventhandlers to the mission after the mission has already started? I was thinking about allowing the map during the briefing so the players would have the option of actually reading the briefing in-game and trying to memorize the terrain before combat. In any case this thanks for your help so far.

Share this post


Link to post
Share on other sites

Should work fine in briefing already. Did you download the example mission?

Share this post


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

Should work fine in briefing already. Did you download the example mission?

Ah, interesting, poor choice of words on my part. I was thinking about allowing the players to access the map while getting their gear and organizing squads back the base after the mission had already stared and activating the eventhandler after they deployed into a combat area. But you are correct, seeing the map (and thus being able to read the briefing) is still allowed during the pre-mission briefing screen which is just fine for my application. Thanks.

Share this post


Link to post
Share on other sites

Change:

	if (_key in actionKeys "showMap") then

To:

	if (_key in actionKeys "showMap" && missionStarted) then

You will need to define the variable, maybe in init.sqf like so:

if (isNil "missionStarted") then {missionStarted = FALSE;};

And you will need to set it to TRUE somewhere, you'll have to decide when to do that.

missionStarted = TRUE; publicVariablr "missionStarted";

All un-tested.

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

×