HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with texttag function

05-13-2007, 04:52 PM#1
grupoapunte
Hey well this is my function, it displays the bonuty (iReward) over the killed unit (uDead) to the killing player (pKiller) the problem is that the tag is showing to every player in the game, what am i doing wrong?

Collapse JASS:
function ReviveHero_KillBounty takes unit uDead, integer iReward, player pKiller returns nothing
    local texttag tt
    local location l = GetUnitLoc(uDead)
    local force f = CreateForce()
    
    if (GetPlayerController(pKiller) == MAP_CONTROL_USER) then
        call ForceClear(f)
        call ForceAddPlayer(f, pKiller)
        set tt = CreateTextTagLocBJ("+" + I2S(iReward), l, GetUnitFlyHeight(uDead), 10.00, 99.61, 82.75, 7.06, 0.00)
        call ShowTextTagForceBJ(true, tt, f)
        call SetTextTagVelocityBJ(tt, 55.00, 90.00)
        call SetTextTagFadepoint(tt, 2.00)
        call SetTextTagLifespan(tt, 3.00)
        call SetTextTagPermanent(tt, false)
    endif
    
    call AdjustPlayerStateSimpleBJ(pKiller, PLAYER_STATE_RESOURCE_GOLD, R2I((GetUnitPointValue(uDead) * 0.10) * 0.50))
    
    call RemoveLocation(l)
    call DestroyForce(f)
    set l = null
    set tt = null
    set f = null
endfunction

thanks

ps: i checked the parameters they are ok, it has to be something with the function.
05-13-2007, 05:09 PM#2
MindWorX
(GetPlayerController(pKiller) == MAP_CONTROL_USER)
should be:
(GetLocalPlayer() == pKiller)
05-13-2007, 06:07 PM#3
Ammorth
No, don't do that cause then you will be creating the texttag locally == desyncs. Instead, try this:

Collapse JASS:
function ReviveHero_KillBounty takes unit uDead, integer iReward, player pKiller returns nothing
    local texttag tt
    local location l = GetUnitLoc(uDead)    
    if (GetPlayerController(pKiller) == MAP_CONTROL_USER) then
        set tt = CreateTextTagLocBJ("+" + I2S(iReward), l, GetUnitFlyHeight(uDead), 10.00, 99.61, 82.75, 7.06, 0.00)
        if GetLocalPlayer() == pKiller then
            call SetTextTagVisibility(tt, true)
        else
            call SetTextTagVisibility(tt, false)
        endif
        call SetTextTagVelocityBJ(tt, 55.00, 90.00)
        call SetTextTagFadepoint(tt, 2.00)
        call SetTextTagLifespan(tt, 3.00)
        call SetTextTagPermanent(tt, false)
    endif
    
    call AdjustPlayerStateSimpleBJ(pKiller, PLAYER_STATE_RESOURCE_GOLD, R2I((GetUnitPointValue(uDead) * 0.10) * 0.50))
    
    call RemoveLocation(l)
    set l = null
    set tt = null
endfunction