• 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.

Player online detection

Status
Not open for further replies.
Level 5
Joined
Aug 17, 2014
Messages
106
Essentially what I've been trying to figure out to do is a trigger that would enable my RPG to detect which of the three players are online so they can all get the game started at once. Let me specify a bit more. In my rpg you start at a race selection screen then a class selection screen following that and obviously some people will get done quicker than others. The way I have it set-up right now your hero will be instantly created in a region in a room. Can someone make me a gui trigger so your hero is paused until every online player finishes their character creation and enters that region or at least help me figure it out.
 
Level 3
Joined
Nov 12, 2018
Messages
43
I guess you already triggered the hero and class selection. In that case, all you have to do, is adding a variable that holds the information that player x has finished hero selection. I recommend a boolean or an integer for that. If one player is done, you set the corresponding variable: (just an example)
  • Set boolean[1-3] = True
  • or
  • Set integer[1-3] = 1
And you add this at the end of the trigger, that is responsible for the selection process:
  • Trigger - Run Game Start
"Game Start" should look like this:
  • Events:
  • Conditions:
    • boolean[1] = True //or integers
    • boolean[2] = True
    • boolean[3] = True
  • Actions:
    • Do what ever should happen...
The problem with this is, that your game will NEVER start, in case someone lefts the game early, or desyncs. I recommend adding a timer that starts your game without conditions, in case the selection process takes too long.
 
Level 5
Joined
Aug 17, 2014
Messages
106
I guess you already triggered the hero and class selection. In that case, all you have to do, is adding a variable that holds the information that player x has finished hero selection. I recommend a boolean or an integer for that. If one player is done, you set the corresponding variable: (just an example)
  • Set boolean[1-3] = True
  • or
  • Set integer[1-3] = 1
And you add this at the end of the trigger, that is responsible for the selection process:
  • Trigger - Run Game Start
"Game Start" should look like this:
  • Events:
  • Conditions:
    • boolean[1] = True //or integers
    • boolean[2] = True
    • boolean[3] = True
  • Actions:
    • Do what ever should happen...
The problem with this is, that your game will NEVER start, in case someone lefts the game early, or desyncs. I recommend adding a timer that starts your game without conditions, in case the selection process takes too long.
I'll try this out and let you know if it works for me, I appreciate the help!
 
Level 5
Joined
Aug 17, 2014
Messages
106
Well I am a bit confused i'm not exactly sure if this works for me. When your hero selection is done its instantly created in some far off region, I want your hero to be paused until all player heroes land in that area. Essentially, I want the game to understand which of the three player slots are being used and if x number is being used then you would need to wait for x heroes to land in that area. Once they do they're all unpaused. Would this work??
b65c27f34216e06a908584dddd8b9b63.png

32d321f699daf86545fe6569f96e733b.png
714bf564737adf26ee28cd52d703e76b.png
f27849fa00b16451b8b0386b9b926bf4.png

74cf4f79e431248ef4498d12c4332cc0.png
 
Level 9
Joined
Jul 30, 2018
Messages
445
Heh, that's a bit complicated. Just use loops and an integer variable.

Here. Make a trigger to check how many players are online:
  • Check Player Status
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to [max amount of players], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Set PlayerCount = (PlayerCount + 1)
            • Else - Actions

Then increase that variable every time a player chooses his/her hero:
  • Check Player Ready
    • Events
      • [Whatever your event is when a hero is chosen]
    • Conditions
    • Actions
      • Unit - Pause [Chosen hero]
      • Set PlayerReady = (PlayerReady + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PlayerReady Equal to PlayerCount
        • Then - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in HeroArea) and do (Actions)
            • Loop - Actions
              • Unit - Unpause (Picked unit)
        • Else - Actions

Then, a failsafe for if a player leaves, it then lowers the PlayerCount and also checks if the other two players are now ready, so they don't get stuck if they have already chosen their hero and the last one leaves before choosing his/hers:
  • Player Leave
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • [...]
      • [Amount of players]
    • Conditions
    • Actions
      • Set PlayerCount = (PlayerCount - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PlayerReady Equal to PlayerCount
        • Then - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in HeroArea) and do (Actions)
            • Loop - Actions
              • Unit - Unpause (Picked unit)
        • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top