• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help with a function

Status
Not open for further replies.
Level 3
Joined
Nov 3, 2017
Messages
34
Prompt how correctly to use function
JASS:
SelectUnitForPlayerSingle
This I need to ensure that, after the casting of the spell, the unit was selected by the owner in a trigger. Will this cause desynchronization in the game over the network and the Internet?
just there is
JASS:
GetLocalPlayer()
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
JASS:
function SelectUnitForPlayerSingle takes unit whichUnit, player whichPlayer returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call ClearSelection()
        call SelectUnit(whichUnit, true)
    endif
endfunction

No this will not desync.

It seems strange that the owner of the unit casting the spell would not be selected on the unit when the spell is cast...

However, to use this catch when the spell is cast then call this function and pass whichever unit/player you need to have selected.
 
Level 3
Joined
Nov 3, 2017
Messages
34
No this will not desync.

It seems strange that the owner of the unit casting the spell would not be selected on the unit when the spell is cast...

However, to use this catch when the spell is cast then call this function and pass whichever unit/player you need to have selected.

You did not understand me correctly. My fault, I did the wrong thing. During casting spells, the hero is removed from the selection
JASS:
call SelectUnit(GetTriggerUnit(), false)
and how the cast is ended, but only for the hero's owner
JASS:
call SelectUnitForPlayerSingle(GetTriggerUnit(), GetOwningPlayer(GetTriggerUnit()))
That's why I asked if it would cause desynchronization in a network game. thank you very much friend
 
Level 18
Joined
Jun 13, 2016
Messages
586
You did not understand me correctly. My fault, I did the wrong thing. During casting spells, the hero is removed from the selection
JASS:
call SelectUnit(GetTriggerUnit(), false)
and how the cast is ended, but only for the hero's owner
JASS:
call SelectUnitForPlayerSingle(GetTriggerUnit(), GetOwningPlayer(GetTriggerUnit()))
That's why I asked if it would cause desynchronization in a network game. thank you very much friend

Selection events will never cause a desync, since SelectUnit() is meant to be called in a local player clause to make it work for one player. You should be safe in this case.
 
Status
Not open for further replies.
Top