Aller au contenu

Photo

Playing instant sound


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
Nebril2

Nebril2
  • Members
  • 59 messages

Hi all!

 

I want to make a Harp to play an harp sound when used.

 

I have my script when used with tagbased script and all.. but i have just a simple problem.

 

#include "x2_inc_switches"

void main()
{
 
int nEvent =GetUserDefinedItemEventNumber();
if(nEvent !=  X2_ITEM_EVENT_ACTIVATE)return;
 
 
  object oPC = GetItemActivator();
  object oHarp = GetItemActivated();
 
  int n;
 
  AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY2,0.2,6.0));
  DelayCommand(0.2, SetCommandable(0,oPC));
  DelayCommand(15.0, SetCommandable(1,oPC));
  AssignCommand(OBJECT_SELF,PlaySound("harp"));   <------- here is the problem. 
//the rest is not important.
 
 
Using playsound doesnt work, i have to use the name of the sound i created? or the name file sound in data folder? or what?

 

 



#2
EzRemake

EzRemake
  • Members
  • 118 messages

The game for some reason treats PlaySound as if it were an action, so sometimes in order to get it to work properly you need to clear the actions of the object you're calling it on. It's not a guarantee but I'd give it a try.



#3
kalbaern

kalbaern
  • Members
  • 824 messages

I'm assuming that "harp" is the file name of a custom sound you've added yourself. If it is .. try this:

AssignCommand(oPC,PlaySound("harp"));

 

You have to have an object to play a sound, not an item as you have it right now. If the above fails, then try this line instead:

AssignCommand(oPC,PlaySound("sdr_bardsong"));

 

If you are using the CEP, "zep_harp" is also a valid sound file.