1. 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
  2. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice
  3. Melee Mapping Contest #3 - Results are out! Congratulate the winners and check plenty of new 4v4 melee maps designed for this competition!
    Dismiss Notice
  4. The winners of our cinematic soundtrack competition have been decided! Step by the Music Contest #11 - Results to check the entries and congratulate the winners!
    Dismiss Notice

Host Cmd

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

  1. AlwaysAndForever

    AlwaysAndForever

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

    AlwaysAndForever

    Joined:
    Jun 20, 2017
    Messages:
    180
    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

    Spell Reviewer

    Joined:
    Jun 13, 2016
    Messages:
    279
    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,030
    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,160
    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,030
    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.