• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Quick help with this? playing sound for only 1 unit (advanced)

Status
Not open for further replies.
Level 5
Joined
Feb 1, 2009
Messages
111
I have a unit-array variable CreatedPlayerHero[]

And I want the custom script I need to issue a sound effect when an action happens to one unit, im using:

  • Custom script: if GetLocalPlayer() == udg_CreatedPlayerHero[GetConvertedPlayerId(GetTriggerPlayer())] then
  • Sound - Play upgrade_fail <gen>
But no sound is played. Any idea?
 
Last edited:
Well, you can't play a sound for one unit. You can play it for a player, but not a unit. Maybe you mean to play a 3D sound? (Sound - Play sound on Unit)

Anyway, the general structure would be:
  • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
  • Sound - Play upgraded <gen>
  • Custom script: endif
That would be to play the sound globally for the triggering player only (you can hear it regardless of where your camera is). To play it around the unit, you would use:
  • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
  • Sound - Play upgraded <gen> at 100.00% volume, attached to (SomeUnit)
  • Custom script: endif
But keep in mind that if you have a custom sound, it might not necessarily work as a 3D sound. They need certain properties. You should try playing the sound in a blank map as a 3D sound to see whether it plays properly in the first place.
 
Level 5
Joined
Feb 1, 2009
Messages
111
This is the exact code im using:

  • Custom script: if GetLocalPlayer() == udg_CreatedPlayerHero[GetConvertedPlayerId(GetTriggerPlayer())] then
  • Sound - Play upgraded <gen>
  • Custom script: endif
Jasshelper is enabled

Im just trying to convert the GUI: CreatedPlayerHero[Player number of[Triggering player]] to custom script since that's whats needed to call the sound for 1 player in-game and no one else to hear it !
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
tried this and it worked.
  • Melee Initialization
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == Player(0) then
      • Game - Display to (All players) the text: asd
      • Sound - Play FootmanWhat2 <gen> at 100.00% volume, attached to Paladin 0001 <gen>
      • Custom script: endif
 
Status
Not open for further replies.
Top