You've got to look at it like this:
GetLocalPlayer() calls your computer.
So if you say "if GetLocalPlayer() == Player(0)", it is actually checking whether the computer you're playing on is playing with Red.
If you create a unit like that, it will only create the unit for that player (other players simple 'don't exist' within that function).
That means the unit will only be created on 1 game, the other games don't even know that unit exists.
E.g.: if you say "All Players" within that function, it will still only call 1 player (because, as said before, other players simply don't exist).
No, it will not crash: it will desync.
The player for whom you created the unit will not be playing the same game as the others anymore.
Never, ever do anything like that. It's dangerous.
What he said. GetLocalPlayer() is useful for things like floating text and screen masks that don't return handles. I.E. if you only wanted floating text to be seen by 1 person.
function whatever takes nothing returns nothing
local integer q=0
if GetLocalPlayer()==Player(0) then
set q='h001'
endif
call CreateUnit(q, nevermindotherparameters)
endfunction
don't return handles, gotcha, thx for help
anyway, does this legal?
JASS:function whatever takes nothing returns nothing local integer q=0 if GetLocalPlayer()==Player(0) then set q='h001' endif call CreateUnit(q, nevermindotherparameters) endfunction
function showUnitForPlayer takes unit u, player p returns nothing
if GetLocalPlayer() != p then
call SetUnitScale(u,0.01,0.01,0.01)
endif
endfunction
call ShowUnit(Unit, false)
if GetLocalPlayer() == Player(...) then
call ShowUnit(Unit, true)
endif
Okay, thanks. I wasn't quite sure: as far as I knew it didn't create any local handles, but I'm not that familiar with when GetLocalPlayer desyncs.Hidding/showing units locally causes desyncs I heard.