Author Topic: Playing instant sound  (Read 375 times)

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Playing instant sound
« on: December 02, 2014, 12:42:58 am »


               

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?

 


 



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Playing instant sound
« Reply #1 on: December 02, 2014, 01:33:43 am »


               

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.



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Playing instant sound
« Reply #2 on: December 02, 2014, 03:37:38 am »


               

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.