Page 1 of 2

Why doesn't it play the sound ?

Posted: May 29th, 2010, 4:34 pm
by <LT>YosemiteSam[NL]
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)

Re: Why doesn't it play the sound ?

Posted: May 29th, 2010, 5:38 pm
by mr-x
lol!
did u make Soundalias?

Re: Why doesn't it play the sound ?

Posted: May 29th, 2010, 7:42 pm
by <LT>YosemiteSam[NL]
:) ofcourse m8 and the line below is in there;

Code: Select all

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

Re: Why doesn't it play the sound ?

Posted: May 29th, 2010, 7:49 pm
by Drofder2004

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.

Re: Why doesn't it play the sound ?

Posted: May 29th, 2010, 9:25 pm
by <LT>YosemiteSam[NL]
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 ?

Re: Why doesn't it play the sound ?

Posted: May 29th, 2010, 10:13 pm
by Drofder2004
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();

Re: Why doesn't it play the sound ?

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

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 ?

Re: Why doesn't it play the sound ?

Posted: May 29th, 2010, 11:39 pm
by Drofder2004
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.

Re: Why doesn't it play the sound ?

Posted: May 30th, 2010, 6:33 pm
by <LT>YosemiteSam[NL]
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.

Re: Why doesn't it play the sound ?

Posted: May 30th, 2010, 11:57 pm
by Drofder2004

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...

Re: Why doesn't it play the sound ?

Posted: May 31st, 2010, 10:37 am
by <LT>YosemiteSam[NL]
Ok m8, i'll try it when i get home.

Re: Why doesn't it play the sound ?

Posted: May 31st, 2010, 7:21 pm
by <LT>YosemiteSam[NL]
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;
}

Re: Why doesn't it play the sound ?

Posted: May 31st, 2010, 7:31 pm
by Drofder2004
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;
}

Re: Why doesn't it play the sound ?

Posted: May 31st, 2010, 7:37 pm
by <LT>YosemiteSam[NL]
Don't work either. :(
Where should it print the text ?

Re: Why doesn't it play the sound ?

Posted: May 31st, 2010, 8:17 pm
by mr-x
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