| 12-07-2007, 02:38 PM | #1 |
JASS:function omg takes real x, real y returns nothing local integer n = 0 set bj_lastCreatedTextTag = CreateTextTag() loop if GetLocalPlayer()==Player(n) then call SetTextTagText(bj_lastCreatedTextTag,GetPlayerName(Player(n)),0) endif set n=n+1 exitwhen n>11 endloop call SetTextTagPos(bj_lastCreatedTextTag,x,y,0) endfunction will this cause desync? because someone said that changing the text in the texttag locally will not cause desync, well just to confirm. |
| 12-07-2007, 03:13 PM | #2 |
No, I don't think so since you can show a texttag locally to a player like so: call SetTextTagVisibility(TextTag,GetLocalPlayer == YourPlayer) |
| 12-07-2007, 03:19 PM | #3 |
well i wish to do with the fuction above because i don't want to create an array of texttag and showing them one by one... so instead, changing the text of the texttag locally only requires one texttag and it shows all the things i need |
| 12-07-2007, 03:44 PM | #4 |
My suggestion to ensure that this won't desync is not using blizzard.j variables, instead, use a local one: JASS:function omg takes real x, real y returns nothing local integer n = 0 local texttag t = CreateTextTag() loop if GetLocalPlayer()==Player(n) then call SetTextTagText(t,GetPlayerName(Player(n)),0) set n=n+1 exitwhen n>11 endif endloop call SetTextTagPos(t,x,y,0) set t = null endfunction |
| 12-07-2007, 03:47 PM | #5 |
It will desync, and not work properly, look at your loop... If GetLocalPlayer() == Player(n) then set n = n+1 exitwhen n>11... that will ONLY be true once, and for player 0 it will set n = n + 1 and loop forever because it'll never check the n>11 condition. Best bet is to create the text tag and check if local player is player(n) then set visibility to true. |
| 12-07-2007, 04:11 PM | #6 | |
Quote:
there fixed, basically the function displace the players' name with ONE texttag... |
| 12-07-2007, 10:38 PM | #7 |
imho you can DO ANYTHING WITH TT'S localy cause texttag is a "local type" yeah i think it's 100% so =) you can use globals for them etc. (TT's are not saved by saving the game so don't operate with TT's after loading a saved game cause otherwise == crush (or maybe not =)) |
| 12-07-2007, 11:02 PM | #8 |
I think it works, but I would do it this way: JASS:function omg takes real x, real y returns nothing local integer n = 0 local string s set bj_lastCreatedTextTag = CreateTextTag() loop set s=GetPlayerName(Player(n)) if GetLocalPlayer()==Player(n) then call SetTextTagText(bj_lastCreatedTextTag,s,0) endif set n=n+1 exitwhen n>11 endloop call SetTextTagPos(bj_lastCreatedTextTag,x,y,0) endfunction It is not likely at all that this function would be the first time you generate an string for player names, it is totally improbable that creating a local string object would cause issues, but I guess it is a risk that's not necessary so let's just avoid it... |
| 12-08-2007, 03:20 AM | #9 |
I see, thanks guys :) -- Another question: Then how about the multiboard? Can I change the string value in the multiboard locally? The example will be similiar with above, just dealing with multiboard now... |
| 12-08-2007, 03:41 AM | #10 |
If I'm not mistaken, you can also make multiboards locally for each player. But I think changing a string value may desync. |
| 12-08-2007, 09:46 AM | #11 |
the more safety way is to create the "object" and display it only for the local player, no ? |
| 12-08-2007, 10:51 PM | #12 | |
Quote:
i mean if GetLocacPlayer()==Player(x) then call MultiboardSetItemVal(i,i2,"my local val") // this will desync endif local string val="def val" if GetLocacPlayer()==Player(x) then set val="my local val" endif call MultiboardSetItemVal(i,i2,val) // this will work properly see ;) + i think this also may work with some other interesting functions. maybe also you can set unit position localy =) (i havent checked it using local vals) well it's the best solution use local values and not to call function localy ;) |
