[vJASS] GetLocalPlayer() in floating text

Status
Not open for further replies.
Guys, is it save if I want to show floating text just for one player
JASS:
  if (GetLocalPlayer() == pla) then
                call SetTextTagVisibility(bj_lastCreatedTextTag, true)
            else
                call SetTextTagVisibility(bj_lastCreatedTextTag, false)
            endif
insted of creating forces and using this bj:
JASS:
function ShowTextTagForceBJ takes boolean show, texttag tt, force whichForce returns nothing
    if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call SetTextTagVisibility(tt, show)
    endif
endfunction

I have no expirience with GetLocalPlayer()
 
Level 19
Joined
Dec 12, 2010
Messages
2,070
JASS:
call SetTextTagVisibility(tt, GetLocalPlayer() == pla)
or better create tags competely at local PC if he supposed to see it.
JASS:
function TextTagOnUnitVis takes string s,real dur,unit u,real height,integer r,integer g,integer b,integer a, boolean visible returns nothing	
	local texttag tt
	if visible then
		set tt=CreateTextTag()
		call SetTextTagText(tt,s,height)
		call SetTextTagPosUnit(tt,u,64)
		call SetTextTagColor(tt,r,g,b,a)
		call SetTextTagVelocity(tt,0,0.0355)
		call SetTextTagFadepoint(tt,2)
		call SetTextTagPermanent(tt,false)
		call SetTextTagLifespan(tt,dur)
		call SetTextTagVisibility(tt,true)
		set tt=null
	endif
endfunction
 
Level 19
Joined
Dec 12, 2010
Messages
2,070
Creating tags locally messes up the handle ids.
I know that tags are an exception but it is better to just do the visualization local.

in case if there's many tt around you wouldn't like to exceed retarded limit of 100 instances per PC. so creating them locally just fine. and you won't need their handles anyway, every play may have different handles, it won't change a thing
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
well I definitely had an issue regarding tt didn't spawn in rare cases when there's too many of them on the screen

I'm totally aware about this limit for texttags.
I didn't say there was not the 100 limit, i just said that's not the case with lightnings and images, that's all.
But you can still create them in a local block, simply because they have their own handle id stack.
 
Creating tags locally messes up the handle ids.
I know that tags are an exception but it is better to just do the visualization local.
Not neccesary for texttags. It's 100% safe to create them locally, since their handle stack works different than other handles.

However, one exception: as soon as you store data to the handle ID of a texttag, you might create asynchronous data with that, obviously.
But I wouldn't do that anyway, since the 100 tag limit kinda prevents you from reliably attaching data to tags.
 
Status
Not open for further replies.
Top