GetLocalPlayer() ??

elmstfreddie

The Finglonger
Reaction score
203
Say you do kill a unit for only player 1, would that cause him to quit from the game, or would everyone go? Because you could make a fancy kick with that.
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
When killing the unit for a certain player, that is weird and barely makes sense to use, but I think it will desync and kickout all players except the player that sees the unit killed. But don't blame me if I'm wrong. :eek:

EDIT: I found a thread about LocalPlayer(), click here...

PurplePoot said:
Diablo, funnily enough, that causes a desynch when the unit dies, not when it's created, if it has the same damage, life, etc (though the model, name, and scale can change)

(and the owner of the killer/dier won't get desynched)
 

Sim

Forum Administrator
Staff member
Reaction score
534
Blizzard explains it efficiently in the blizzard.j

JASS:
if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.


Problem is, they don't only use local code in the whole function >_<

JASS:
function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing
    local real dist
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.

        set dist = DistanceBetweenPoints(loc, GetCameraTargetPositionLoc())
        if (dist &gt;= bj_SMARTPAN_TRESHOLD_SNAP) then
            // If the user is too far away, snap the camera.
            call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0)
        elseif (dist &gt;= bj_SMARTPAN_TRESHOLD_PAN) then
            // If the user is moderately close, pan the camera.
            call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
        else
            // User is close enough, so don&#039;t touch the camera.
        endif
    endif
endfunction


That is "Pan camera as necessary" in GUI. As you guys may know, it causes desyncs. Notice the global variables.
 

SFilip

Gone but not forgotten
Reaction score
634
To the original question...
Every trigger, when executed, runs separately on every human player's PC.
The player who's PC is currently running the trigger is GetLocalPlayer.
As already stated this can be (ab)used in order to get something to happen for one player only.
 

Sim

Forum Administrator
Staff member
Reaction score
534
You don't use the "as necessary" version.

Use "Pan camera for player".
 

PurgeandFire

zxcvmkgdfg
Reaction score
508

Sim

Forum Administrator
Staff member
Reaction score
534
Which can be considered a global "object" (aka outside from this trigger since it is created).

You're right though, it isn't a global variable!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top