1. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  2. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  3. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice

[Solved] Host Cmd

Discussion in 'World Editor Help Zone' started by AlwaysAndForever, Jan 14, 2019.

  1. AlwaysAndForever

    AlwaysAndForever

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

    AlwaysAndForever

    Joined:
    Jun 20, 2017
    Messages:
    200
    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:
    315
    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:
    25,260
    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.
     
  5. Pinzu

    Pinzu

    Joined:
    Nov 30, 2007
    Messages:
    1,162
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    Hosting is such an elitist system, everything should be decided by popular vote.
     
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,260
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I mostly agree, but in some sorts of maps it can be useful. For example in roleplay maps where the host usually acts as the dungeon master.