Author Topic: Sound files on /command [SOLVED]  (Read 1174 times)

So, I'm trying to make a mod (or find one if it's already made)
Where a certain sound is played when you type a /command

for example

If I had sound_beep

and I typed /beep

It would play sound_beep for the player.


I know it's a simple script, but I'm not exactly sure how to start.

Help appreciated!
« Last Edit: February 01, 2013, 08:47:24 PM by MasterChief55 »

This will play the actual beep at a certain position. Now all you have to do is throw this into a servercmd function and get a position from the client's player
Code: [Select]
serverplay3d(Beep_Checkout_Sound,%position);

This will play the actual beep at a certain position. Now all you have to do is throw this into a servercmd function and get a position from the client's player
Code: [Select]
serverplay3d(Beep_Checkout_Sound,%position);
Uh, thank you... but that's not exactly what I'm looking for

I'm a beginner at this, and I'd like to know where to start.

Alright, I think it would help if I were to be more specific.

I'm trying to make a script that has multiple sounds, and people can play different sounds using a /command, and other people around the person who said it can hear it.
Like let's say I have three sounds in my Script_cmdsounds folder.

Beep.wav
Woop.wav
Honk.wav

Then of course, my description.txt, then my server.cs

My goal is to make it so ANYONE (not just me) can say /beep to play beep.wav, and so on.

And I have NO idea how to do this. If this has already been made, I sure couldn't find anything that works.



Well you have to create a datablock for the wav file. Then you reference that datablock in the serverplay3d. Ill write an example just this one time because you are starting and hopefully you will learn. Not always will you get a full example though
Code: [Select]
//Create the actual beep datablock
datablock AudioProfile(beepSound)
{
   filename    = "./Beep.wav";
   description = AudioClosest3d;
   preload = true;
};
//Create /beep
function servercmdbeep(%client)
{
   //Only play if the player is spawned
   if(isObject(%client.player))
      serverplay3d(beepSound,%client.player.getPosition());
}

Code: [Select]
//Create the actual beep datablock
datablock AudioProfile(beepSound)
{
   filename    = "./Beep.wav";
   description = AudioClosest3d;
   preload = true;
};
//Create /beep
function servercmdbeep(%client)
{
   //Only play if the player is spawned
   if(isObject(%client.player))
      serverplay3d(beepSound,%client.player.getPosition());
}

Do I have to do this for every individual sound?

Thank you, by the way. I'm not on my computer right now, and I don't have access
Until tomorrow, will try then.

function servercmdsound(%cl,%s)
{
   if(isObject(%cl.player) && %cl.isAdmin)
      serverplay3d(%s,%cl.player.getPosition());
}

function servercmdsound(%cl,%s)
{
   if(isObject(%cl.player) && %cl.isAdmin)
      serverplay3d(%s,%cl.player.getPosition());
}

He said that he wanted everyone to be able to use it, not just admins.
And that code won't work that well.
« Last Edit: February 01, 2013, 05:38:15 PM by tkepahama »


Well you have to create a datablock for the wav file. Then you reference that datablock in the serverplay3d. Ill write an example just this one time because you are starting and hopefully you will learn. Not always will you get a full example though
Code: [Select]
//Create the actual beep datablock
datablock AudioProfile(beepSound)
{
   filename    = "./Beep.wav";
   description = AudioClosest3d;
   preload = true;
};
//Create /beep
function servercmdbeep(%client)
{
   //Only play if the player is spawned
   if(isObject(%client.player))
      serverplay3d(beepSound,%client.player.getPosition());
}

It works! Thank you so much, Plornt! Cookies for you!
 :cookie: :cookie: :cookie: :cookie: :cookie: :cookie: :cookie: :cookie: :cookie: :cookie: :cookie: