• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Play Sound for only 1 player

Status
Not open for further replies.
Level 2
Joined
Jan 25, 2011
Messages
25
Hey Guys

My problem is i want to play a sound only for 1 player. But with normal tiggers it didnt work:goblin_cry:.

Thank you for Reading
 
Level 2
Joined
Jan 25, 2011
Messages
25
Thank you for answer

A unit attack a other unit. The sound have to played for the owner of the attacking unit.
 
Level 2
Joined
Jan 25, 2011
Messages
25
Sorry i didnt work :vw_sad:.

  • Stop Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal Unit 1
      • (unit-type of (Attacking unit)) Unequal Unit 2
      • (unit-type of (Attacking unit)) Unequal Unit 3
      • (unit-type of (Attacking unit)) Unequal Unit 4
      • (unit-type of (Attacking unit)) Unequal Unit 5
    • Actions
      • Unit - Order (Attacking unit) to Stop
      • Custom script: if GetLocalPlayer() != GetOwningPlayer(GetAttacker() then
      • Sound - play (my sound)
      • Custom script: endif
This is my Tigger.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,204
GetLocalPlayer() returns an asyncrnious value.
WC3 is syncrnious, so what is calculated for 1 human playing the map should also be calculated for other humans playing the map.
An asyncrnious value is when the value is different between atleast 2 players in an instance of the game.

GetLocalPlayer()
Returns an asyncrnious player object representing who the owner of the game client is playing.
Only active human players have a game client so can be returned by it.
Player object returned is constant and unique for each game client.
Impossible to get null returned or values in the range of Player(12 to 15) (neutral players).

Using this unique behaviour combined with flow control structures you can run code locally for only specific players. This is great for HCI or graphics which do not affect gameplay but improve the interaction of players with the map. This should never be used to run anything that alters gameplay as it will cause an immediate game split.

Examples
good - Using it to play a sound only for a single player. The sound will only play for certain players.
bad - Using it as the desired owner of a unit. Multiplayer games will instantly disolve (everyone gets dropped from each other).
 
Status
Not open for further replies.
Top