RedHawk504 Posted July 26, 2014 Report Share Posted July 26, 2014 Hello, I want to add a sound to this script, so whenever i click it it will only play a single sound once.What am i doing wrong? //**********************************************************************************************************// #Version 2.0#// // Original script for em3 by: Rev Bem// Made compatible for em4 by: Godra// Godra's version fixed by: Hoppah// Script commented for easier use by: Stan// // Usage of this script in other is allowed with mention of Godra, Hoppah & Rev Bem in the readme////**********************************************************************************************************int DummyGroup = 20; // Definitionen - Hier muss geändert werden! const char AlarmMessage[] = "Container afzetten."; // Die Nachricht die beim Alarm abgespielt wirdconst char AlarmSound[] = "mod:Audio/FX/Motoren/aan.wav"; // Pfad zum Sound der abgespielt wird - muss Mono & WAV sein object wlfloadupTEST : CommandScript{wlfloadupTEST(){SetCursor("wlfloadup");SetIcon("wlfloadup");SetValidTargets(ACTOR_VEHICLE);} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){if(!Caller->IsValid() || !Target->IsValid() || (Caller->GetID()==Target->GetID()))return false; Vehicle v(Target); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //INFO: //[ENG]: Put the link to the e4p file of the container only //[DE]: Hier nur den link zur e4p von dem container reinschreiben //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if(StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/02Brandweer/27.e4p") == 0) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //INFO: //[ENG]: The "if (v.IsInstalled())" function checks if the hose conenctions are curently used //[DE]: Die "if (v.IsInstalled())" function checkt ob schlauch anschlusse benutzt werden //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if (v.IsInstalled()) return false; if(v.GetUserData() == 0) return true; }return false;} void PushActions(GameObject *Caller, Actor *Target, int childID){ Vehicle v(Caller); Vehicle c(Target); v.PushActionMove(ACTION_NEWLIST, Target, TARGET_LOADUP); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //INFO: //[ENG]: Put the link to the e4p file of the container only //[DE]: Hier nur den link zur e4p von dem container reinschreiben //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if(StrCompare(c.GetPrototypeFileName(), "mod:Prototypes/Vehicles/02Brandweer/27.e4p") == 0) { v.PushActionExecuteCommand(ACTION_APPEND, "DummyWLF", Target, 1, false); } } }; object DummyWLF: CommandScript{DummyWLF(){} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){} void PushActions(GameObject *Caller, Actor *Target, int childID){ Vehicle v(Caller); Vehicle c(Target); float r1, r2, r3, r4, r5, r6, r7, r8, r9; Vector pos = v.GetPosition(); v.GetRotation(r1, r2, r3, r4, r5, r6, r7, r8, r9); Vehicle WLF; if(childID == 1) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //INFO: //[ENG]: Put the link to the e4p file of the container truck including container //[DE]: Hier den link zur e4p von dem container truck mit container //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ WLF = Game::CreateVehicle("mod:Prototypes/Vehicles/02Brandweer/53.e4p", "WLF1"); } if(childID == 2) { WLF = Game::CreateVehicle("mod:Prototypes/Vehicles/02Brandweer/53leeg.e4p", "WLF2"); } WLF.SetPosition(pos); WLF.SetRotation(r1, r2, r3, r4, r5, r6, r7, r8, r9); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //INFO: //[ENG]: WLF.SetMaxPassengers(3); = Max units in the container truck (can change if you changed in editor) //[ENG]: WLF.SetSpeed(9.0f); = Vehicle speed 9.0 is egal to 90 //[DE]: WLF.SetMaxPassengers(3); = Einheiten im container truck (kan man heir ander fals im editor geandert) //[DE]: WLF.SetSpeed(9.0f); = Fahrzeug speed 9.0 is gleich an 90 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ WLF.SetMaxPassengers(2); WLF.SetSpeed(8.0f); int PlayerID = v.GetPlayerMP(); WLF.SetPlayerMP(PlayerID); PersonList passengers = v.GetPassengers(); for(int i = 0; i < passengers.GetNumPersons(); i++) {v.RemovePassenger(&passengers.GetPerson(i));WLF.AddPassenger(&passengers.GetPerson(i)); } PersonList transports = c.GetTransports(); for(int i = 0; i < transports.GetNumPersons(); i++) { c.RemoveTransport(&transports.GetPerson(i)); WLF.AddTransport(&transports.GetPerson(i)); } v.PushActionWait(ACTION_APPEND, 0.1f); v.PushActionDeleteOwner(ACTION_NEWLIST); c.PushActionDeleteOwner(ACTION_NEWLIST);} }; Mission::PlayHint(AlarmMessage); if(GameSoundID == 1) { Audio::PlaySample(AlarmSound); } Vector TargetPos=Game::GetCommandPos(); Game::FindFreePosition(&v, TargetPos, 90); }; Quote Link to comment Share on other sites More sharing options...
RedHawk504 Posted July 27, 2014 Author Report Share Posted July 27, 2014 @Hoppah Weet jij iets?? Of hoe ik het anders kan doen zodat dit script een geluid afspeelt bij het aanklikken ervan? Quote Link to comment Share on other sites More sharing options...
RedHawk504 Posted August 2, 2014 Author Report Share Posted August 2, 2014 BumpAnyone??? Quote Link to comment Share on other sites More sharing options...
Chris07 Posted August 2, 2014 Report Share Posted August 2, 2014 Audio::PlaySample(); plays a sound once. To make it loop you need to use PlaySample3D().PlaySample3D(AlarmSound, Vector Target, true);Replace "Vector Target" with a vector object of the location you want the sound to come out of...If you want the sound to follow the vehicle, I would assume it would be best to use "pos". Quote Link to comment Share on other sites More sharing options...
RedHawk504 Posted August 4, 2014 Author Report Share Posted August 4, 2014 Can you insert it into my scripts so i can see what i did wrong?Doesn't it also need an reference to the specific sound i want to let play? Quote Link to comment Share on other sites More sharing options...