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

[JASS] Is there a way to find the host?

Status
Not open for further replies.
Level 1
Joined
Sep 26, 2006
Messages
1
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
(extracted from wc3Jass, made origionally by Tennis )

JASS:
//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
 
Level 6
Joined
Mar 2, 2006
Messages
306
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...
 
Status
Not open for further replies.
Top