Rotating weapon help

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:

Re: Rotating weapon help

Post by <LT>YosemiteSam[NL] » July 12th, 2010, 10:19 pm

ok thx.

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Rotating weapon help

Post by Rezil » July 12th, 2010, 11:42 pm

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
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Rotating weapon help

Post by megazor » July 13th, 2010, 4:35 am

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.

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Rotating weapon help

Post by Nightmare » July 13th, 2010, 9:43 am

Try replacing this:

Code: Select all

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

Code: Select all

players[i] playLocalSound("jump_pad");
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

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

Re: Rotating weapon help

Post by <LT>YosemiteSam[NL] » July 13th, 2010, 3:18 pm

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;
}

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Rotating weapon help

Post by Nightmare » July 13th, 2010, 6:34 pm

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.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

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

Re: Rotating weapon help

Post by Drofder2004 » July 13th, 2010, 7:20 pm

As said, you need to use local sound.
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: Rotating weapon help

Post by <LT>YosemiteSam[NL] » July 13th, 2010, 8:12 pm

Aha ok. But if I put "localsound" into the csv file that would be alright aswell....right ?

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Rotating weapon help

Post by Nightmare » July 13th, 2010, 10:49 pm

Just have it set as auto, CoD2 will do the rest in game.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Rotating weapon help

Post by megazor » July 14th, 2010, 10:10 am

Code: Select all

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

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests