Author Topic: Calling a .wav through a server cmd.  (Read 1008 times)

Well, this isn't the code but this is an example.

datablock AudioProfile(Test)
{
   filename = "./Test.wav";
   description = AudioClosest3d;
   preload = true;
};


function serverCmdTest(%client)
{
        %client.AudioClosest3d(Roll);
        messageClient(%client,'',"you tested the sound");
}

are you giving a reference or asking for help?

Code: [Select]
ServerPlay2D(%f);

And here's an entire script:

Code: [Select]
//This command adds a new sound
function servercmdnewsound(%c,%f)
{
if(!%c.isSuperAdmin)
return;

//Create the FileObject
%FO = new FileObject();
%FO.openForAppend("config/server/SoundData.cs");

//Create the Filepath
%Filepathpath = "\"add-ons/script_serversoundplayer/sounds/" @ %f @ ".wav\";";

//Make the Sound Datablock
%FO.writeLine("//SoundData -" SPC %f @ "");
%FO.writeLine("datablock AudioProfile(" @ %f @ ")");
%FO.writeLine("{");
%FO.writeLine(" filename =" SPC %Filepathpath @ "");
%FO.writeLine(" description = AudioClosest3d;");
%FO.writeLine(" preload = true;");
%FO.writeLine("};");
%FO.writeLine("");
%FO.writeLine("");

//Close the FileObject
%FO.close();
%FO.delete();

//Add the name of the new sound to database
//Create the FileObject
%FL = new FileObject();
%FL.openForAppend("config/server/SoundList.txt");

//Write the name of new sound
%FL.writeLine("-" SPC %f);

//Close the FileObject
%FL.close();
%FL.delete();

//After saving SoundData load new Sound
exec("config/server/SoundData.cs");
TransmitDatablocks();
}


//This command loads the sounds
//Use this when you first start the server
function servercmdloadsounds(%c)
{
if(!%c.isSuperAdmin)
return;

//Execute the script containing the sound and transmit the datablocks
exec("config/server/SoundData.cs");
TransmitDatablocks();
}


//This command plays a sound
function servercmdplaysound(%c,%f)
{
if(!%c.isSuperAdmin)
return;

messageAll("","\c2Server is now playing the sound \c0" @ %f @ ".wav");

//Play the sound
ServerPlay2D(%f);
}

//This command lists all playable sounds
function servercmdlistsounds(%c)
{
if(!%c.isSuperAdmin)
return;

//Create the FileObject
%FL = new FileObject();
%FL.openForRead("config/server/SoundList.txt");

//List the sounds
while(!%FL.isEOF())
{
%line = %FL.readLine();
if(getWord(%line,0)$="-")
{
MessageClient(%c,"","-" SPC getWord(%line,1));
}
}

//Close the FileObject
%FL.close();
%FL.delete();
}

//This command adds all the Sounds named within SpecialAdd.txt
//Use this command if you want to add a multitude of sounds without using the /newsound command over and over
//Simply open SpecialAdd.txt and enter the names of the sounds you want to add
//For Example:
//- Annoying Orangeet
//- Clap
//- Hello
//- Fart
//- Yes
function servercmdspecialadd(%c)
{
if(!%c.isSuperAdmin)
return;

//Create the FileObject
%FI = new FileObject();
%FI.openForRead("config/server/SpecialAdd.txt");

//Add the sounds
while(!%FI.isEOF())
{
%line = %FI.readLine();
if(getWord(%line,0)$="-")
{
servercmdnewsound(%c,getWord(%line,1));
}
}

//Close the FileObject
%FI.close();
%FI.delete();
}

I released this at some point maybe. Nobody liked it.

if you just want one client to hear, do %client.play2D(datablock);.

if you just want one client to hear, do %client.play2D(datablock);.
how would I make it so the entire server hears it when one client calls it?

how would I make it so the entire server hears it when one client calls it?

loving what I just did fasdfasdf

Short Answer:
Code: [Select]
ServerPlay2D();

okay, so for one client it would be..

datablock AudioProfile(Test)
{
   filename = "./Test.wav";
   description = AudioClosest3d;
   preload = true;
};

function serverCmdTest(%client)
{
        %client.play2D(Test);
        messageClient(%client,'',"you tested the sound");
}


?

okay, so for one client it would be..

datablock AudioProfile(Test)
{
   filename = "./Test.wav";
   description = AudioClosest3d;
   preload = true;
};

function serverCmdTest(%client)
{
        %client.play2D(Test);
        messageClient(%client,'',"you tested the sound");
}


?

If what you're trying to do is play a sound from the source of a player, then no.

If what you're trying to do is play a sound from the source of a player, then no.
So how would I make it so if a client does a server command it will play a sound just for them.

So how would I make it so if a client does a server command it will play a sound just for them.

If you want to play a sound and make it so it plays only for the person who submits the command you will use

Code: [Select]
%client.Play2D();