• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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
 

~El

Level 17
Joined
Jun 13, 2016
Messages
556
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