• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Using the host selection

Status
Not open for further replies.
Hmmm, someone tried to do the thing for me so I got to ask what he did.

Edit: I imported the script and made a test trigger that says the name of the picked player. This test works, but when I want to show a dialog to the player under the Host variable nothing pops up. Even when he is selected as the host.
 
just do this:
Go to the trigger editor,,
you will see triggers, and maps (submaps)
Above the submaps there is the name of the map including the icon of it (RoC or TFT),, you will see a place where you can place Jass scripts,,
put the code in there,, (here it is again)
JASS:
[COLOR=#b8a26e]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
[/COLOR]
then you can freely do this anywhere in your triggers:
  • Custom script: call GetHost()
But make sure you have a Player Variable called 'Host' in your map
(i said unit variable before, i meant player,, sorry)

hope it helps you,,
 
I edited my older post when you wrote that :P
----------------------------------------------------
I imported the script and made a test trigger that says the name of the picked player. This test works, but when I want to show a dialog to the player under the Host variable nothing pops up. Even when he is selected as the host.


Edit: the -host command also seems to only work for player 1 (yes I made it useable by other players :P)


Edit II: using the Call GetHost() in front of every action that needs to use the host variable just causes fatal errors.
 
You should call it once.
Why would you ever need to get the host again and again in the first place - that's the point of the global variable you declared.

Just stick that function in the map header, call it somewhere with an init event (or time == 0, or whatever you want) and use the variable wherever you want.
 
This script doesn't work... I tested it a couple of times...
what I did is:

I made a variable called Host (type = player)

I putted the script in the upper map (the init script of your map)

then I made a init trigger:

map initialization

call GetHost()

and when I went to a different trigger with a show dialog action and used the Host variable... It didn't show up at all...

EDIT: nevermind, I fixed it by using the call GetHost() in the elapsed game time = 0 sec dialog trigger :)
 
Note - Hashjie is the guy who was with me fixing the problem :P
Tutorial says it needs to be put at Map Initialization, but I guess that is wrong.

Problem solved - Have a look at the host selection tutorial whoever wants to close this thread, because it seems like there is a very important mistake in it (the thing can not be called at map initialization even though it says so in the tutorial)
 
Last edited:
Note - Hashjie is the guy who was with me fixing the problem :P
Tutorial says it needs to be put at Map Initialization, but I guess that is wrong.

I think it is not wrong, the only reason why it shouldn't work is because we used a map init AND a 0.00 game time event... I think if you use gethost on map init it isn't working because another trigger is doing something at a small time later as the map init. which means it has too less time to figure out who is the host... maybe if we haven't got the 0.00 game time event it should work on map init

(haven't tested it though :grin:)

(thats only what I think that happened... If not then I should be ashamed of myself :hohum: and it should be changed in the tutorial)
 
Status
Not open for further replies.
Back
Top