[Commands] Host Commands

Yezz

New Member
Reaction score
0
Okay, i got a detect host script, but i dont know how to connect the commands to it.
 

Yezz

New Member
Reaction score
0
All credit to Azylaminaz
JASS:

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


All credit to Azylaminaz
 

Exide

I am amazingly focused right now!
Reaction score
448
Now, in your GUI trigger, add the condition:
If (Triggering Player) Equal to Host then ..actions..

Host is your player variable, and you should compare players. (If the player that is attempting to use your commands == Host, then .. do actions.. else *do nothing*.)

Conclusion:
Player comparison - (Triggering Player) == Host
 

Rainther

I guess I should write something of value here...
Reaction score
61
Run 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.
 

Igor_Z

You can change this now in User CP.
Reaction score
61
Detecting the host might be a little tricky so I suggest u use those commands when the first player from force 1 types something cuz in most games the first player of force 1 is the host. If you want to detect host look @ this
 

Yezz

New Member
Reaction score
0
Run 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()
 

UndeadDragon

Super Moderator
Reaction score
447
Where should i put
call GetHost()

Use the event Map Initialization and then do

Trigger:
  • Custom Script: call GetHost()


Make sure you have created the host variable (player variable).
 

Romek

Super Moderator
Reaction score
963
And when the host leaves. :)
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
He means, and when the host leaves - then what?

My solution, pick a random player, make him the new host.
 

Rainther

I guess I should write something of value here...
Reaction score
61
Depends on the other players hosting-game ability. If anyone can keep the game up after host leaves/disconnects.

My suggestion is a Game Message: The Captain has left the ship, big ice block ahead!
And then Game Over ;P

Jokes aside, but you need to think of stuff such as that. I haven't checked the entire trigger but you can have event On Map Initialization and all when player leaves, condtion equal to Host and then reuse the function. Maybe you have to null the Player variable first.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
He means, and when the host leaves - then what?

My solution, pick a random player, make him the new host.

What he means is you call the GetHost function once when the game starts, and every time the host leaves. Try This:

Trigger:
  • Init
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Custom Script: call GetHost()
      • Trigger - Add to Get Host the event (Player - (Host) leaves the game)


Trigger:
  • Get Host
    • Events
    • Conditions
    • Actions
      • Custom Script: call GetHost()
      • Trigger - Add to (This trigger) the event (Player - (Host) leaves the game)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top