Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 6 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: I would like to put a touch activated mp3 into my map.
Harpattack
General Member
Since: Aug 14, 2007
Posts: 32
Last: Mar 24, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Friday, Mar. 2, 2012 10:26 pm
I have read many tutorials but I havn't found one for touch on and off activation. Can anyone please help me.
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Mar. 3, 2012 12:30 am
shall it sound like coming from a certain spot?
Share |
Harpattack
General Member
Since: Aug 14, 2007
Posts: 32
Last: Mar 24, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Mar. 3, 2012 04:53 am
what wouldnt add alot of lag, certain location or throughout at a low even volume.
Share |
Mystic
General Member
Since: Apr 10, 2004
Posts: 6147
Last: Apr 15, 2018
[view latest posts]
Level 10
Forum Moderator
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Saturday, Mar. 3, 2012 08:59 am
Have a look at this

It's written for WaW but its doesn't really change much throughout the entire game series. Im not sure if cod4 uses script_structs, if not you can use script_origins instead.

That should get you started, if you have problems let us know.
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Mar. 3, 2012 09:36 am
even volume is possible via ambientplay() and musicplay(), but will be played for all players

so playSoundToPlayer is the only option for your case, which plays a sound as if coming from an entity. if the alias got the following settings, it might sound like even volume:

vol_min 1
vol_max 1
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Mar. 3, 2012 06:08 pm
here is the relevant code of the tutorial Mystic posted:


Code:
main()
{
	thread radio();
	thread generator();
}

radio()
{
	radio = getent("radio", "targetname");
	trig = getent("radiotrig", "targetname");
	while (1)
	{
		trig waittill("trigger");
		radio playsound("talk_01");
		wait (36);
	}
}

generator()
{
	generator = getent("generator", "targetname");
	trig = getent("generatortrig", "targetname");
	while (1)
	{
		trig waittill("trigger");
		generator playsound("run_01");
		wait (3);
	}
}


if you changed it to:
trig waittill("trigger", player);
generator playsoundtoplayer("run_01", player);

it wouldn't work, as it will wait the given time before playing it again - which is fine for 1 player - but the first player will block the audio output for all other players.

you may try this (untested):

Code:
main()
{
	thread radio();
	thread generator();
}

radio()
{
	radio = getent("radio", "targetname");
	trig = getent("radiotrig", "targetname");
	trig thread playsoundtoplayer_thread(radio, "talk_01", 36);
}

generator()
{
	generator = getent("generator", "targetname");
	trig = getent("generatortrig", "targetname");
	trig thread playsoundtoplayer_thread(generator, "run_01", 3);
}

playsoundtoplayer_thread(entity, soundalias, waittime)
{
	while (1)
	{
		self waittill("trigger", player);

		if (isdefined(player.soundtrig_wait) && player.soundtrig_wait)
		{
			wait (0.05);
			continue;
		} else {
			entity thread playsoundtoplayer_wait(soundalias, player, waittime);
			wait (0.05);
		}
	}
}

playsoundtoplayer_wait(soundalias, player, waittime)
{
			player.soundtrig_wait = 1;
			self playsoundtoplayer(soundalias, player);
			wait (waittime);
			player.soundtrig_wait = 0;
}
Share |
Harpattack
General Member
Since: Aug 14, 2007
Posts: 32
Last: Mar 24, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, Mar. 4, 2012 07:33 am
Thanks I will give it a try, this is with a trigger or script origin?
Share |
Harpattack
General Member
Since: Aug 14, 2007
Posts: 32
Last: Mar 24, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, Mar. 4, 2012 09:15 am
Sevenz writes...
Quote:
even volume is possible via ambientplay() and musicplay(), but will be played for all players

so playSoundToPlayer is the only option for your case, which plays a sound as if coming from an entity. if the alias got the following settings, it might sound like even volume:

vol_min 1
vol_max 1


When a player hits the f to start the play will all others hear the music in the distance and near? or just that player?
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Sunday, Mar. 4, 2012 09:49 am
it's trigger plus another entity, e.g. a script_model, but can also be script_origin (to be used as virtual sound source)

playSoundToPlayer will play it for the triggering player only.

not entirely sure if my suggested code will work for trigger_use, i thought you wanted trigger_multiple
Share |
Harpattack
General Member
Since: Aug 14, 2007
Posts: 32
Last: Mar 24, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, Mar. 4, 2012 02:59 pm
Im looking for the normal ambient sounds to be heard but when someone triggers the music all will hear the music coming from a location. I will draw them in and kill em all lol.
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»