Jump to content
the1krisrob

exec or execVM? Call or Spawn?

Recommended Posts

I'm having a little trouble with a script I pulled from the forums which is uses the playSound3D command to play a sound local to the player.

 

The script is simply 

[-1, {
	sleep 10;
	MISSION_ROOT = str missionConfigFile select [0, count str missionConfigFile - 15];
	playSound3D [MISSION_ROOT + "sounds\crying.ogg", player, false, getPos player, 5, 1, 75];
	}
] call CBA_fnc_globalExecute;

And it works fine when I call it from a trigger using 

[] exec "creepycrying.sqf"

Except that I get a code error when the trigger runs saying 

'#sleep10;'
Error generic error in expression

So after some research I found this is because I should be using execVM or using the spawn command instead of the call command at the end of the script.
Problem is if I change either of those the script just never seems to run. 

Maybe I'm just not seeing the obvious solution, but that's because I'm still trying to get the hang of scripting, and get confused when there seems to be 2 commands for doing the exact same thing (I assume they're not but for a newbie it does seem that way at times)

 

 

ALSO 

 

While I have you looking at the script how can it be modified so that the sound moves around the player? At the moment it simply "spawns" on the player's location at the time of the script running and stays there.

I'd really like it if the sound could spawn to the players right (for instance) then if the player turns right to face it, the sound moves to his left, and then behind him etc etc if you get what I mean?

 

Thanks for taking the time to look at my problem.

 

When I first envisaged what I wanted I thought I'd be able to just use a trigger to play the sound, and then move the trigger around the player. But you don't seem to get the same customization with triggers.

Share this post


Link to post
Share on other sites

 

 

Now is there any way to move that 3D sound around the player? Say 360 degree circles?

KK, answers this in the last note of the command's wiki page: https://community.bistudio.com/wiki/playSound3D

 

Where the sound is first emitted, it stays, so unless you get creative with the sound and a looping script that keeps up with the central position, then spawns in a new sound at whatever interval over 360 degrees, it won't be as simple as moving the original sound spawned around in a circle around the central position.

Share this post


Link to post
Share on other sites

Damn that's disappointing, although I had a sneaky suspicion that would be the case.

I was hoping you could attachTo a game logic or something. I would have thought that would be the way to put radio chatter in vehicles.

 

Maybe I just forego using 3DSound and just spawn a sound that follows the player and edit the sound in Audacity to sound like it's moving side to side at least to fake some 3D movement.

 

 

*edit actually just using the voice option on a trigger and moving the trigger around the player works ok. Not as well as I hoped, but it'll be enough to disturb the player I hope :p

Share this post


Link to post
Share on other sites

You could also use say3D on a dummy object - it's then only a matter of randomising the relative position of the dummy every once in awhile.

Share this post


Link to post
Share on other sites

Pretty sure you can't, because it doesn't attach to the player, it basically emanates from the position the player was in when you call it.

It's perfect for like a static radio or something like that, but (at least to my limited knowledge) it won't attachto.

Share this post


Link to post
Share on other sites

Pretty sure you can't, because it doesn't attach to the player, it basically emanates from the position the player was in when you call it.

It's perfect for like a static radio or something like that, but (at least to my limited knowledge) it won't attachto.

 

If we are talking about the audio 3d localisation, say3D is working perfect, believe me! ^^

 

Try to spawn, let' say, a pen : Hide it and attach it to the player with attachTo - use a strong offset (like 5 meters right of the player for instance).

Have your pen say something with say3D and run while it does it.

I'm pretty sure the sound will follow you without any interruption, and stay "on your right" all the time.

 

Attaching your speaking pen to a vehicle should work exactly the same and produce a convincing radio effect.

  • Like 2

Share this post


Link to post
Share on other sites

I'd try something similar to this:

_helipad = "Land_HelipadEmpty_F" createVehicle [0,0,0];
_helipad attachTo [player, [0,30,0]]; // The second argument is the offset from the player

_helipad say3d ["sounds\crying.ogg",30,1]

So the sound will follow the player, and when the sound is done playing (or if you want to end it early) all you have to do is:

deleteVehicle _helipad;

However, it wont have the 3D positional audio effect that you're looking for. For that, the one option that sticks out to me is to compare the direction the player is facing to the direction from which you want the sound to play. Then its a matter of using the detach method on the helipad and reattaching it to the player at the proper offset. It sounds fairly complicated, but I'm a noob so there's probably a better way to do this!

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

×