• 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] Using the host selection

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
show us what you did, show us the trigger (or the code you did) and the trigger where you call the function,,
BTW: Did you make a variable:
Unit Variable called: 'Host' (will become udg_Host in JASS)
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
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.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
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,,
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
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.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
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.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
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 :)
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
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:
Level 14
Joined
Apr 20, 2009
Messages
1,543
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.
Top