Finding the host problem

Quakern

New Member
Reaction score
1
Hey there, I am trying to make that the host always choose the difficult, so I tried this toturial: http://www.wc3c.net/showthread.php?t=86119
and this script instead:

function GetHostId takes nothing returns integer
//This stores the Id + 1 for each player.
call StoreInteger(GameCache(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
//Setup the TriggerSyncReady call.
call TriggerSyncStart()
//Sync the value of the entry for each player.
//Each value will sync to the value of the host.
call SyncStoredInteger(GameCache(), "missionKey", "key")
//Wait until the Game Cache syncs the key for everyone.
call TriggerSyncReady()
//Return the synced value as a id.
return GetStoredInteger(GameCache(), "missionKey", "key") - 1
endfunction

I placed that script in triggers, at top where the name of the map is.

I also made a Variable named "Host" and it's a "player" variable.

and the last thing is this:
Trigger:
  • Start of the map
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call GetHost()


But I get an error on that trigger, so what am I doing wrong?
(error= Line 276: Expected a function name)
 

Faust

You can change this now in User CP.
Reaction score
123
Try using it as this:
Set Host (a player variable) = Player(GetHost() + 1)
 

wellwish3r

wishes wells.
Reaction score
52
did you also copy this function into your map header? Cause the function you posted is GetHostId...

JASS:
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
 

Faust

You can change this now in User CP.
Reaction score
123
Oh there are two functions, GetHost and GetHostId...
Well, if you try what I posted before, use the GetHostId
 

Quakern

New Member
Reaction score
1
okey the script looks like this now:

function GetHostId takes nothing returns integer
//This stores the Id + 1 for each player.
call StoreInteger(GameCache(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
//Setup the TriggerSyncReady call.
call TriggerSyncStart()
//Sync the value of the entry for each player.
//Each value will sync to the value of the host.
call SyncStoredInteger(GameCache(), "missionKey", "key")
//Wait until the Game Cache syncs the key for everyone.
call TriggerSyncReady()
//Return the synced value as a id.
return GetStoredInteger(GameCache(), "missionKey", "key") - 1
endfunction

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

function GetHostAverage takes nothing returns nothing
local integer array id
local integer max = 0
local integer t = 0
local integer i = 0
set udg_Host = null
loop
exitwhen i > 11
set id = 0
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 5
set t = GetHostId()
set id[t] = id[t] + 1
if id[t] > id[max] then
set max = t
endif
set i = i + 1
call TriggerSleepAction(1)
endloop
set udg_Host = Player(max)
endfunction

and my trigger:
Trigger:
  • Start of the map
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: Set Host = Player(GetHost() + 1)


But still got the same problem
 

wellwish3r

wishes wells.
Reaction score
52
Well the tutorial says that you only need this:

JASS:
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


and with only this, and this:

Trigger:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call GetHost()


it compiles fine (Do you have JassNewGen, or the regular WE?)
 

Quakern

New Member
Reaction score
1
I only have regular WE. But I tried exactly what the toturial said but still gets an error on the "call GetHost()" trigger :/

EDIT: lol found the problem, haha I just wrote the script on the comment side :p lolol. but thanks for your time guys :) +rep
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top