function GetHost takes nothing returns nothing
local gamecache g
local integer array count
local integer a = 0
local integer popular = -1
local integer maxCount = -1
loop
exitwhen a == 12
set count[a] = 0
set a = a + 1
endloop
set a = 0
loop
exitwhen a == 10
set g = InitGameCache("Map.w3v")
call StoreInteger(g, "Map", "Host", GetPlayerId(GetLocalPlayer())+1)
call TriggerSyncStart()
call SyncStoredInteger(g, "Map", "Host" )
call TriggerSyncReady()
set count[GetStoredInteger(g, "Map", "Host")] = count[GetStoredInteger(g, "Map", "Host")] + 1
call FlushGameCache(g)
set g = null
set a = a + 1
endloop
set a = 0
loop
exitwhen a == 12
if count[a] > maxCount then
set maxCount = count[a]
set popular = a
endif
set a = a + 1
endloop
set udg_Host = Player(popular + 1)
endfunction
Where should i putRun it once on Map Initialization. Use a custom script 'call GetHost()' and make sure to have the player variable Host. Then you should be able to use Host variable whenever you want to use the host player.
Where should i put
call GetHost()
What do you mean by that?And when the host leaves.
And when the host leaves.
He means, and when the host leaves - then what?
My solution, pick a random player, make him the new host.