• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Checking online players

Status
Not open for further replies.
Level 7
Joined
Jun 23, 2009
Messages
297
I want to check whether if the player is on LAN or Single player, in order to destroy, or not, the leaderboard. Until nao i have this:


  • Start
    • Events
      • Time - Elapsed game time is 0.01545618789 seconds and a half
    • Conditions
      • Map Maker - Map maker is equal to (Craphter)
    • Actions
      • -------- ----- Leaderboards ----- --------
      • Leaderboard - Create a leaderboard for (All players) titled Kills
      • Leaderboard - Show (Last created leaderboard)
      • -------- ----- Ifs ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) controller) Equal to User
          • (Player 1 (Red) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 1 (Red) Current gold to 100
          • Player Group - Add Player 1 (Red) to JugadoresConectados
      • -------- Im from Argentina, "JugadoresConectados" means Online Players" --------
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 2 (Blue) controller) Equal to User
          • (Player 2 (Blue) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 2 (Blue) Current gold to 10
          • Player Group - Add Player 2 (Blue) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 3 (Teal) controller) Equal to User
          • (Player 3 (Teal) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 3 (Teal) Current gold to 10
          • Player Group - Add Player 3 (Teal) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 4 (Purple) controller) Equal to User
          • (Player 4 (Purple) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 4 (Purple) Current gold to 10
          • Player Group - Add Player 4 (Purple) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) controller) Equal to User
          • (Player 5 (Yellow) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 5 (Yellow) Current gold to 10
          • Player Group - Add Player 5 (Yellow) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 6 (Orange) controller) Equal to User
          • (Player 6 (Orange) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 6 (Orange) Current gold to 10
          • Player Group - Add Player 6 (Orange) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 7 (Green) controller) Equal to User
          • (Player 7 (Green) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 7 (Green) Current gold to 10
          • Player Group - Add Player 7 (Green) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 8 (Pink) controller) Equal to User
          • (Player 8 (Pink) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 8 (Pink) Current gold to 10
          • Player Group - Add Player 8 (Pink) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 9 (Gray) controller) Equal to User
          • (Player 9 (Gray) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 9 (Gray) Current gold to 10
          • Player Group - Add Player 9 (Gray) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 10 (Light Blue) controller) Equal to User
          • (Player 10 (Light Blue) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 10 (Light Blue) Current gold to 10
          • Player Group - Add Player 10 (Light Blue) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 11 (Dark Green) controller) Equal to User
          • (Player 11 (Dark Green) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 11 (Dark Green) Current gold to 10
          • Player Group - Add Player 11 (Dark Green) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 12 (Brown) controller) Equal to User
          • (Player 12 (Brown) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 12 (Brown) Current gold to 10
          • Player Group - Add Player 12 (Brown) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (JC Less than or equal to 0) then do (Leaderboard - Destroy the leaderboard else


But when I test my map on Single Player, the leaderboard appears empty:



drawing.png
 
Level 9
Joined
May 28, 2007
Messages
365
There is a bj_isSinglePlayer that is a boolean. It returns true if it is single player and false if it isn't.

That's should provide what you are looking for, I don't know the exact name of it though, and it's nto available in GUI.

Here is a script you could call using custom script.

function IsSinglePlayer takes nothing returns boolean
return bj_isSinglePlayer
endfunction

Then on your map initializaton trigger, use this

Custom Script( set udg_SinglePlayer = IsSinglePlayer() )

Make sure to create a variable called SinglePlayer as type boolean.
 
Level 7
Joined
Jun 23, 2009
Messages
297
Do you even initialize JC somewhere?
Also, don't you think this is pretty unfair? I mean Player 1 get's 90 gold more than the rest.

Whats "initialize a variable"?
And the gold is only for testing, u can build 3 buildings, the most expensive costs 24, so if i put 10 gold i wont be able to see if everything is in order... When i finish it ill put it to 10.

@overload, thanks a lot, but would you mind explaning that code? I get the part of

JASS:
function IsSinglePlayer takes nothing returns boolean
return bj_isSinglePlayer
endfunction

But i dont understand this:

JASS:
set udg_SinglePlayer = IsSinglePlayer()

And i like to understand everything in my map =)
 
Level 9
Joined
May 28, 2007
Messages
365
Sure no problem.

The function I made earlier returns a boolean, meaning it returns a value that is true/false. The function will let you know whether or not it is in Single Player.

The reason there is a

set udg_SinglePlayer = function()

Is because since you are using GUI, I made it easier for you. You can create a boolean variable (press Crt-X) and call it SinglePlayer. So, essentially you are assigning whether or not it is singleplayer to the variable udg_SinglePlayer which you will then be able ot include in your maps GUI triggers as

Condition - Boolean

If SinglePlayer == True then... do your stuff.

I hope I made it clear, I'll try one last attempt.
The function tells you if it is singleplayer or not. It returns the value of the singleplayer variable (but this variable cannot be accessed in GUI) Therefore, we create our own boolean variable in the variable editor and set it to the value of the singleplayer variable (bj_isSinglePlayer).

When I meant by initialization is that you have ot have ea trigger that runs at the start of your map. The event for that trigger will be Map Initialization, and the action will be:

Custom Script - set udg_SinglePlayer = IsSinglePlayer()
-- This is the part that assigns GUI variable to the single player variable that is otherwise unaccessable.
 
Level 15
Joined
Aug 11, 2009
Messages
1,606
Why don't you use something like this one?
  • If ((Player 1 (Red) slot status) Equal to Is playing) then do (Leaderboard - Add Player 1 (Red) to LEADERBOARD with label (Name of Player 1 (Red)) and value Kills) else do (Do nothing)
Where LEADERBOARD is a variable of leaderboard type and is equal to last created leaderboard.
 
Level 7
Joined
Jun 23, 2009
Messages
297
Sure no problem.

The function I made earlier returns a boolean, meaning it returns a value that is true/false. The function will let you know whether or not it is in Single Player.

The reason there is a

set udg_SinglePlayer = function()

Is because since you are using GUI, I made it easier for you. You can create a boolean variable (press Crt-X) and call it SinglePlayer. So, essentially you are assigning whether or not it is singleplayer to the variable udg_SinglePlayer which you will then be able ot include in your maps GUI triggers as

Condition - Boolean

If SinglePlayer == True then... do your stuff.

I hope I made it clear, I'll try one last attempt.
The function tells you if it is singleplayer or not. It returns the value of the singleplayer variable (but this variable cannot be accessed in GUI) Therefore, we create our own boolean variable in the variable editor and set it to the value of the singleplayer variable (bj_isSinglePlayer).

When I meant by initialization is that you have ot have ea trigger that runs at the start of your map. The event for that trigger will be Map Initialization, and the action will be:

Custom Script - set udg_SinglePlayer = IsSinglePlayer()
-- This is the part that assigns GUI variable to the single player variable that is otherwise unaccessable.



Yaaaaaaayy!!
Thnks a lot Overload, + rep :grin:
Keep on like this :D

@reason3, the original trigger is this one:

  • Inicio
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- ----- Timers ----- --------
      • Countdown Timer - Start FBattle as a One-shot timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for FBattle with title Next battle in
      • Countdown Timer - Show (Last created timer window)
      • -------- ----- Leaderboards ----- --------
      • Leaderboard - Create a leaderboard for (All players) titled Kills
      • Leaderboard - Show (Last created leaderboard)
      • -------- ----- Ifs ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) controller) Equal to User
          • (Player 1 (Red) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 1 (Red) Current gold to 1000
          • Player Group - Add Player 1 (Red) to JugadoresConectados
          • Unit - Create 1 Builder for Player 1 (Red) at (Player 1 (Red) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 1 (Red)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 2 (Blue) controller) Equal to User
          • (Player 2 (Blue) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 2 (Blue) Current gold to 10
          • Player Group - Add Player 2 (Blue) to JugadoresConectados
          • Unit - Create 1 Builder for Player 2 (Blue) at (Player 2 (Blue) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 2 (Blue)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 3 (Teal) controller) Equal to User
          • (Player 3 (Teal) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 3 (Teal) Current gold to 10
          • Player Group - Add Player 3 (Teal) to JugadoresConectados
          • Unit - Create 1 Builder for Player 3 (Teal) at (Player 3 (Teal) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 3 (Teal)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 4 (Purple) controller) Equal to User
          • (Player 4 (Purple) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 4 (Purple) Current gold to 10
          • Player Group - Add Player 4 (Purple) to JugadoresConectados
          • Unit - Create 1 Builder for Player 4 (Purple) at (Player 4 (Purple) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 4 (Purple)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) controller) Equal to User
          • (Player 5 (Yellow) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 5 (Yellow) Current gold to 10
          • Player Group - Add Player 5 (Yellow) to JugadoresConectados
          • Unit - Create 1 Builder for Player 5 (Yellow) at (Player 5 (Yellow) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 5 (Yellow)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 6 (Orange) controller) Equal to User
          • (Player 6 (Orange) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 6 (Orange) Current gold to 10
          • Unit - Create 1 Builder for Player 6 (Orange) at (Player 6 (Orange) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 6 (Orange)
          • Player Group - Add Player 6 (Orange) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 7 (Green) controller) Equal to User
          • (Player 7 (Green) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 7 (Green) Current gold to 10
          • Unit - Create 1 Builder for Player 7 (Green) at (Player 7 (Green) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 7 (Green)
          • Player Group - Add Player 7 (Green) to JugadoresConectados
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 8 (Pink) controller) Equal to User
          • (Player 8 (Pink) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 8 (Pink) Current gold to 10
          • Player Group - Add Player 8 (Pink) to JugadoresConectados
          • Unit - Create 1 Builder for Player 8 (Pink) at (Player 8 (Pink) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 8 (Pink)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 9 (Gray) controller) Equal to User
          • (Player 9 (Gray) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 9 (Gray) Current gold to 10
          • Player Group - Add Player 9 (Gray) to JugadoresConectados
          • Unit - Create 1 Builder for Player 9 (Gray) at (Player 9 (Gray) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 9 (Gray)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 10 (Light Blue) controller) Equal to User
          • (Player 10 (Light Blue) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 10 (Light Blue) Current gold to 10
          • Player Group - Add Player 10 (Light Blue) to JugadoresConectados
          • Unit - Create 1 Builder for Player 10 (Light Blue) at (Player 10 (Light Blue) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 10 (Light Blue)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 11 (Dark Green) controller) Equal to User
          • (Player 11 (Dark Green) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 11 (Dark Green) Current gold to 10
          • Player Group - Add Player 11 (Dark Green) to JugadoresConectados
          • Unit - Create 1 Builder for Player 11 (Dark Green) at (Player 11 (Dark Green) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 11 (Dark Green)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 12 (Brown) controller) Equal to User
          • (Player 12 (Brown) slot status) Equal to Is playing
        • Then - Actions
          • Player - Set Player 12 (Brown) Current gold to 10
          • Player Group - Add Player 12 (Brown) to JugadoresConectados
          • Unit - Create 1 Builder for Player 12 (Brown) at (Player 12 (Brown) start location) facing 270.00 degrees
          • Selection - Select (Last created unit) for Player 12 (Brown)
        • Else - Actions
          • Set JC = (JC - 1)
      • If (JC Less than or equal to 0) then do (Leaderboard - Destroy (Last created leaderboard)) else do (Do nothing)
      • -------- ----- Visibility ----- --------
      • Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across Construccion 1 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 2 (Blue) emitting Visibility across Construccion 1 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 3 (Teal) emitting Visibility across Construccion 1 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 4 (Purple) emitting Visibility across Construccion 1 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 5 (Yellow) emitting Visibility across Construccion 1 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 6 (Orange) emitting Visibility across Construccion 1 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 7 (Green) emitting Visibility across Construccion 2 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 8 (Pink) emitting Visibility across Construccion 2 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 9 (Gray) emitting Visibility across Construccion 2 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 10 (Light Blue) emitting Visibility across Construccion 2 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 11 (Dark Green) emitting Visibility across Construccion 2 <gen>
      • Visibility - Create an initially Enabled visibility modifier for Player 12 (Brown) emitting Visibility across Construccion 2 <gen>
      • -------- ----- Camera ----- --------
      • Camera - Pan camera for Player 1 (Red) to (Player 1 (Red) start location) over 0.10 seconds
      • Camera - Pan camera for Player 2 (Blue) to (Player 2 (Blue) start location) over 0.10 seconds
      • Camera - Pan camera for Player 3 (Teal) to (Player 3 (Teal) start location) over 0.10 seconds
      • Camera - Pan camera for Player 4 (Purple) to (Player 4 (Purple) start location) over 0.10 seconds
      • Camera - Pan camera for Player 5 (Yellow) to (Player 5 (Yellow) start location) over 0.10 seconds
      • Camera - Pan camera for Player 6 (Orange) to (Player 6 (Orange) start location) over 0.10 seconds
      • Camera - Pan camera for Player 7 (Green) to (Player 7 (Green) start location) over 0.10 seconds
      • Camera - Pan camera for Player 8 (Pink) to (Player 8 (Pink) start location) over 0.10 seconds
      • Camera - Pan camera for Player 9 (Gray) to (Player 9 (Gray) start location) over 0.10 seconds
      • Camera - Pan camera for Player 10 (Light Blue) to (Player 10 (Light Blue) start location) over 0.10 seconds
      • Camera - Pan camera for Player 11 (Dark Green) to (Player 11 (Dark Green) start location) over 0.10 seconds
      • Camera - Pan camera for Player 12 (Brown) to (Player 12 (Brown) start location) over 0.10 seconds
      • -------- ----- Extras ----- --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Turn Gives bounty On for (Picked player)
      • Sound - Stop (Last played sound) Immediately
      • Sound - Play DaybreakRooster <gen>
      • Sound - Use the Lordaeron Summer nighttime ambient theme
      • Wait 4.50 seconds
      • Game - Display to (All players) the text: Welcome to Epic Bla...
      • Wait 2.00 seconds
      • Game - Display to (All players) the text: |c00FFCC00Start con...

So thats why i dont make it the other way :p
 
Level 11
Joined
Apr 29, 2007
Messages
826
Whats "initialize a variable"?

I mean, you have the Variable JC. Each time a player isn't playing, you're substracting it by 1. Then, if it is less than or equal to 0, you destroy the leaderboard.
But, variables have an normal value of 0 if you didn't put anything in the variable editor. Means you have to set the variable to atleast 11 in order to make it work.
 
Level 15
Joined
Aug 11, 2009
Messages
1,606
Heh,funny :D anyway wait i will edit this post and tell you how!
EDIT:You can use this one:
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
I am sure you will find it...Using this you can set the "action" to take place for the number of players you want as you see above.It doesn't really matter if it is A or B.
 
Last edited:
Status
Not open for further replies.
Top