Jump to content
dlder

Spawned vehicle not visible for other players in MP?

Recommended Posts

Dear community,

 

when I use my addon to open the Virtual Garage in SP or MP, I can spawn any vehicle I want and use it.

BUT: for some reason, in MP my friend won't see the vehicle; and if I drive in said vehicle, he just sees me kinda floating over the ground.

 

-> for me that means that the vehicle is spawned client side only; which shouldn't happen and is kinda weird, as the AI - which would run server side - CAN interact and enter my spawned vehicle... so maybe it's just other player-clients?

 

Without further ado, here's the code I'm using:

		_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if ((inputAction 'User16') > 0) then
		{
			if (serverCommandAvailable '#kick') then
			{
				if (isNil 'HS_PG_Opened') then
				{
					HS_PG_Opened = 1;
					
					_pos = player getPos [20, getDir player];
					BIS_fnc_garage_center = createVehicle ['Land_HelipadEmpty_F', _pos, [], 0, 'NONE'];
					['Open', true] call BIS_fnc_garage;
				}
				else
				{
					hint format ['Sorry %1, but in  MP, the Virtual Garage is only available once every respawn!', profileName];
					{sleep 5; hintSilent '';} spawn BIS_fnc_spawn;
				};
			}
			else
			{
				hint format ['Sorry %1, but you are not an admin!', profileName];
				{sleep 5; hintSilent '';} spawn BIS_fnc_spawn;
			};
		};"];

And I've tried the following; executing the code on the server:

['Open', true] call BIS_fnc_garage;
------------------------------------------------------------------
['Open', true] remoteExec ['BIS_fnc_garage', 2];

"2" is the target; in this case it's executed only on the server: doesn't work

"0" doesn't work either -> this time the spawned vehicle will (of course) spawn for every player, but neither sees the vehicle of the other player

 

So, what am I doing wrong?

How am I able to spawn vehicles from the Virtual Garage in multiplayer?

 

Thanks in advance for any help/pointers etc.!!

 

cheers

 

Share this post


Link to post
Share on other sites

The Virtual Garage function spawns the vehicle only locally with createVehicleLocal. It might be necessary to replace the local vehicle with one that spawns globally when the player closes the garage. There is a scripted eventhandler that you might be able to use.

  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, 7erra said:

The Virtual Garage function spawns the vehicle only locally with createVehicleLocal.

 

That's it!

I now created an eventhandler and it spawns a vehicle which is visible in MP 🙂

 

Now I "only" have to figure out how to select the spawned vehicle; so I can delete it and spawn the same type on the server... (unfortunately there is no return variable from "BIS_fnc_garage" 😒

 

Share this post


Link to post
Share on other sites

BIS_fnc_garage_center contains the selected vehicle when the scripted EH fires

  • Thanks 1

Share this post


Link to post
Share on other sites

Really?

Doesn't it contain "Land_HelipadEmpty_F"?

 

Nope, you are absolutely right! Again! 🙂

 

Thank you very much!!

Share this post


Link to post
Share on other sites

Someone please help, I am trying to spawn globally what is chosen in Virtual Garage. 
 

[missionNamespace, "garageClosed", {
	hint "I am dumb";
}] call BIS_fnc_addScriptedEventHandler;

How to get the vehicle reference? :headscratch:

Share this post


Link to post
Share on other sites

No need for remote executing something if you delete a re-create the vehicle (and crew) with global effect command createVehicle and createUnit

So you garageClosed EH could be:
 

[missionNamespace, "garageClosed", {
  private _type = typeof BIS_fnc_garage_center;
  private _pos = getPos BIS_fnc_garage_center;
  private _dir = getDir BIS_fnc_garage_center;
  private _crew = +fullCrew BIS_fnc_garage_center;
  private _typeOfCrew = getText (configfile / "CfgVehicles" / _type / "crew");
  _crew apply {_x set [0,_typeOfCrew]};
  deleteVehicleCrew BIS_fnc_garage_center;
  deleteVehicle BIS_fnc_garage_center;

  private _veh = _type createVehicle _pos;
  _veh setVariable ["BIS_enableRandomization", false];
  if (_crew isNotEqualTo []) then {
    private "_ cr";
    {
      _cr = group player createUnit [_typeOfCrew, [0,0,0], [], 0, "none"];
      switch (_x #1) do {
        case "driver": {_cr moveInDriver _veh};
        case "commander": {_cr moveInCommander _veh};
        case "gunner": {_cr moveInGunner _veh};
        case "turret": {_cr moveInTurret [_veh,_x#3]};
        case "cargo": {_cr moveInCargo [_veh,_x#2,false]};
      };
    } forEach _crew;
  };
  _veh setdir _dir;
}] call BIS_fnc_addScriptedEventHandler;

 

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

×