1. The 3rd Melee Mapping Contest is ON! Join in on a ride of a 4v4 melee experience!
    Dismiss Notice
  2. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  3. We have a new contest going on right now! Join the 11th Music Contest! You are to make a Cinematic modern sound-track for this contest, so come and compete with other people for fun.
    Dismiss Notice
  4. The Aftermath has been revealed! Choose which entry should win in the 19th Terraining Contest Poll.
    Dismiss Notice

Host Cmd

Discussion in 'World Editor Help Zone' started by AlwaysAndForever, Jan 14, 2019 at 4:26 PM.

  1. AlwaysAndForever

    AlwaysAndForever

    Joined:
    Jun 20, 2017
    Messages:
    187
    Resources:
    1
    Maps:
    1
    Resources:
    1
    How to make only host able to type some command?!
     
  2. AlwaysAndForever

    AlwaysAndForever

    Joined:
    Jun 20, 2017
    Messages:
    187
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Should this work?!
    detect
    Code (vJASS):

    function GetHost takes nothing returns nothing
        local gamecache g = InitGameCache("Map.w3v")
        call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ())+1)
        call TriggerSyncStart ()
        call SyncStoredInteger ( g, "Map", "Host" )
        call TriggerSyncReady ()
        set udg_Host = Player( GetStoredInteger ( g, "Map", "Host" )-1)
        call FlushGameCache( g )
        set g = null
    endfunction
     
    cmd
    • Progame
      • Events
        • Player - Player 1 (Red) types a chat message containing -pg as An exact match
        • Player - Player 2 (Blue) types a chat message containing -pg as An exact match
        • Player - Player 3 (Teal) types a chat message containing -pg as An exact match
        • Player - Player 4 (Purple) types a chat message containing -pg as An exact match
        • Player - Player 5 (Yellow) types a chat message containing -pg as An exact match
        • Player - Player 6 (Orange) types a chat message containing -pg as An exact match
        • Player - Player 7 (Green) types a chat message containing -pg as An exact match
        • Player - Player 10 (Light Blue) types a chat message containing -pg as An exact match
        • Player - Player 11 (Dark Green) types a chat message containing -pg as An exact match
        • Player - Player 12 (Brown) types a chat message containing -pg as An exact match
      • Conditions
      • Actions
        • Custom script: call GetHost()
        • Set Integer_GameModes = 1
        • Sound - Play Warning <gen>
        • Game - Display to (All players) the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ( has activated |cffff0000Progame|r mode. + Now Hunters are stronger and can level up faster.))
        • Trigger - Turn off (This trigger)
    • Select Host
      • Events
        • Time - Elapsed game time is 0.00 seconds
      • Conditions
        • (Triggering player) Equal to (==) Host
      • Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 1 (Red) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 1 (Red)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 2 (Blue) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 2 (Blue)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 3 (Teal) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 3 (Teal)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 4 (Purple) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 4 (Purple)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 5 (Yellow) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 5 (Yellow)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 6 (Orange) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 6 (Orange)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 7 (Green) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 7 (Green)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 10 (Light Blue) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 10 (Light Blue)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 11 (Dark Green) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 11 (Dark Green)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 12 (Brown) is in PlayerGroup_Host) Equal to (==) True
          • Then - Actions
            • Set Host = Player 12 (Brown)
          • Else - Actions
     
  3. Sir Moriarty

    Sir Moriarty

    Joined:
    Jun 13, 2016
    Messages:
    242
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Not really. There's no reliable way to detect the host anymore. This method "usually" worked in the era before bots, but it stopped after bots appeared. Same goes for the current B.Net patches.

    This trick relied on the fact that the host would have the lowest latency out of all players (by virtue of being the host, duh), but this is no longer the case as the game is hosted by Blizzard servers, and another player may have a lower ping than the host.
     
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    24,919
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Ironically it did not even work well back when it did "work". Players connected to the host via LAN could potentially be detected as the host due to sub millisecond latency.

    The best way to do what you want is to design the game around selecting forces/colour at map start rather than in lobby. That way you can have a dedicated force "host" which the host player can always place themselves in, while still not be disadvantaged with choice selection.