• 🏆 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!

[Lua] Does this desync?

Level 6
Joined
Mar 27, 2019
Messages
51
Hi there,

I'm trying to implement my UI while also fiddling with GetLocalPlayer(), I wonder if this method of doing it causes any desync.

Lua:
function AutoSendToggleFunc()
    
    -- Set Local Variables
    local p
    local i
    local s
    local backdrop = BackdropLocalPlayerDisplay
    
    
    -- Show Frame
    BlzFrameSetEnable(AutoSendToggle, false)
    BlzFrameSetEnable(AutoSendToggle, true)
    
    -- Get Player
    p = GetTriggerPlayer()
    
    -- Get Player ID
    i = GetConvertedPlayerId(p)
    
    
    -- Check for Boolean
    if udg_Send_Toggle[i] == false then
        
        -- Set True
        udg_Send_Toggle[i] = true
        
        if GetLocalPlayer() == p then
            
            backdrop = BackdropAutoSendToggle
            
        end
        
        s = "Custom\\BTNActivated.tga"
        BlzFrameSetTexture(backdrop, s, 0, true)
        
    else
        
        -- Set False
        udg_Send_Toggle[i] = false
        
        if GetLocalPlayer() == p then
            
            backdrop = BackdropAutoSendToggle
            
        end
        
        s = "Custom\\BTNDeactivated.tga"
        BlzFrameSetTexture(backdrop, s, 0, true)
        
        
    end
    
end

  • Player l Menu Command
    • Events
    • Conditions
    • Actions
      • Set VariableSet Temp_Player = (Triggering player)
      • Set VariableSet Temp_Integer = (Player number of Temp_Player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Menu for Player_Builder[Temp_Integer]) Equal to 1
        • Then - Actions
          • Unit - Set level of Menu for Player_Builder[Temp_Integer] to 2
          • Unit - For Unit Player_Builder[Temp_Integer], start cooldown of ability Menu " over "1.00 seconds.
          • Custom script: local backdrop_skin = BackdropLocalPlayerDisplay
          • Custom script: local backdrop_title = BackdropLocalPlayerDisplay
          • Custom script: if GetLocalPlayer() == udg_Temp_Player then
          • Custom script: backdrop_skin = BackdropSkinHUD
          • Custom script: backdrop_title = BackdropTitleDisplay
          • Custom script: end
          • Custom script: BlzFrameSetVisible( backdrop_skin, true )
          • Custom script: BlzFrameSetVisible( backdrop_title, true )
        • Else - Actions
          • Unit - Set level of Menu for Player_Builder[Temp_Integer] to 1
          • Unit - For Unit Player_Builder[Temp_Integer], start cooldown of ability Menu " over "1.00 seconds.
          • Custom script: local backdrop_skin = BackdropLocalPlayerDisplay
          • Custom script: local backdrop_title = BackdropLocalPlayerDisplay
          • Custom script: if GetLocalPlayer() == udg_Temp_Player then
          • Custom script: backdrop_skin = BackdropSkinHUD
          • Custom script: backdrop_title = BackdropTitleDisplay
          • Custom script: end
          • Custom script: BlzFrameSetVisible( backdrop_skin, false )
          • Custom script: BlzFrameSetVisible( backdrop_title, false )

Is it unnecessary to do it like that, can I just use "BlzFrameSetTexture(backdrop, s, 0, true)" in the GetLocalPlayer() block?

How do I test if any desyncs happen? As someone that doesn't have access to playtesters, it hurts to see that my map desynced in a full lobby, leaving everyone disappointed/wasting their time.
Any help would be greatly appreciated, I'm trying to release my map but the desyncs are holding it back. I dont know if its the Custom UI or the Save/Load System.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
How do I test if any desyncs happen? As someone that doesn't have access to playtesters, it hurts to see that my map desynced in a full lobby, leaving everyone disappointed/wasting their time.
Any help would be greatly appreciated, I'm trying to release my map but the desyncs are holding it back. I dont know if its the Custom UI or the Save/Load System.
That looks like the correct way of handling it. To use GetLocalPlayer() properly the general rule of thumb is:

Always call functions for everyone - but modify the function's variables locally - like you're doing.

This way the same game logic happens for everyone, but with slightly different results for some.

To test it, you can launch any number of clients through the BNET app and play LAN with yourself. Just make sure that after launching the second client you immediately return to the first client and click "Play Offline" - it may take a moment to appear. I think if you wait too long then it will cause problems and you'll have to exit out and try again.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
Honestly, I see this unnecessary complicated I always use these functions inside of a if p == GetLocalPlayer() then block without issues:
vJASS:
native BlzFrameSetPoint takes framehandle frame, framepointtype point, framehandle relative, framepointtype relativePoint, real x, real y returns nothing
native BlzFrameClick takes framehandle frame returns nothing
native BlzFrameSetText takes framehandle frame, string text returns nothing
native BlzFrameSetFocus takes framehandle frame, boolean flag returns nothing
native BlzFrameSetEnable takes framehandle frame, boolean enabled returns nothing
native BlzFrameSetTexture takes framehandle frame, string texFile, integer flag, boolean blend returns nothing
native BlzFrameSetScale takes framehandle frame, real scale returns nothing
native BlzFrameCageMouse takes framehandle frame, boolean enable returns nothing
native BlzFrameSetValue takes framehandle frame, real value returns nothing
native BlzFrameSetSize takes framehandle frame, real width, real height returns nothing
I never needed setting variables and calling them for all players, because these functions only affect visual stuff and not the outcome of the game.
 
Last edited:
Always call functions for everyone - but modify the function's variables locally - like you're doing.

This way the same game logic happens for everyone, but with slightly different results for some.
Is this different in Lua? In JASS, calling BlzFrameSetTexture and similar functions locally is not a problem at all.

To test it, you can launch any number of clients through the BNET app and play LAN with yourself. Just make sure that after launching the second client you immediately return to the first client and click "Play Offline" - it may take a moment to appear. I think if you wait too long then it will cause problems and you'll have to exit out and try again.
You can also click in the bottom-right on the first client and log out before you start a second client. That should make it much easier.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Is this different in Lua? In JASS, calling BlzFrameSetTexture and similar functions locally is not a problem at all.


You can also click in the bottom-right on the first client and log out before you start a second client. That should make it much easier.
No, it's not different, what I said was just a rule of thumb. Some functions will work fine, it all depends on what's going on under the hood. I still run into seemingly random desyncs even after applying the best practices so I try to do things as safe as possible, even if it's "unnecessary". Pretty sure this game is just busted - not like the new patches ever help.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
No, it's not different, what I said was just a rule of thumb. Some functions will work fine, it all depends on what's going on under the hood. I still run into seemingly random desyncs even after applying the best practices so I try to do things as safe as possible, even if it's "unnecessary". Pretty sure this game is just busted - not like the new patches ever help.
This could mean that some issues that didn't seem related with editing the UI are actually related?
 
Top