[JASS] Desync with TextTags and Strings

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
Alright I once learned you could set a string to a variable in GetLocalPlayer() blocks and it wouldn't desync. I would swear that once a long time ago this worked. Now, it doesn't.

Example:

JASS:
    if IsPlayerInForce(GetLocalPlayer(), udg_Force[2]) then
        set str = "Units"
    endif
    call CreateTextTagLocBJ( str, GetUnitLoc(GUI_Units), 0, 17.00, 100, 100, 100, 0 )

Desyncs. Can this be fixed?

EDIT: Changed code to -

JASS:
    local string str = ""

    set str = "Units"
    if not IsPlayerInForce(GetLocalPlayer(), udg_Force[2]) then
        set str = ""
    endif
    call CreateTextTagLocBJ( str, GetUnitLoc(GUI_Units), 0, 17.00, 100, 100, 100, 0 )
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
1,084
Try this:
JASS:
local string str = "Units"
if not IsPlayerInForce(GetLocalPlayer,udg_Force[2] then
    set str = "" // Or whatever text you want to display for players that aren't in that force. 
endif
call CreateTextTagLocBJ( str, GetUnitLoc(GUI_Units), 0, 17.00, 100, 100, 100, 0 ) // Remember to clear location leaks!
Alternatively you could use SetTextTagVisibility or create the texttag in the local block if you don't want to show it to players outside of udg_Force[2]

Useful tutorial. (Scroll to creating special effects for player)

Edit: You figured it out while I was slowly typing this post, but I think you should do it the way I offered.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Hmm unfortunately SetTextTagVisibility didn't work:

JASS:
    set str = "Units"
    call CreateTextTagLocBJ( str, GetUnitLoc(GUI_Units), 0, 17.00, 100, 100, 100, 0 )
    call SetUnitVertexColorBJ( GUI_Units, 100, 100, 100, 100.00 )
    if not IsPlayerInForce(GetLocalPlayer(), udg_Force[2]) then
        call SetTextTagVisibility(bj_lastCreatedTextTag, false)
    endif
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
That's odd since it does work for me.
My Test:
JASS:
    local texttag t = CreateTextTag()
    call SetTextTagText(t,"YO!",0.287)
    call SetTextTagColor(t,100,100,100,255)
    call SetTextTagPos(t,0,0,0)
    if GetLocalPlayer() == Player(0) then
        call SetTextTagVisibility(t,false)
    endif
    set t = null
Were you testing with a player outside of udg_Force[2]?

Anyway, I think it's better to create the texttag inside the local block which should have been the only method I mentioned.
 
IsPlayerInForce(GetLocalPlayer(), udg_Force[2]

This desyncs. You can not check whether a player is in a force for the current player.

You should use this:
JASS:
local integer i = 0;

loop
    exitwhen i >= 12 
    if IsPlayerInForce(Player(i), udg_Force[2]) then
        If GetLocalPlayer() == Player(i) then
            set str = "Units"
        endif
    endif
    set i = i +1;
endloop
 
Status
Not open for further replies.
Top