• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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