Stopping a Play3D

Author Topic: Stopping a Play3D  (Read 1149 times)

How would I go about stopping the following sound. I'm making a radio in which I need it to stop the previously playing or played song so that the songs do not overlap. Is there a already made function or would I have to make one.

Code: [Select]
serverPlay3D(Adjust, %this.getPosition());
« Last Edit: August 06, 2009, 04:13:16 PM by Kunit »

As far as I know you can't. See if it returns anything. Make it a music brick and blah.setMusic?

As far as I know you can't. See if it returns anything. Make it a music brick and blah.setMusic?
Right, I decided to try it with AlxPlay, and AlxStop.

So far it works great but I've hit a problem with AlxStop, I can not seem to figure out what it means by "Handle",  I've set it up to use the following variables, none seem to stop the previous sound. My code is at the bottom of this post, which includes an example of every peice of code I am using.

Variables:

%play
PERP_Rock_1
PERP_Rock_2
$StationSong[%this.StationID]

Example of AlxStop:

Code: [Select]
alxStop( handle )

Purpose
Use the alxStop function to stop a currently playing sound as specified by handle.
Syntax

handle – The ID (a non-negative integer) corresponding to a previously set up sound source.

Returns
No return value.

See Also
alxIsPlaying, alxPlay, alxStopAll


Code: [Select]

//Radio

$RadioDistance = 30;
$Station[0] = "Off";
$Station[1] = "WPJ";
$Station[2] = "KJR";
$MaxStations = 2;

$StationSong[1] = $CurrentSong[1];
$CurrentSong[1] = "PERP_Rock_1";

$StationSong[2] = $CurrentSong[2];
$CurrentSong[2] = "PERP_Rock_2";

datablock AudioProfile(PERP_Rock_1)
{
   filename    = "Add-ons/Kunit_DarkRP/Sounds/Radio/1/1.wav";
   description = AudioClosest3D;
   preload = true;
};

function GameConnection::NextStation(%client,%this) //Called by the previous func
{
alxStop(//VariablesHere);
%this.StationID += 1;
%play = alxPlay($StationSong[%this.StationID],%this.getPosition());
%client.Dis("\c6Radio: \c0" @ $Station[%this.StationID] @ "");
echo("Next Station!");
}

function GameConnection::StationOff(%client,%this)  //Called by the previous func
{
echo("Radio: Off");
%this.StationID = 0;
%this.IsPlaying = 0;
%client.Dis("\c6Radio: \c0Off!");
return;
}

Does alxPlay return the handle of the sound source it created?

yes

The problem here is you're mixing clientside and serverside code. alxPlay is a clientside sound command mainly used for GUI sfx so a client calling this on a server would just make it play for the host (presuming you're not on a dedicated).
« Last Edit: August 07, 2009, 11:20:27 AM by Ephialtes »

You could do it with client-commands but then only people with your mod could hear the music. And you'd need to transmit datablock IDs or something weird to get the clientside sound data.

Odd, this is going to be more complicated then I presumed, thanks for the help. Hopefully I can get a version working by later today.