Why doesn't it play the sound ?

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 29th, 2010, 4:34 pm

I made the following script and it should play a sound at 5 minutes left in the game.

Code: Select all

thread time();

}
time()
{
level.timelimit = getCvarFloat("scr_dm_timelimit");
timeleft = (level.timelimit - getTime()) / 1000;
timeleft = timeleft / 60;
timepassed = 300;
player = getentarray("player", "classname");
if(timeleft == timepassed)
player playsound ("5minutes");
}
But it doesn't, does anybody see waht is wrong ? (300 = 5 minutes ?? right)

mr-x
CJ Newbie
CJ Newbie
Posts: 61
Joined: March 7th, 2010, 3:33 pm

Re: Why doesn't it play the sound ?

Post by mr-x » May 29th, 2010, 5:38 pm

lol!
did u make Soundalias?

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 29th, 2010, 7:42 pm

:) ofcourse m8 and the line below is in there;

Code: Select all

#   5minutes
5minutes,,misc/5minutes.wav,1,1,,,,1000000,,auto,streamed

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Why doesn't it play the sound ?

Post by Drofder2004 » May 29th, 2010, 7:49 pm

Code: Select all

timePassed = (getTime() - level.startTime)/1000;
//(getTime() is counted in milliseconds, level.starttime will normally be 0 or close...
// Dividing by 1000 returns the milliseconds to seconds.

timeRemaining = (level.timeLimit * 60) - timePassed;
// timelimit is measured in minutes, multiply by 60 to get seconds
// Once we have the timelimit in seconds, we subtract the timepassed, from the timelimit.

if(timeRemaining <= 300)
   //playsound
Copied for reference.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 29th, 2010, 9:25 pm

Ok, my code looks like this now;

Code: Select all

thread time();

}
time()
{
player = getentarray("player", "classname");
timepassed = (getTime() - level.startTime)/1000;
timeRemaining = (level.timelimit * 60) - timePassed;
if(timeRemaining <= 300)
player playsound ("mp_jumppad");//this sound definately works
}
But I get the following compile error;

Code: Select all

******* script runtime error *******
pair '0' and 'undefined' has unmatching types 'int' and 'undefined': (file 'maps/mp/mp_deck16.gsc', line 30)
timepassed = (getTime() - level.startTime)/1000;
                        *
called from:
(file 'maps/mp/mp_deck16.gsc', line 24)
thread time();
       *
started from:
(file 'maps/mp/mp_deck16.gsc', line 1)
main()
*
************************************
I think the level.starttime has to be defined somewhere ?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Why doesn't it play the sound ?

Post by Drofder2004 » May 29th, 2010, 10:13 pm

level.starttime should be assigned a value when the gametypes start, I am sure this is the case of at least dm.gsc...

Add it to the first line of your gsc...
level.starttime = getTime();
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 29th, 2010, 10:24 pm

Code: Select all

thread time();

}
time()
{
level.starttime = getTime();
player = getentarray("player", "classname");
timepassed = (getTime() - level.startTime)/1000;
timeRemaining = (level.timelimit * 60) - timePassed;
if(timeRemaining <= 300)
player playsound ("mp_jumppad");//this sound definately works
}
Now it's : timepassed = (gettime() - level.starttime(=gettime())/1000;
Is this correct ... seems strange to me.
But I put the code above in my gsc and I get the following compile error;

Code: Select all

******* script runtime error *******
pair 'undefined' and '60' has unmatching types 'undefined' and 'int': (file 'maps/mp/mp_deck16.gsc', line 33)
timeRemaining = (level.timelimit * 60) - timePassed;
                                 *
called from:
(file 'maps/mp/mp_deck16.gsc', line 25)
thread time();
       *
started from:
(file 'maps/mp/mp_deck16.gsc', line 1)
main()
*
************************************
Any ideas ?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Why doesn't it play the sound ?

Post by Drofder2004 » May 29th, 2010, 11:39 pm

Slight misunderstanding.

Go to your main() function and add a single line with

Code: Select all

main()
{
   level.startTime = getTime();
   thread time();
}

time()
{
   while(timeRemaining() <= 300)
      wait 1;

   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
      players[i] playLocalsound("mp_jumppad");
}

timeRemaining()
{
   timepassed = (getTime() - level.startTime)/1000;
   timeRemaining = (level.timelimit * 60) - timePassed;
   return timeRemaining;
}
Just to explain, for learning purposes...
The 'time()' function, now simply continuosly loops until the "return" of 'timeRemaining()' function is less or equal to 300.
Once this event happens, the loop breaks and the function continues. An array of players is listed and a quick loop will play a local sound on all of them.

The 'timeRemaining()' function will simply calculate the time that remains and 'return' the value.

Code is untested, let me know of errors.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 30th, 2010, 6:33 pm

The level.timelimit also has to be defined so I did (used the dm_gsc file);

Code: Select all

main()
{
  level.timelimit = getcvarfloat("scr_dm_timelimit");
  level.startTime = getTime();
   thread time();
}

time()
{
   while(timeRemaining() <= 300)
      wait 1;

   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
      players[i] playsound("jump_pad");
}

timeRemaining()
{
   timepassed = (getTime() - level.startTime)/1000;
   timeRemaining = (level.timelimit * 60) - timePassed;
   return timeRemaining;
}
But still it won't play (the sound was jump_pad by the way...my mistake :oops: )
I don't get any errors btw.

My other gsc file looks like this (maybe there is a mistake in there which I doubt)

Code: Select all

main()
{

maps\mp\_load::main();
ambientPlay("ambient_mp_deck16");
maps\mp\bounce_jump::main();
maps\mp\remaining::main();

game["allies"] = "british";
game["axis"] = "german";
game["british_soldiertype"] = "airborne";
game["british_soldiervariation"] = "normal";
game["german_soldiertype"] = "fallschirmjagergrey";
game["german_soldiervariation"] = "normal";
game["attackers"] = "allies";
game["defenders"] = "axis";

setcvar ("g_gravity", 800);
setcvar ("g_speed" , 350);
setcvar ("jump_height" ,85);
setcvar ("bg_fallDamageMinHeight", 100000); 
setcvar ("bg_fallDamageMaxHeight", 200000);
setcvar ("scr_dm_timelimit" , "5.10");


}
And my csv file is this;

Code: Select all

#  ///jumppad/// 

jump_pad,,misc/jump_pad.wav,1,,,,,500,1000,auto,streamed,,,,mp_deck16

#   Ambiance
ambient_mp_deck16,,ambient/deck16.mp3,0.15,0.15,,,,,,local,streamed,,looping,,mp_deck16

#   fiveminutes
fiveminutes,,misc/fiveminutes.wav,1,,,,,500,1000,local,streamed,,,,mp_deck16
Thx drof for taking the time to help me btw.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Why doesn't it play the sound ?

Post by Drofder2004 » May 30th, 2010, 11:57 pm

Code: Select all

timeRemaining()
{
   timepassed = (getTime() - level.startTime)/1000;
   timeRemaining = (level.timelimit * 60) - timePassed;
   iprintln(timeRemaining);
   return timeRemaining;
}
Tell me what comes about from doing this...
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 31st, 2010, 10:37 am

Ok m8, i'll try it when i get home.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 31st, 2010, 7:21 pm

Script is this but gives no print text or error message;

Code: Select all

main()
{
  level.timelimit = getcvarfloat("scr_dm_timelimit");
  level.startTime = getTime();
  thread time();
}

time()
{
   while(timeRemaining() <= 300)
      wait 1;

   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
      players[i] playsound("jump_pad");
}

timeRemaining()
{
   timepassed = (getTime() - level.startTime)/1000;
   timeRemaining = (level.timelimit * 60) - timePassed;
   iprintln(timeRemaining);
   return timeRemaining;
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Why doesn't it play the sound ?

Post by Drofder2004 » May 31st, 2010, 7:31 pm

Try.

Code: Select all

main()
{
  level.timelimit = getcvarfloat("scr_dm_timelimit");
  level.startTime = getTime();
  thread time();
}

time()
{
   iprintln(timeRemaining());
   while(timeRemaining() <= 300)
      wait 1;

   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
      players[i] playsound("jump_pad");
}

timeRemaining()
{
   timepassed = (getTime() - level.startTime)/1000;
   timeRemaining = (level.timelimit * 60) - timePassed;
   return timeRemaining;
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Why doesn't it play the sound ?

Post by <LT>YosemiteSam[NL] » May 31st, 2010, 7:37 pm

Don't work either. :(
Where should it print the text ?

mr-x
CJ Newbie
CJ Newbie
Posts: 61
Joined: March 7th, 2010, 3:33 pm

Re: Why doesn't it play the sound ?

Post by mr-x » May 31st, 2010, 8:17 pm

must work try play sount like this
trigger waittill("trigger",player);
playersound("blalal");
wat 0.5;
check if sound play or not
if not
make sure u add ur sound folder into iwd and run map normal not from compiler
will work

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests