Page 5 of 5

Re: Rotating weapon help

Posted: July 12th, 2010, 10:19 pm
by <LT>YosemiteSam[NL]
ok thx.

Re: Rotating weapon help

Posted: July 12th, 2010, 11:42 pm
by Rezil
It's done simmilarly there, so that didn't get me anywhere. Have tried simply getting all the players on the server and printing a message to all of them. Didn't work. :S

Re: Rotating weapon help

Posted: July 13th, 2010, 4:35 am
by megazor
here's the code i wrote. it's cod1, but should be working for cod2.

Code: Select all

time()
{
	if (!isDefined(level.timelimit_custom))
	{
		level.timelimit_custom = getCvarFloat("scr_dm_timelimit");
		level.realtime_custom = getTime();
	}

   	while (timeleft() > 300)
      		wait 1;
   	
      	iPrintLnBold("5 minutes left");
	wait 1;
	level.timelimit_custom = getCvarFloat("scr_dm_timelimit");
	//thread time();	//unlock this string if you want to let the script print it again if some admin changed (extended) timelimit after the printing
}

timeLeft()
{
	if (level.timelimit != getCvarFloat("scr_dm_timelimit"))
	{
		level.timelimit_custom = getCvarFloat("scr_dm_timelimit");
		level.realtime_custom = getTime();
	}
   
	realtime = (getTime()-level.realtime_custom)/1000;

   	timeleft = getCvarFloat("scr_dm_timelimit")*60 - realtime;
	if (timeleft < 300) timeleft = 1000;	//if timelimit is less than 5 minutes, do not let the script print anything to players
   	return timeleft;
}
i advide using custom variables in order not to have troubles with stock ones. however, probably in it i'm mistaken.
but i'm sure i had some troubles with changing timelimit by stock variables being used.

Re: Rotating weapon help

Posted: July 13th, 2010, 9:43 am
by Nightmare
Try replacing this:

Code: Select all

players[i] playsound("jump_pad");
with this:

Code: Select all

players[i] playLocalSound("jump_pad");

Re: Rotating weapon help

Posted: July 13th, 2010, 3:18 pm
by <LT>YosemiteSam[NL]
Thx alot magazor ! It works fine, you forgot the word custom in one of the lines but i forgive you :wink:
This is the final code which plays the announcers voice "5minutes remaining" of UT99.

Code: Select all

main()
{
  thread time();
}

time()
{
   if (!isDefined(level.timelimit_custom))
   {
      level.timelimit_custom = getCvarFloat("scr_dm_timelimit");
      level.realtime_custom = getTime();
      
   }
      
      while (timeleft() > 300)
            wait 1;
        player = getent("player","classname");
        player playsound("fiveminutes");
   
   wait 1;
   level.timelimit_custom = getCvarFloat("scr_dm_timelimit");
   //thread time();   //unlock this string if you want to let the script print it again if some admin changed (extended) timelimit after the printing
}

timeLeft()
{
   if (level.timelimit_custom != getCvarFloat("scr_dm_timelimit"))
   {
      level.timelimit_custom = getCvarFloat("scr_dm_timelimit");
      level.realtime_custom = getTime();
   }
   
   realtime = (getTime()-level.realtime_custom)/1000;

      timeleft = getCvarFloat("scr_dm_timelimit")*60 - realtime;
   if (timeleft < 300) timeleft = 1000;   //if timelimit is less than 5 minutes, do not let the script print anything to players
      return timeleft;
}

Re: Rotating weapon help

Posted: July 13th, 2010, 6:34 pm
by Nightmare
The sound will sound a lot better if you replace playSound with playLocalSound.
The reason I say this is because it will play the sound out loud from your player origin.
So say you have multiple players in the server, they will all be outputting this sound into the world, which will sound awkward.
Using playLocalSound will only pass the sound through the players' speakers only, avoiding the echo/repeating sound.

Re: Rotating weapon help

Posted: July 13th, 2010, 7:20 pm
by Drofder2004
As said, you need to use local sound.

Re: Rotating weapon help

Posted: July 13th, 2010, 8:12 pm
by <LT>YosemiteSam[NL]
Aha ok. But if I put "localsound" into the csv file that would be alright aswell....right ?

Re: Rotating weapon help

Posted: July 13th, 2010, 10:49 pm
by Nightmare
Just have it set as auto, CoD2 will do the rest in game.

Re: Rotating weapon help

Posted: July 14th, 2010, 10:10 am
by megazor

Code: Select all

player = getent("player","classname")
this code returns only one player. u should use the function getentarray()