• 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.

Recognizing Player

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
Is there a way to recognize a player that is host of the game (created game)

Like: I create a game and then I move to the slot 7 and someone is on slot 1 (so everything related to set settings (dialogs etc...) will be shown for guy on first slot (normally, it will check if slot is occupied, if not, it goes to next slot)).

Do you understand? So, if I created game, I'm the host and everything shall be shown to me for setting no matter on which slot I am. This is not required, but I'm asking if it's possible.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
JASS:
globals
    player Host
endglobals

function GetHost takes nothing returns nothing
    local gamecache g = InitGameCache("Map.w3v")
    call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ()))
    call TriggerSyncStart ()
    call SyncStoredInteger ( g, "Map", "Host" )
    call TriggerSyncReady ()
    set Host = Player( GetStoredInteger ( g, "Map", "Host" ))
    call FlushGameCache( g )
    set g = null
endfunction

I found this on google. Just call GetHost() and "Host" variable will get the host player number. I think it detect's the host by checking who loads the map first.

If you want it GUI just change "Host" for "udg_Host", delete the "globals" block, and create a Player variable called "Host". Then use a custom script to "call GetHost()" on map initialization.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
globals
    player Host
endglobals

function GetHost takes nothing returns nothing
    local gamecache g = InitGameCache("Map.w3v")
    call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ()))
    call TriggerSyncStart ()
    call SyncStoredInteger ( g, "Map", "Host" )
    call TriggerSyncReady ()
    set Host = Player( GetStoredInteger ( g, "Map", "Host" ))
    call FlushGameCache( g )
    set g = null
endfunction

I found this on google. Just call GetHost() and "Host" variable will get the host player number. I think it detect's the host by checking who loads the map first.

If you want it GUI just change "Host" for "udg_Host", delete the "globals" block, and create a Player variable called "Host". Then use a custom script to "call GetHost()" on map initialization.

Host should be set after a 0.00 second timer and it should just return Host, else your gonna get baiscally a 2sec sleep in the mid of your trigger.

And no, SyncStoredInteger syncs the integer with what the host has (if im not mistaken)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I don't think it desync, and the script works just like it's with no 2sec sleep in the mid of your trigger.

However, Arkhow is right about calling it on sec 0.00 and not Map Initialization (i'm not sure if it works on it thou...)
 
I don't think it desync, and the script works just like it's with no 2sec sleep in the mid of your trigger.

However, Arkhow is right about calling it on sec 0.00 and not Map Initialization (i'm not sure if it works on it thou...)

it wasnt my trigger lol. just a question.

ya calling GetLocalPlayer at map init will cause desyncs.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
No there is not as the host need not be playing in the session.
Welcome to host robots.

The person who hosts usually runs a host server and joins it with their client at the same time. This means that there is no player in the session tied with the host server as every client is identical to each other in the eyes of the host server.

You can try and do the synchronization trick described above. What it does is synchronizes the player who first runs the code. This has the result of returning the player with the lowest latency, even if the player who also is running the host server is someone else.

For example, there is a 50% chance of incorrect results if the host is playing with players on a LAN as the traffic arrives so fast that it is placed along side the internal PC network traffic used by the client to connect to the host within the same computer.

If a host robot is used then the results will vary depending on geographic location and traffic relative to where the host robot server is running.

This is why voting systems are best.
 
Level 18
Joined
May 11, 2012
Messages
2,103
No there is not as the host need not be playing in the session.
Welcome to host robots.

The person who hosts usually runs a host server and joins it with their client at the same time. This means that there is no player in the session tied with the host server as every client is identical to each other in the eyes of the host server.

You can try and do the synchronization trick described above. What it does is synchronizes the player who first runs the code. This has the result of returning the player with the lowest latency, even if the player who also is running the host server is someone else.

For example, there is a 50% chance of incorrect results if the host is playing with players on a LAN as the traffic arrives so fast that it is placed along side the internal PC network traffic used by the client to connect to the host within the same computer.

If a host robot is used then the results will vary depending on geographic location and traffic relative to where the host robot server is running.

This is why voting systems are best.

Wow, great!

Anyway, It seems too complicated, I'll just stay on what I have now :D

Thanks for trying tho :)
 
Status
Not open for further replies.
Top