Jump to content
pliskin124

Only Server Host Teleporting or Hearing Sounds

Recommended Posts

I am about at wits end I'll be honest. I have spent the last 5 days tediously perfecting this mission and it works FLAWLESSLY on single player, through the editor, and even when I'm hosting by myself. The second I get players in though, they complain they can't hear sounds during a critical part of the mission, and also the scripts aren't applying to them.

Here is what happens, the players spawn into a briefing room with the commander, everything works great, it fades to black and they teleport to the barracks. All good so far, all players teleport just fine, and say3d sounds play perfectly from both triggers and sqf files on the air field base. The problem comes when they enter into the helicopter to take them to the mission objective. Basically what happens is the helicopter takes off, flies through several triggers, one to delete objects behind at the air field base for performance reasons, the second trigger to start the sandstorm, the third trigger is the audio where the pilot begins talking (which I hear perfectly but no one else hears it at all),

Trigger 4 - Helicopter takes slight damage
Trigger 5 - Pilot talks again
Trigger 6 - Helicopter takes damage to destroy tail rotor

 

Then this trigger, probably the most PIVOTAL to the mission is the teleport script, to teleport all players OFF of the helicopter (AI included) to the crash site, then eventually delete the previous helicopter (fading to black to simulate a helicopter crash site) Here is the problem, in single player or the editor, it works great, all AI teleport with me to the crash site. In multiplayer when I'm hosting however all of the AI stay with the helicopter, players included, the helicopter is deleted and they fall to their deaths.

I remember there being something about global commands, like 3dsayglobal or something. Not sure if this is the issue but I can't find anything on it.
Second thought, if the first teleport script works perfectly, and the code in the second works fine in single player then it's not the teleport command that's not working, but more so it's not applying to all players, or its a problem with the trigger.

My trigger conditions for this are

Blufor Present

nul = execVM "teleport2.sqf";

I previously had it set to "Trigger Owner" and synced directly to the helicopter which worked fine in single player and the editor, but I assumed might have been the issue so I undid it.

Attached is the teleport script (again the teleport is used earlier in the mission so I'm not sure why it won't work this time around and the sound isn't playing for other players in the helicopter, and no its not a volume issue I have it up around 60 decibels its loud enough)

 

 sleep 15;
cutText ["","BLACK IN"];
cutText ["","BLACK OUT"];
 sleep 2;
cutText ["","BLACK IN"];
 "dynamicBlur" ppEffectEnable true;
cutText ["","BLACK OUT"];
 sleep 1;
  "dynamicBlur" ppEffectEnable true;
cutText ["","BLACK IN"];
cutText ["","BLACK OUT"];
 sleep 2;
  // I know checking for AI and players is redundant, this is after I fixed it, previously it was a getpos setpos command but tested this
if (isPlayer P1) then {
    P1 setpos getMarkerPos "CrashSite1";
};
if (isPlayer P2) then {
    P2 setpos getMarkerPos "CrashSite2";
};
if (isPlayer P3) then {
    P3 setpos getMarkerPos "CrashSite3";
};
if (isPlayer P4) then {
    P4 setpos getMarkerPos "CrashSite4";
};
if (isPlayer P5) then {
    P5 setpos getMarkerPos "CrashSite5";
};
if (isPlayer P6) then {
    P6 setpos getMarkerPos "CrashSite6";
};
if (isPlayer P7) then {
    P7 setpos getMarkerPos "CrashSite7";
};

if (!isPlayer P1) then {
    P1 setpos getMarkerPos "CrashSite1";
};
if (!isPlayer P2) then {
    P2 setpos getMarkerPos "CrashSite2";
};
if (!isPlayer P3) then {
    P3 setpos getMarkerPos "CrashSite3";
};
if (!isPlayer P4) then {
    P4 setpos getMarkerPos "CrashSite4";
};
if (!isPlayer P5) then {
    P5 setpos getMarkerPos "CrashSite5";
};
if (!isPlayer P6) then {
    P6 setpos getMarkerPos "CrashSite6";
};
if (!isPlayer P7) then {
    P7 setpos getMarkerPos "CrashSite7";
};
 p1 setUnconscious true;
 p2 setUnconscious true;
 p3 setUnconscious true;
 p4 setUnconscious true;
 p5 setUnconscious true;
 p6 setUnconscious true;
 p7 setUnconscious true;
 Wreck1 setpos getMarkerPos "CrashSiteHeli";
 Smoke1 setpos getMarkerPos "CrashSiteSmoke";
 sleep 0.1;
 Wreck1 say3d "HelicopterCrash1";
 sleep 1;
 deletevehicle Helicopter1;
 deletevehicle Helicopter1A;
 deletevehicle Helicopter1B;
 sleep 7;
 cutText ["","BLACK IN"];
 sleep 5;
 p1 setUnconscious false;
 p2 setUnconscious false;
 p3 setUnconscious false;
 p4 setUnconscious false;
 p5 setUnconscious false;
 p6 setUnconscious false;
 p7 setUnconscious false;



TLDR; Sound files / Teleport script not working for other players but server host

Share this post


Link to post
Share on other sites

I may have found a discrepancy between the triggers / SQF's that work in multiplayer against those that don't...

The ones that do are activated by a trigger for "Any Player", however this doesn't work because the players are in a helicopter and for some reason it's not detecting them when the helicopter passes through the trigger. Does anyone have any ideas on how to bypass this maybe? At the moment I have "Helicopter1 in thislist;" as my condition which activates the trigger fine on single player.

Share this post


Link to post
Share on other sites

I am going to try the following code to see if it might fix the issue of detection on the trigger for any player and hope that it applies the script to all players rather than just the helicopter unit.
 

if (vehicle player != player) then {hint "Player is in a vehicle"};

 

Share this post


Link to post
Share on other sites
19 minutes ago, pliskin124 said:

I am going to try the following code to see if it might fix the issue of detection on the trigger for any player and hope that it applies the script to all players rather than just the helicopter unit.
 


if (vehicle player != player) then {hint "Player is in a vehicle"};

 

Didn't work.... Still SOL.

Share this post


Link to post
Share on other sites

Okay, more progress. I made duplicates of every trigger, and set the trigger owner as each member of the unit, that solved nothing. I then created a trigger to activate OUTSIDE of the helicopter for "Any Player" and went through the arduous process of TIMING when I wanted the sound files to be said, and when I want the trigger to be actuated assuming that it was due to the player not activating the trigger himself. This was a no go, which tells me that the problem lies with the scripts not applying to the player IN the vehicle. Could this be because the vehicle is local? Any help would be appreciated.

This is the script that I had playing as "Any Player" detection, still nothing.

sleep 3;
Helicopter1A say3d "Pilot1";
sleep 38;
Helicopter1A say3d "Pilot2";
sleep 19;
Helicopter1A say3d "Pilot3";
sleep 12;
Helicopter1A say3d "Pilot4";
sleep 15;
Nul = execVM "Teleport2.sqf";

Honestly the main problem here is the teleportation not working, that's game breaking.

Share this post


Link to post
Share on other sites

From what I'm reading here: https://community.bistudio.com/wiki/Multiplayer_Scripting
"a driven vehicle is always local to the machine of its driver (not the commander's, not the gunner's)"

The spawned in vehicle, which has a driver based on the server, because that's where the pilot was created, makes the vehicle local to the server, which explains why I would be the only one being effected by the scripts after entering the vehicle because it effectively makes the script executed by the players activate as if it was dedicated... if I'm understanding this correct.

 

So again, the issue comes down to how to make the helicopter global or make the script apply locally for the client and not locally for the server. Any assistance would be appreciated.

Share this post


Link to post
Share on other sites

Okay. From what I'm reading the "remoteExec" command is useful for sending scripts specifically to each machine. I'm not quite sure about how to go about writing that into my script above.

I'm thinking I will call the script with a function similar to...

 

{[] execVM "flight.sqf"} remoteExec ["bis_fnc_call",0];

 

by placing this in a trigger activation I think it might work? If anyone can help me with the syntax on that or if I need to add anything specific to the script let me know. Thanks.

 

 

EDIT:

{[] execVM "flight.sqf"} remoteExec ["bis_fnc_call",0];
Did not work as a trigger activation, still encountering the same issue of the script only executing for the host.

Share this post


Link to post
Share on other sites

Update:

I am going to attempt to use the following command to attempt to call the script on all machines.

["Flight.sqf","BIS_fnc_execVM",true,true ] call BIS_fnc_MP;

 

or

 

[[{*Your code*}],"BIS_fnc_Spawn",target,false] spawn BIS_fnc_MP;

 

Will update on the results, otherwise I have to attempt to make a function, which I have no idea how to do.

Source:

 

 

Share this post


Link to post
Share on other sites

Use remoteExec in preference to BIS_fnc_MP. As per one of the comments on the wiki:

 

"Executing commands/functions via remoteExec is more faster than using BIS_fnc_MP"

 

Also, the first sentence on this page - http://killzonekid.com/arma-scripting-tutorials-locality/ - is pretty important. You'll want to get your head around the rest of that tutorial. 

  • Like 1

Share this post


Link to post
Share on other sites
8 minutes ago, beno_83au said:

Use remoteExec in preference to BIS_fnc_MP. As per one of the comments on the wiki:

 

"Executing commands/functions via remoteExec is more faster than using BIS_fnc_MP"

 

Also, the first sentence on this page - http://killzonekid.com/arma-scripting-tutorials-locality/ - is pretty important. You'll want to get your head around the rest of that tutorial. 


I'm not quite sure I understand, I tried remoteExec already and it didn't work, calling the script from a trigger with {[] execVM "flight.sqf"} remoteExec ["bis_fnc_call",0];

 

I read through the tutorial, I understand how the locality works I just don't know how to code it to change it. So if I understand the tutorial correctly I want the script to execute remotely, but I'm not good enough at coding to create a function, so how would I go about getting the SQF to execute remotely then?

Share this post


Link to post
Share on other sites

Can't test any further tonight unfortunately because it's late and all of my guinea pigs have gone to bed, but I'm curious if

if ((isMultiplayer) && (isDedicated)) exitWith {};

would have any effect at the beginning of the SQF file... probably not but I'm pretty much throwing stuff at the wall now.

Share this post


Link to post
Share on other sites

Not sure if I'm understanding this correctly... but defining the script as a function might be a way to get it broadcasted to all players?

And creating a function is just creating a script, and using this line in the init.sqf to turn it into a function?
MY_fnc_do = compile preprocessFile "Flight.sqf";


Then I call it with the MP function ...

[[Player], "MY_fnc_do"] spawn BIS_fnc_MP;

 

Would this work or am I entirely off base?


Source:

 

Share this post


Link to post
Share on other sites

Found this tutorial on function making, going to test the results to see if the clients are effected by the script as well this time.

 

Testing
 

[] spawn FL_fnc_flight

EDIT: This did not work, didn't even call the script at all. Not sure what I did wrong. Called the function from the description.ext with

class CfgFunctions 
{
	#include "vcom\cfgFunctions.hpp"
	#include "functions\clients\cfgFunctions.hpp"
};


Changed the following code from Flight.sqf to fn_Flight.sqf
 

sleep 3;
Helicopter1A say3d "Pilot1";
sleep 38;
Helicopter1A say3d "Pilot2";
sleep 19;
Helicopter1A say3d "Pilot3";
sleep 12;
Helicopter1A say3d "Pilot4";
sleep 15;

cutText ["","BLACK IN"];
cutText ["","BLACK OUT"];
 sleep 2;
cutText ["","BLACK IN"];
cutText ["","BLACK OUT"];
 sleep 1;
cutText ["","BLACK IN"];
cutText ["","BLACK OUT"];
 sleep 2;

P1 setpos getMarkerPos "CrashSite1";
P1 setpos getMarkerPos "CrashSite2";
P1 setpos getMarkerPos "CrashSite3";
P1 setpos getMarkerPos "CrashSite4";
P1 setpos getMarkerPos "CrashSite5";
P1 setpos getMarkerPos "CrashSite6";
P1 setpos getMarkerPos "CrashSite7";
			  
 p1 setUnconscious true;
 p2 setUnconscious true;
 p3 setUnconscious true;
 p4 setUnconscious true;
 p5 setUnconscious true;
 p6 setUnconscious true;
 p7 setUnconscious true;
 Wreck1 setpos getMarkerPos "CrashSiteHeli";
 Smoke1 setpos getMarkerPos "CrashSiteSmoke";
 sleep 0.1;
 Wreck1 say3d "HelicopterCrash1";
 sleep 1;
 deletevehicle Helicopter1;
 deletevehicle Helicopter1A;
 deletevehicle Helicopter1B;
 sleep 7;
 cutText ["","BLACK IN"];
 sleep 5;
 p1 setUnconscious false;
 p2 setUnconscious false;
 p3 setUnconscious false;
 p4 setUnconscious false;
 p5 setUnconscious false;
 p6 setUnconscious false;
 p7 setUnconscious false;



Created a cfgfunctions.hpp file with the following code

class FL
{
	tag = "FL";
	class clients
	{
		file = "functions\clients";
		class Flight {};
	};
};

// [] spawn FL_fnc_Flight

 

Share this post


Link to post
Share on other sites

Okay update.

I have tested the

["Flight.sqf","BIS_fnc_execVM",true,true ] call BIS_fnc_MP;

code in a triggers init. This "sort of" worked, progress anyway.

The sounds played for the players, unfortunately it played twice for each player, maybe even 3 times, I'm not sure why. However the main problem is that it DIDN'T execute the teleport script. I'm not quite sure where to go from here.

Share this post


Link to post
Share on other sites

Tested

 

[] remoteExec ["FL_fnc_Flight", 0, false];

and

 

[] remoteExec ["Flight.sqf", 0, false];

 

Neither of which work in the editor, curious if they will work in multiplayer and I will test later but I don't think its going to work. Is there a problem with my syntax?

Share this post


Link to post
Share on other sites

Okay, I am seeing a potential problem with using

remoteExec ["FL_fnc_Flight", 0]; 

which is that it isn't' defined in the RemoteExecCFG in the description.ext which is defined on the wiki as

 

class CfgRemoteExec
{
	// List of script functions allowed to be sent from client via remoteExec
	class Functions
	{
		// RemoteExec modes:
		// 0- turned off
		// 1- turned on, taking whitelist into account
		// 2- turned on, ignoring whitelist (default, because of backward compatibility)
		mode = 2;

		// Ability to send jip messages: 0-disabled, 1-enabled (default)
		jip = 1;

		// your functions here
		class BIS_fnc_aFunction
		{
			allowedTargets = 0;	// can target anyone (default)
			jip = 0;			// sending JIP messages is disabled for this function (overrides settings in the Functions class)
		};
		class YourFunctionOne { allowedTargets = 1; }; // can target only clients
		class YourFunctionTwo { allowedTargets = 2; }; // can target only the server
	};

	// List of script commands allowed to be sent from client via remoteExec
	class Commands
	{
		// your commands here
		class setDir
		{
			allowedTargets = 2;	// can target only the server
			jip = 0;			// sending JIP is turned off (overrides settings in the Commands class)
		};
	};
};

 

The problem I'm encountering is that I can't seem to see anywhere I can define the location of the SQF file (Flight.sqf) to be read. Can someone help me figure out how I set it as a function in the CfgRemoteExec? The cfgfunctions.hpp for CfgFunctions is pretty straight forward, but this RemoteExecCfg I don't understand and can't find any material online for.

Share this post


Link to post
Share on other sites

PROGRESS!

 

null = [[""], "functions\clients\fn_Flight.sqf"] remoteExec ["execVM", 0, true];

 

Works, the second players are just delayed from the host for some reason and are falling to their death at the beginning of the black out simulation, then they hit the ground and die before the teleport script effects them. I think I can fix this. Also I believe the audio bug of it broadcasting twice is because the helicopter itself is hitting the triggers along with my timed trigger so both scripts are running at once.

Share this post


Link to post
Share on other sites

Okay, so the aforementioned script

null = [[""], "functions\clients\fn_Flight.sqf"] remoteExec ["execVM", 0, true]; 

started to execute the code on the clients once I fixed the timing, they would black out, black in, black out, black in etc. however the teleport portion of the script is not functioning. The player drops to their death still, and another problem is that for the server, the sounds now play 3 times, and for the clients it plays twice in a row. ANY help would be helpful.

 

P1 setpos getMarkerPos "CrashSite1";
P1 setpos getMarkerPos "CrashSite2";
P1 setpos getMarkerPos "CrashSite3";
P1 setpos getMarkerPos "CrashSite4";
P1 setpos getMarkerPos "CrashSite5";
P1 setpos getMarkerPos "CrashSite6";
P1 setpos getMarkerPos "CrashSite7";

 

Share this post


Link to post
Share on other sites

SUCCESS!

 

The script now functions! I had P1 instead of the other classnames for the units (unfortunate accident of continually changing out the script)

 

HOWEVER! I am now getting TWO sound file replays instead of the original three. So the voice acting plays itself twice for some reason. I assume this is due to the command I'm using. Hopefully someone, anyone, can give me an answer on why it might be playing the sound files twice

 

EDIT: I wonder if this has to do with this code, specifically the integer "0", I will attempt to set it to -2 to broadcast only to the players and not the server.

 

null = [[""], "functions\clients\fn_Flight.sqf"] remoteExec ["execVM", 0, true];

Share this post


Link to post
Share on other sites

if (!isServer) exitWith {};

Added this line to the beginning of the script, I will test to see if this gets rid of the double broadcasting.

I have the teleportation working great now, with the exception of one problem. For some reason, the AI instead of teleporting to their location they're supposed to (a marker) they instead respawn back to where they started in the beginning of the mission. Not really game breaking but a bit immersion breaking. Anyone have any ideas why they might be starting at their spawn location when the script is teleporting players just fine?

 

P1 setpos getMarkerPos "CrashSite1";
P2 setpos getMarkerPos "CrashSite2";
P3 setpos getMarkerPos "CrashSite3";
P4 setpos getMarkerPos "CrashSite4";
P5 setpos getMarkerPos "CrashSite5";
P6 setpos getMarkerPos "CrashSite6";
P7 setpos getMarkerPos "CrashSite7";

Share this post


Link to post
Share on other sites

Managed to fix the AI not teleporting with the player issue (must be something with calling the command with remoteExec, but I called a script from the trigger to teleport them separately when a player enters and it works just fine. Still need to test the fix for the sound issue.

Share this post


Link to post
Share on other sites

The sound fix of calling if (!isServer) exitWith {}; did not work. The sound files are still playing one after the other with Say3D. I tested this with only 2 players counting myself, I'm worried that it might trigger once PER player.

Hearing the same sound effect over and over again is LITERALLY giving me a head ache, so some help here would be lovely.

Share this post


Link to post
Share on other sites

Word of advice: don't update a forum topic every hour or so as you encounter minor problems and work out the solutions. There's probably too much back-and-forth from problem to solution to next problem for most people to read through and provide help. This kind of posting seems like it belongs on a blog or some other personal platform, not a forum. You'd be far better off exhausting your knowledge/ability and available resources (including searching for posts to do with your problems, cause they're out there), then coming here to ask for help. Unfortunately at this point i think you've effectively flooded your own topic. 

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, beno_83au said:

Word of advice: don't update a forum topic every hour or so as you encounter minor problems and work out the solutions. There's probably too much back-and-forth from problem to solution to next problem for most people to read through and provide help. This kind of posting seems like it belongs on a blog or some other personal platform, not a forum. You'd be far better off exhausting your knowledge/ability and available resources (including searching for posts to do with your problems, cause they're out there), then coming here to ask for help. Unfortunately at this point i think you've effectively flooded your own topic. 

 

About as useful as your previous post. I am keeping a record of what I've tried, what works and doesn't work. This forum will be more useful for the people researching this problem in the future who encounter the same error I'm encountering.

 

This forum is clearly dead regardless, I'm the only one actually answering other peoples questions.

 

Instead of spending your energy to help, you decided to troll instead. I don't know why I bothered coming to the forums in the first place when the only responses I get are this kind of pretentious garbage. If it bothers you that much, turn off notifications, you didn't have to enter this thread just to whine.

  • Confused 1

Share this post


Link to post
Share on other sites

Well, my previous post pointed out that remoteExec is superior to BIS_fnc_MP, then i pointed you in the direction of one of the best collection of tutorials to be found anywhere, and even gave you the page to start looking at to learn how to do what you're trying to do properly. 

 

The next post was advice on being more succinct when asking for help on a forum, as this thread is now bloated with information that doesn't really help the initial problem.

 

As for claiming I'm trolling instead of helping, like i said, there plenty of posts already out there that you could've gone through to find a solution. That being said, starting your own topic is not a problem. Filling it with constant updates and ignoring the help i attempted to provide, is. I'd say that's contributed to the lack of help you've gotten from anyone else, as these forums certainly aren't dead.....

 

And i don't have notifications on for this thread. Just tried to help out and got called a troll. 

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

×