JASS Question

Strilanc

Veteran Scripter
Reaction score
42
If you only create an effect for one player it will desync. However, if you create SOME effect for every player, then it should be fine. For example:
JASS:

if GetLocalPlayer() == p then
  //create effect above target unit
else
  //create effect above a fake unit in some corner no one can see
endif
 

quraji

zap
Reaction score
144
If you only create an effect for one player it will desync. However, if you create SOME effect for every player, then it should be fine. For example:
JASS:

if GetLocalPlayer() == p then
  //create effect above target unit
else
  //create effect above a fake unit in some corner no one can see
endif

Or:

JASS:
function AddSpecialEffectForPlayer takes player p, string path, real x, real y returns effect
    if GetLocalPlayer() == p then
        return AddSpecialEffect(path, x, y)
    else
        return AddSpecialEffect("", 0., 0.)
    endif
endfunction
 

Romek

Super Moderator
Reaction score
963
You could create a special effect only for certain players and destroy the ones you don't want.

JASS:
function AddSpecialEffectTargetForPlayer takes string path, unit whichUnit, string Apoin, player whichPlayer returns effect
    local string s = ""
    if GetLocalPlayer() == whichPlayer then
        set s = path
    endif
    call AddSpecialEffectTarget(s, whichUnit, Apoint)
endif


I'm not 100% sure that works.

That works fine. And much better than the next one:

If you only create an effect for one player it will desync. However, if you create SOME effect for every player, then it should be fine. For example:
JASS:

if GetLocalPlayer() == p then
  //create effect above target unit
else
  //create effect above a fake unit in some corner no one can see
endif

Not sure if this would work. The first one does anyway, so it'd be better to use :)

You can't really test these things on your own because you can't be 2 players at the same time. Ask a friend or something :p

It probably works anyway.
 

Romek

Super Moderator
Reaction score
963
can you make the first 1 gui?

http://www.thehelper.net/forums/showpost.php?p=810222&postcount=10

Well no, it doesn't. It won't compile because it doesn't return ;)

Oh.. Yeah.. I knew that :)

JASS:
function AddSpecialEffectTargetForPlayer takes string path, unit whichUnit, string Apoin, player whichPlayer returns effect
    local string s = ""
    if GetLocalPlayer() == whichPlayer then
        set s = path
    endif
    return AddSpecialEffectTarget(s, whichUnit, Apoint)
endif


It leaks though.
 

quraji

zap
Reaction score
144
JASS:
function AddSpecialEffectTargetForPlayer takes string path, unit whichUnit, string Apoin, player whichPlayer returns effect
    local string s = ""
    if GetLocalPlayer() == whichPlayer then
        set s = path
    endif
    return AddSpecialEffectTarget(s, whichUnit, Apoint)
endif


It leaks though.

As long as it's destroyed in the calling function it won't.

JASS:
function b takes nothing returns nothing
    local effect e = AddSpecialEffectTargetForPlayer(...)
    //do stuff
    set e = null  //  leaks an effect, since it wasn't destroyed
endfunction 

function a takes nothing returns nothing
    local effect e = AddSpecialEffectTargetForPlayer(...)
    //do stuff
    call DestroyEffect(e)  //  destroy the effect
    set e = null  //  null the variable
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top