Warcraft III resources & community, 2003–2006 · archived

Is there a way to find the host?

6 posts
#1

Is there a way to find the host?

Im making a map and there are various commands i want the host to be able to use, the problem is that i dont like the idea of assigning the commands the a colour rather than the actual host. so i was wondering if there was any way to find the host via jass. I do believe there was a topic somewhere here that would be able to help me with this but ive spent 3 hours searching with no success.
#2
(extracted from wc3Jass, made origionally by Tennis )

//This function takes nothing and returns the host of the game.
function GetHost takes nothing returns player
    //This stores the Id + 1 for each player.
    call StoreInteger(GameCache(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
    //Setup the TriggerSyncReady call.
    call TriggerSyncStart()
    //Sync the value of the entry for each player.
    //Each value will sync to the value of the host.
    call SyncStoredInteger(GameCache(), "missionKey", "key")
    //Wait until the Game Cache syncs the key for everyone.
    call TriggerSyncReady()
    //Return the synced value as a player.
    return Player(GetStoredInteger(GameCache(), "missionKey", "key") - 1)
endfunction
#3
BTW, what does TriggerSyncStart() stand for?
#4
i think that returns the host's slot, but dont ask, as i didnt write the function :)
#5
while the function does work, note that it will often return the "dude with the best comp" instead
of "dude who created the game".

i do miss the times when there were no server-switching and server-splitting technologies...
#6
*bump* 2 month revival topic

Yeah, its sorta buggy, but its the best you can get. (far as we know), and it seems to be fairly accurate.