Jump to content
Sign in to follow this  
Lucasmnunesk

Tracking if GPS is on and when player leaves optics sights

Recommended Posts

I'm currently trying to learn how to make addons, as a first project i've been trying to make what i believe would be a simple task.

i wanted to track if a player is with GPS toggled on, and when he left an Magnified scope sight or even when he left an vehicle slot which has no interior he would have his GPS turned on automatically.

When i first thought about it this was my first ideia, an Event Handler would turn a variable to true when a player toggled the GPS on, and when he left any state which the GPS would be turned off another event handler would check if the GPS variable was on. Unfortunately i couldn't find any event handler that would serve this purpose.

My main reason to do this is to learn more about scripting and to get into add on making, but sometimes i was annoyed that my GPS was turned off just because i've used the binoculars so it could be useful.

So anyone has any ideas how to track these events?

Share this post


Link to post
Share on other sites

This may help:

[] spawn {
 while(true) {
   if(vehicle player == player) then {
     if(cameraView != "GUNNER") then {
       // show GPS
     };
   };
   sleep 0.1;
 };
};

Essentially spawn thread, check if player is player (e.g. not in vehicle), check that not aiming through scope/down sights. However not sure how to display actual GPS, you may have to get the ctrl/dialog ID's and call cutRsc/createDialog.

Share this post


Link to post
Share on other sites

Thanks for your help! It will work, but still i'm not sure if its the optimal way of doing this.

Correct me if i am wrong, but a while loop like this would cause performance issues with higher number of players, right? Still it seems to be the only method to do this.

I've asked the FA_gps mod developer to have a look on his code so i would understand how to manipulate the gps but I've found Addon making documentation on BIS wiki pretty poor, still i couldn't find any info anywhere, is there anywhere else to look into? Or the best way is really looking at other people addons?

Share this post


Link to post
Share on other sites

I don't think it will cause issues with many players, as the code will be run separately on each client. You could also increase the sleep time, to a higher amount if required.

I looked at GPS last night, and it appears you may need to create a custom config which extends RscMiniMap, then use cutRSC.

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  

×