| 03-03-2007, 08:48 PM | #1 |
Is it possible to play a sound via triggers for only certain players and not for all to hear? for instance.. one trigger i have plays the error.wav when something doesn't work but everyone hears it in my 10 player game. also, i use float text a lot. how do you get it to only show float text to certain players? I play dota time to time and i saw this being done there with creep denies. |
| 03-03-2007, 09:15 PM | #2 |
Using two lines of custom script: Trigger: ![]() Set TempPlayer = Player 1 (Red)
![]() Custom Script: if GetLocalPlayer=udg_TempPlayer
![]() -------- Your actions go here --------
![]() Custom Script: endif |
| 03-03-2007, 09:54 PM | #3 |
Floating text already has a GUI function for displaying it for certain players only... |
| 03-03-2007, 11:11 PM | #4 |
Yeah, doesn't that cause Desyncs? |
| 03-03-2007, 11:50 PM | #5 |
well i've looked numerous times (including just now) for changing float text to display to certain players and i dont see it. unless it can only be done in certain editors. i use standard world edit that came with game. |
| 03-04-2007, 12:04 AM | #6 |
Example: Floating Text - Show (Last created floating text) for (All players)and no I don't believe it causes Desyncs, let me check though. Edit: I doesn't seem to... |
| 03-04-2007, 12:33 AM | #7 |
No I was saying that using GetLocalPlayer() causes desyncs. But floating text doesn't use it so it's fine. |
| 03-04-2007, 12:59 AM | #8 |
GetLocalPlayer() only causes desyncs when it is used to change the game-state for only 1 person (exmaple: kill a unit, remove a destructible, give player gold, etc.) If you use it for visual or interface purposes, it's normally fine. I usually wait till the last possible time to use GetLocalPlayer(). For example, to make a multiboard for 1 player, I create the multiboard, set all the values for all the players, and then use GetLocalPlayer() to display it. All players have a multiboard in memory, but only 1 player can see it. |
| 03-04-2007, 03:18 AM | #9 | |
Quote:
AHHH. i dont know why i didn't notice that. i kept thinking that was just like how you hide units.. .. i kept looking for something that was like the way other types of texts were handled. |
| 03-04-2007, 03:24 AM | #10 | |
Quote:
does that work with ftext only or sound too? now that ammorth showed me what i could do with ftext..(thx) i have a few sounds that are annoying when you aren't the player owning the unit and have to hear it. |
| 03-04-2007, 05:07 AM | #11 |
yes it works, you can also use this method (both work the same) Make a new player variable called LocalPlayer and then make a trigger like this: Trigger: then you can use your variable LocalPlayer to play sounds for a certain player. Ex, plays the sound for player 1 (red) Trigger: And thats it! |
| 03-04-2007, 05:19 AM | #12 |
1. does it have to be named that exactly in order to work? 2. since this is a 10 player map i can array that right? i find that weird how when the localplayer = player # and play the sound that it knows who to play for when the sound event doesn't actually let you point it to anything. never did anything like that before. |
| 03-04-2007, 08:45 AM | #13 | ||||||||||||
It works because GetLocalPlayer() loops through all players, and does the actions in the "if" for only the ones that match the desired player(s). EDIT: So, it would go though a check like this: Table:
|
| 03-04-2007, 11:20 PM | #14 |
Actually, GetLocalPlayer() returns a player, but instead of returning the same value for all the players, the function returns the local player. Example: You are in a game with some friends. You are player 1 and your friends are player 2 and player 4. Now, the map calls GetLocalPlayer() and assigns it to a variable. Your computer runs it, and returns Player 1 (yourself) while your other friend's computers run it and return themselves. Now, this variable has a different value for every player. If the map were to use it in a condition check (example: LocalPlayer is equal to Player 1 (red)) each computer runs the check. Since the values of LocalPlayer are different, the check will only pass for certain players which have the proper value, in this case Red. @ 1) No, but the custom script needs to have "udg_<variableName>" for it to work. @ 2) No, an array is useless. Function returns differently for each player, as stated above. |
| 03-04-2007, 11:54 PM | #15 |
Well then, Ammorth, I am greatly mistaken. Thanks for clarifying. |
