The problem is if the unit is invisible, or if its behind a tree.You can find out where all the players are looking and find out how far they are from the casting unit. Then use the GetLocalPlayer() function to show the texttag to all the players that are looking within a certain range from the casting unit.
To prevent OOS occuring, I would recommend creating the text tag for all players and only hiding / revealing it to those who apply. Although it sounds tempting to not create the tag at all for people who are not meant to see it, it will probably result in an OOS as handle numbers will no longer match. Thus you will still have to atleast create the object for all players, you do not however have to perform any other actions on it the tag unless the player needs it.
WTF is an OOS? And texttags aren't really handles, just create them locally.
OOS is besically when some is kicked from the game or the game splits. The data in the game is no longer syncronized between people so it splits to allow play to continue.
Thinking of it now, it probably is safe to make them locally as at the time I forgot they used their own handle index range (thus the cap of 100 of them at once).
Anything that affects anything to do with gameplay and not graphics will result in an OOS, eg a unit being killed or the random number generator altered. Thus it is recommended to test your maps for OOS (splits) if you do use get local player jsut to be sure.
if (player X) == GetLocalPlayer() then
// do local stuff here
endif
JASS:if (player X) == GetLocalPlayer() then // do local stuff here endif
Player X being whichever player the code should run locally for. Rules of thumb about local code:
- Try to keep handles in sync (however, some handles do not need to be in sync like floating text), or else you'll desync the game.
- In general, use GetLocalPlayer() for doing stuff with display, but not with directly gameplay-affecting things like creating an unit.
- There are some dirty tricks you can use with this, though, like with special effects. See JASS: GetLocalPlayer()
In short, things like DisplayMultiboard(), showing images, text, and whatsnot... if there's an on/off switch for it, chances are it's safe for GetLocalPlayer(). Oh yeah, and NEVER use sleep locally. I think I saw someone on these boards trying that... yeah, that wasn't smart.