• 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.

Dialog Vote System using Get Local Player

Status
Not open for further replies.
Level 6
Joined
Feb 10, 2011
Messages
188
Ok so I am working on a dialog system and I am using Get Local Player so each player has there own dialog and it wont be affected by other player pushing dialog buttons

Its desyncing, could you tell me why?

Also, if there is a better way to do a dialog vote system, lmk.

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_GetLocalPlayer = GetLocalPlayer()
  • Create Fog Vote
    • Events
    • Conditions
    • Actions
      • Custom script: local integer udg_tempInteger
      • Dialog - Change the title of DialogFog to Fog of War
      • Dialog - Create a dialog button for DialogFog labelled Fog of War Off
      • Set DialogFogOFF = (Last created dialog Button)
      • Dialog - Create a dialog button for DialogFog labelled Fog of War On
      • Set DialogFogON = (Last created dialog Button)
      • For each (Integer P) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GetLocalPlayer Equal to (Player(P))
            • Then - Actions
              • Dialog - Show DialogFog for (Player(P))
            • Else - Actions
  • Fog Picked
    • Events
      • Dialog - A dialog button is clicked for DialogFog
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to DialogFogON
        • Then - Actions
          • Set DialogFogONCount = (DialogFogONCount + 1)
          • Dialog - Hide DialogFog for (Triggering player)
        • Else - Actions
          • Set DialogFogOFFCount = (DialogFogOFFCount + 1)
          • Dialog - Hide DialogFog for (Triggering player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GetLocalPlayer Equal to (Triggering player)
            • Then - Actions
              • Trigger - Run Create Ship Vote <gen> (checking conditions)
            • Else - Actions
  • Create Second Vote
    • Events
    • Conditions
    • Actions
      • Dialog - Change the title of DialogShips to Battleships Allowed
      • Dialog - Create a dialog button for DialogShips labelled All Ships
      • Set DialogShipsON = (Last created dialog Button)
      • Dialog - Create a dialog button for DialogShips labelled Transports Only
      • Set DialogShipsOFF = (Last created dialog Button)
      • Dialog - Show DialogShips for GetLocalPlayer
 
You can use a global just fine. But your actions aren't sync-friendly. First comment:
  • For each (Integer P) from 1 to 12, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GetLocalPlayer Equal to (Player(P))
        • Then - Actions
          • Dialog - Show DialogFog for (Player(P))
        • Else - Actions
That whole thing can just be:
  • Dialog - Show DialogFog for GetLocalPlayer
That doesn't really have to do with the problem at hand though. :p
---------
The actual flaw is here:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • GetLocalPlayer Equal to (Triggering player)
    • Then - Actions
      • Trigger - Run Create Ship Vote <gen> (checking conditions)
    • Else - Actions
That runs "Create Second Vote" only for the local player. That trigger creates a dialog button (locally, because it is only ran by that player), and then wc3 forces a disconnect. You can't create agents locally. Instead, you should just use those actions directly, and just change the "Show dialog for..." to "Show dialog for (Triggering player)". I'm not sure why you need to run all those actions locally.

Anyway, Chaosy's post is good as a reference, but it might not give you all the info on GetLocalPlayer(). If you need some more info on it, you may want to check out:
http://www.thehelper.net/threads/jass-getlocalplayer.77369/
/shameless promotion.
 
Status
Not open for further replies.
Top