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

[Solved] Host Cmd

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
333
Should this work?!
detect
JASS:
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
 

~El

Level 17
Joined
Jun 13, 2016
Messages
557
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.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
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.
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.
 
Status
Not open for further replies.
Top