Jump to content
Chipotles

Make mission multiplayer compatible?

Recommended Posts

Hey guys,

 

it seems like i just cant get my head around it. Ive been looking though a few similar posts like this but i just dont get it. I have made a King of the Hill gamemode which runs perfectly in the eden editor. But when im loading the mission with TDAST dedicated server tool it just behaves differently. My score doesnt work (just shows "Any") and so on. I think the initServer.sqf just doesnt launch.

 

i have 3 init files. initPlayerLocal.sqf, init.sqf and initServer.sqf. This runs without problems in the editor. 

 

here are my three scripts. i know these arent efficient yet, and works and i just started scripting.

 

how would i proceed with this?

 

 

initServer.sqf

scoreLimit = 50;
scoreWest = 0;
scoreEast = 0;

engagingWest = 0;
engagingEast = 0;



engagingRadius = 50;
"engagingMarker" setMarkerSize [engagingRadius, engagingRadius];


actionScript = true;

while {actionScript} do
{
  if (engagingWest > engagingEast) then
  {
    scoreWest = scoreWest + 1;
    "engagingMarker" setMarkerColor "colorBLUFOR";
    sleep 1;
  };

  if (engagingEast > engagingWest) then
  {
    scoreEast = scoreEast + 1;
    "engagingMarker" setMarkerColor "colorOPFOR";
    sleep 1;
  };

  if ((engagingWest == 0) and (engagingEast == 0)) then
  {
    "engagingMarker" setMarkerColor "ColorBlack";
  };

  if (scoreWest >= scoreLimit) then
  {
    "end1" call BIS_fnc_endMissionServer;
    actionScript = false;
    //disableUserInput true;
  };
  if (scoreEast >= scoreLimit) then
  {
    "end1" call BIS_fnc_endMissionServer;
    actionScript = false;
    //disableUserInput true;
  };
  if !(actionScript) exitWith {};
};

 

 

initPlayerLocal.sqf

while {true} do
{
  waituntil {((player distance AmmoSups) <= engagingRadius);};


  hint "You have entered";
  if (player distance AmmoSups <= engagingRadius) then
  {
    switch (playerSide) do
    {
      case west:
      {
          engagingWest = engagingWest + 1;
      };
      case east:
      {
          engagingEast = engagingEast + 1;
      };
    };
  };

  sleep 1;
  waituntil {((player distance AmmoSups) >= engagingRadius);};


  hint "You have left";
  if (player distance AmmoSups >= engagingRadius) then
  {
    switch (playerSide) do
    {
      case west:
      {
          engagingWest = engagingWest - 1;
      };
      case east:
      {
          engagingEast = engagingEast - 1;
      };
    };
  };
};

 

init.sqf

display_switch = true;
_nul = [] execVM "engine.sqf";

 

engine.sqf (the display hud. here is a screenshot)

while {alive player} do
{
	waituntil {display_switch};

	cutrsc ["status_display", "PLAIN", 1, false];

	((uiNamespace getVariable "status_display") displayCtrl 0001) ctrlSetText format ["%1", scoreWest];
	((uiNamespace getVariable "status_display") displayCtrl 0002) ctrlSetText format ["%1", scoreEast];

	sleep 1;
};

 

 

I would apperciate every kind of help! Thank you.

Share this post


Link to post
Share on other sites

it's good that you are using the different event scripts from the start. makes it easier to understand what runs where.

 

now foirst of all. to access a variable with your HUD it has to exist on the clients' machnes. and then to have it show the current state you will have to also update it in a reasonable frequency.

 

so you declare "scoreWest" inside initServer.sqf. so that variable is global to all script scopes on the server machine as opposed to it using an underscore _ infront of it. but don't confuse "global" with "globally shared over the network". i'm just assuming now that this is the cause of confusion since you are already using event scripts.

 

so what you need is this: https://community.bistudio.com/wiki/publicVariable

 

alternatively you can use a combination of: https://community.bistudio.com/wiki/missionNamespace

and: https://community.bistudio.com/wiki/setVariable

nore that for "setVariable" the 4th optional parameter is the key to what you are trying to achieve here.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, bad benson said:

note that for "setVariable" the 4th optional parameter is the key to what you are trying to achieve here.

 

You described it perfectly. Thats exactly what i needed. The mission is now running perfectly! You are an experienced man, thank you!

 

I just got an single question remaining in my mind.

Are missions which are filled with a lot of props in any way inefficient when it comes to performance? both kind of performance. fps & loading time.

Share this post


Link to post
Share on other sites
26 minutes ago, Chipotles said:

 

You described it perfectly. Thats exactly what i needed. The mission is now running perfectly! You are an experienced man, thank you!

 

I just got an single question remaining in my mind.

Are missions which are filled with a lot of props in any way inefficient when it comes to performance? both kind of performance. fps & loading time.

 

more stuff naturally needs more resources. take a look at these two pages. it will help you save some performance here and there especially with stuff that won't move throughout the mission.

 

https://community.bistudio.com/wiki/Arma_3_Simple_Objects

https://community.bistudio.com/wiki/createSimpleObject

 

also take a look at this while you're at it.

 

https://community.bistudio.com/wiki/enableSimulationGlobal

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

×