Jump to content
Barba-negra

moving marker in server

Recommended Posts

After doing thousands of tests with scripts, in several ways to do it and put the server to work as little as possible, I could finally see the difference shown by the use of remoteExec, it is something impressive, the server feels in the air, it is absolutely much better to work with this method if what you want is to do a big job without affecting the performance of the server, I highly recommend it. : D

 

Talking about another topic, I would like to ask a question to see how I can solve a problem that I am having with a mobile dialer function, since it seems that using several mobile markers at the same time is freezing some units in the map established from the server, It seems strange but after doing many tests I realized that that is the problem.

 

0 = [] spawn {

    while {alive soldado2} do {

        "Doblecasco" setMarkerDir (getDir soldado2);
        "Doblecasco" setMarkerPos (getpos soldado2);
        sleep 0.1;
    };

};

[] Spawn {

while{not isnull sensor13} do {"local13" setmarkerpos getpos sensor13; sleep 0.5;};

};

 

Will there be another way to make a mobile dialer or is this the only way?

Share this post


Link to post
Share on other sites

I personally use drawIcon on the map. Marker is fine though I recommend a bit higher sleep and that you only run the code when the map/GPS is active. No need other wise.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for recommending it, I did not know it, I'm going to look for it

Share this post


Link to post
Share on other sites
1 hour ago, Barba-negra said:

Thank you for recommending it, I did not know it, I'm going to look for it

drawIcon is the way to go for any Icon/Line/Polygon that needs to move/be animated, check out some example:
 

Cheers

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

guys I found a way to make a simple brand that follows the object thanks to your great help, thanks guys, through this simple scripts

 

initplayerLocal

 

 

findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {

 

_this select 0 drawArrow [ _vehicle, _vehicle getRelPos [5, 0], [1,0,0,1] ];

 

}];

 

however, in dedicated server when I am away from the vehicle and it is moving, the brand remains immobile, how can this be solved?

Share this post


Link to post
Share on other sites
On 1.12.2018 at 3:38 AM, Barba-negra said:

it is absolutely much better to work with this method

compared to... what?

 

On 1.12.2018 at 3:38 AM, Barba-negra said:

Talking about another topic

You are creating a topic about remoteExec, just to talk about something completely different?

 

On 1.12.2018 at 3:38 AM, Barba-negra said:

It seems strange but after doing many tests I realized that that is the problem.

What? What is the problem?

 

On 3.12.2018 at 12:20 AM, Barba-negra said:

_this select 0 drawArrow [ _vehicle, _vehicle getRelPos [5, 0], [1,0,0,1] ];

_vehicle variable is undefined. This can never work

  • Like 2

Share this post


Link to post
Share on other sites
On 12/1/2018 at 2:38 AM, Barba-negra said:

After doing thousands of tests with scripts

A waste of time by the look of it. As stated above, that won't work so what did you test? :rofl:

  • Haha 1

Share this post


Link to post
Share on other sites

ok guys have me patience you know more than me :D, if I have done several tests in various ways investigating but I have not made it work, ok if I define a private variable this could be so?

 

iniplayerLocal

 

 

private "_vehicle";

 

findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {

 

_this select 0 drawArrow [ _vehicle, _vehicle getRelPos [5, 0], [1,0,0,1] ];

 

}];

 

or following the example of the companion

 

GOM_fnc_getPilotDraw = { params ["_vehicle"]; [[_vehicle modelToWorldVisual [0,0,0]};

 

findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { (_vehicle) draw ([_x] call GOM_fnc_getPilotDraw);

 

     };

];

 

Could this maybe work?

 

my intention is that the brand follows the object or vehicle, in this case there is a vehicle on the map called _vehicle, when I start the dedicated server, the brand works correctly following the vehicle correctly, the problem occurs when the player is away from the vehicle, if the vehicle moves driven by an AI or any other force that moves it, the brand does not follow it, it only follows it when the player is near the vehicle, it is something strange

 

 

 

 

Edited by Barba-negra

Share this post


Link to post
Share on other sites
On 4.12.2018 at 4:57 PM, Barba-negra said:

Could this maybe work?

both no. The Draw eventhandler is a new script. Private variables carry over to lower scopes, but not to entirely different scripts.

Also local variables are deleted when they go out of scope. You add the Draw handler, then your _vehicle goes out of scope and disappears, then maybe hours or days or weeks later sometime the Draw handler will be executed, your variable has been gone for a looooong time at that point.

 

On 4.12.2018 at 4:57 PM, Barba-negra said:

GOM_fnc_getPilotDraw = { params ["_vehicle"]; [[_vehicle modelToWorldVisual [0,0,0]};

What are you trying to do with the array stuff there? You have two opening [ too many.

  • Like 2

Share this post


Link to post
Share on other sites

@Barba-negra    You should change the title of your topic because it's not related to remoteExec but the way to display markers (or icons) on map.

 

As any display, you should think to make it local, i.e. for the player, locally. As said previously, you can use EH "draw" for icons or polygons...

That's probably your best bet. You can also display moving markers.

In this case, You can script for server and createMarker (globally),

or, script for each client/hosted and createMarkerLocal.

The first solution needs to broadcast markers and positions (done by the commands themselves). The second one needs to run the script everywhere but don't impact the network.

As you started with markers, I suggest you, in initPlayerLocal.sqf :

 

addMissionEventHandler ["Map", {
  params ["_mapIsOpened", "_mapIsForced"];
  if !(_mapIsOpened) then {
    {deleteMarkerLocal (_x getVariable ["mked",""])} forEach (< your array of units here >);
  } else {
      {
        _mk = createMarkerLocal [("mk"+str(_x)),getpos _x];
        _mk setMarkerTypeLocal "mil_arrow";
        _x setVariable ["mked",("mk"+str(_x))];
        [_mk,_x] spawn {
          params ["_mk","_unit"];
          while {alive _unit && visiblemap} do {
            _mk setMarkerPosLocal getPos _unit;
           _mk setMarkerDirLocal getDir _unit;
            sleep 0.1;
          };
        };
      } forEach (< your array of units here >);
    }
}];

 

Markers are created when you open the map, and deleted when you close it. No impact on FPS. everything is made locally.

EDITED: I saw you changed your title for Markers in server.... Well. In this case, it's weird to use a EH "map", deleting or creating global markers. You just have to create them and move them... as they must be permanent for any player. So, global markers have no added value in this case. You should think about that. As already said, the goal is to display locally (when opening map) some local result (marker local or icons).

  • Thanks 1

Share this post


Link to post
Share on other sites

thanks @pierremgi, and thanks guys, I really have found it difficult to create this scripts that I think is quite complex

Share this post


Link to post
Share on other sites

yes, change the name, and if your scripts have a lot of logic and meaning, the important thing is to show the position of the object or vehicle when they move position, that's all that is needed

Share this post


Link to post
Share on other sites
On 12/7/2018 at 7:53 AM, pierremgi said:

addMissionEventHandler ["Map", {
  params ["_mapIsOpened", "_mapIsForced"];
  if !(_mapIsOpened) then {
    {deleteMarkerLocal (_x getVariable ["mked",""])} forEach (< your array of units here >);
  } else {
      {
        _mk = createMarkerLocal [("mk"+str(_x)),getpos _x];
        _mk setMarkerTypeLocal "mil_arrow";
        _x setVariable ["mked",("mk"+str(_x))];
        [_mk,_x] spawn {
          params ["_mk","_unit"];
          while {alive _unit && visiblemap} do {
            _mk setMarkerPosLocal getPos _unit;
           _mk setMarkerDirLocal getDir _unit;
            sleep 0.1;
          };
        };
      } forEach (< your array of units here >);
    }
}];

This is great.

Question, if i do this

_mk setMarkerTextLocal name _x; forEach (allPlayers);

is this the correct way if i would like to add it on every player when executing this in initPlayerlocal.sqf.

 

Share this post


Link to post
Share on other sites

Yes, there is no reason to make a marker global from each PC. Keep it locally and you'll save net resource.

  • Like 1

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

×