IOwnYouAll
01-10-2008, 21:14
Orig Post:
How to create a trigger function to detect the host?
Well here you have it.
First of all you need a variable to serve as the host:
-go into trigger editor and select variables editor.
There create a variable named Host and set it as "Player" without any array.
Now comes the best part, creating the jass function:
Go into trigger editor and select the map thing on top of the trigger list and paste there the following code:
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
endfunctionNow that you have set the basics you need to create a trigger to run the jass and to set the variable as the host:
Event:Map Initialization
Condition:None
Action:Custom script: call GetHost()Note:Now when you want to do something with the host , you just need to use the variable named Host.
Note2:This code is not 100% reliable and it can fail sometimes but that happens very rarely.
This tutorial was taken from TheHiveWorkshop and www.wc3jass.com (http://www.wc3jass.com)
How to create a trigger function to detect the host?
Well here you have it.
First of all you need a variable to serve as the host:
-go into trigger editor and select variables editor.
There create a variable named Host and set it as "Player" without any array.
Now comes the best part, creating the jass function:
Go into trigger editor and select the map thing on top of the trigger list and paste there the following code:
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
endfunctionNow that you have set the basics you need to create a trigger to run the jass and to set the variable as the host:
Event:Map Initialization
Condition:None
Action:Custom script: call GetHost()Note:Now when you want to do something with the host , you just need to use the variable named Host.
Note2:This code is not 100% reliable and it can fail sometimes but that happens very rarely.
This tutorial was taken from TheHiveWorkshop and www.wc3jass.com (http://www.wc3jass.com)