Jump to content
EmC-Unit

Play audio in a script

Recommended Posts

Hey people, i'm trying to add a sound in the script when action happens and need your help, everything iv'e tryed - failed

 

object Strahlung_messen : CommandScript{	Strahlung_messen()	{		SetIcon("geiger");		SetCursor("geiger");		SetValidTargets(ACTOR_FLOOR | ACTOR_STREET);	}		bool CheckTarget(GameObject *Caller, Actor *Target, int childID)	{		return true;	}	void PushActions(GameObject *Caller, Actor *Target, int childID)	{	Vector tpos = Game::GetCommandPos();			if(Game::IsInTrigger("flu01", tpos))// Name des Triggers		{		Caller->PushActionMove(ACTION_APPEND, tpos);		Caller->PushActionSwitchAnim(ACTION_APPEND,"useobjmid");		Caller->PushActionWait(ACTION_APPEND, 5);		Caller->PushActionExecuteCommand(ACTION_APPEND,"Meldung1",Target);		return;		}		else		{		Caller->PushActionMove(ACTION_APPEND, tpos);		Caller->PushActionSwitchAnim(ACTION_APPEND,"useobjmid");		Caller->PushActionWait(ACTION_APPEND, 5);		Caller->PushActionExecuteCommand(ACTION_APPEND,"Meldung2",Target);		}	}};object Meldung1: CommandScript{	Meldung1()	{		SetIcon("geiger");		SetCursor("geiger");	}		bool CheckTarget(GameObject *Caller, Actor *Target, int childID)	{		return true;				}	void PushActions(GameObject *Caller, Actor *Target, int childID)	{		Mission::PlayHint("!!!!!!");	}};object Meldung2: CommandScript{	Meldung2()	{		SetIcon("geiger");		SetCursor("geiger");	}		bool CheckTarget(GameObject *Caller, Actor *Target, int childID)	{		return true;				}	void PushActions(GameObject *Caller, Actor *Target, int childID)	{		Mission::PlayHint("T");	}};

Can anybody helps me with what line should i add so it works? it should be simple

Link to comment
Share on other sites

I assume you want to play an audio file in those 2 'Meldung' scripts?

 

try:

 

Audio::PlaySample("mod:Audio/FX/Misc/blah.wav");

 

Obviously, you gotta change the path to the file.This simply plays an audio file.

 

 

In case you want to play the sound from a specific location on the map, use this:

 

Vector pos = Caller->GetPosition();

Audio::PlaySample3D("mod:Audio/FX/mod:Audio/FX/Misc/blah.wav", pos, false);

Link to comment
Share on other sites

I assume you want to play an audio file in those 2 'Meldung' scripts?

 

try:

 

Audio::PlaySample("mod:Audio/FX/Misc/blah.wav");

 

Obviously, you gotta change the path to the file.This simply plays an audio file.

 

 

In case you want to play the sound from a specific location on the map, use this:

 

Vector pos = Caller->GetPosition();

Audio::PlaySample3D("mod:Audio/FX/mod:Audio/FX/Misc/blah.wav", pos, false);

Yes in Meldung. 

Thank you sir, it works!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...