Online players in world

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Try with this

Code:
 # this is one add
        loop all players in world "world1":   # Change every name in the world with the worlds you want
            add loop-player to {_players1::*}
            set {_online1} to size of {_players1::*}
        loop all players in world "world2":   # Change every name in the world with the worlds you want
            add loop-player to {_players2::*}
            set {_online2} to size of {_players2::*}
        loop all players in world "world3":   # Change every name in the world with the worlds you want
            add loop-player to {_players3::*}
            set {_online3} to size of {_players3::*}         
            wait 0.2 ticks
Code:
command /lobbysel:
    trigger:
        loop all players in world "world1":   #Change every name in the world with the worlds you want
            add loop-player to {_players1::*}
            set {_online1} to size of {_players1::*}
        loop all players in world "world2":
            add loop-player to {_players2::*}
            set {_online2} to size of {_players2::*}
        loop all players in world "world3":
            add loop-player to {_players3::*}
            set {_online3} to size of {_players3::*}      
            wait 0.2 ticks
            open chest with 3 rows named "&a&lLobby Selector" to player
            format slot 0 of player with 160:7 named " " to close
            format slot 1 of player with 160:7 named " " to close
            format slot 2 of player with 160:7 named " " to close
            format slot 3 of player with 160:7 named " " to close
            format slot 4 of player with 160:7 named " " to close
            format slot 5 of player with 160:7 named " " to close
            format slot 6 of player with 160:7 named " " to close
            format slot 7 of player with 160:7 named " " to close
            format slot 8 of player with 160:7 named " " to close
            format slot 9 of player with 160:7 named " " to close
            format slot 10 of player with 399 named "&a&lHub 1" with lore "&3Connect to:||&bHub 1||&b%{_online1}%" to close then run [make player execute command "ehub"]
            format slot 11 of player with 160:7 named " " to close
            format slot 12 of player with 160:7 named " " to close
            format slot 13 of player with 399 named "&a&lHub 2" with lore "&3Connect to:||&bHub 2||&b%{_online2}%" to close then run [make player execute command "warp hub2"]
            format slot 14 of player with 160:7 named " " to close
            format slot 15 of player with 160:7 named " " to close
            format slot 16 of player with 399 named "&a&lHub 3" with lore "&3Connect to:||&bHub 3||&b%{_online3}%" to close then run [make player execute command "warp hub3"]
            format slot 17 of player with 160:7 named " " to close
            format slot 18 of player with 160:7 named " " to close
            format slot 19 of player with 160:7 named " " to close
            format slot 20 of player with 160:7 named " " to close
            format slot 21 of player with 160:7 named " " to close
            format slot 22 of player with 160:7 named " " to close
            format slot 23 of player with 160:7 named " " to close
            format slot 24 of player with 160:7 named " " to close
            format slot 25 of player with 160:7 named " " to close
            format slot 26 of player with 160:7 named " " to close
 
Last edited:
Try with this

Code:
 # this is one add
        loop all players in world "world1":   # Change every name in the world with the worlds you want
            add loop-player to {_players1::*}
            set {_online1} to size of {_players1::*}
        loop all players in world "world2":   # Change every name in the world with the worlds you want
            add loop-player to {_players2::*}
            set {_online2} to size of {_players2::*}
        loop all players in world "world3":   # Change every name in the world with the worlds you want
            add loop-player to {_players3::*}
            set {_online3} to size of {_players3::*}        
            wait 0.2 ticks
Code:
command /lobbysel:
    trigger:
        loop all players in world "world1":   #Change every name in the world with the worlds you want
            add loop-player to {_players1::*}
            set {_online1} to size of {_players1::*}
        loop all players in world "world2":
            add loop-player to {_players2::*}
            set {_online2} to size of {_players2::*}
        loop all players in world "world3":
            add loop-player to {_players3::*}
            set {_online3} to size of {_players3::*}     
            wait 0.2 ticks
            open chest with 3 rows named "&a&lLobby Selector" to player
            format slot 0 of player with 160:7 named " " to close
            format slot 1 of player with 160:7 named " " to close
            format slot 2 of player with 160:7 named " " to close
            format slot 3 of player with 160:7 named " " to close
            format slot 4 of player with 160:7 named " " to close
            format slot 5 of player with 160:7 named " " to close
            format slot 6 of player with 160:7 named " " to close
            format slot 7 of player with 160:7 named " " to close
            format slot 8 of player with 160:7 named " " to close
            format slot 9 of player with 160:7 named " " to close
            format slot 10 of player with 399 named "&a&lHub 1" with lore "&3Connect to:||&bHub 1||&b%{_online1}%" to close then run [make player execute command "ehub"]
            format slot 11 of player with 160:7 named " " to close
            format slot 12 of player with 160:7 named " " to close
            format slot 13 of player with 399 named "&a&lHub 2" with lore "&3Connect to:||&bHub 2||&b%{_online2}%" to close then run [make player execute command "warp hub2"]
            format slot 14 of player with 160:7 named " " to close
            format slot 15 of player with 160:7 named " " to close
            format slot 16 of player with 399 named "&a&lHub 3" with lore "&3Connect to:||&bHub 3||&b%{_online3}%" to close then run [make player execute command "warp hub3"]
            format slot 17 of player with 160:7 named " " to close
            format slot 18 of player with 160:7 named " " to close
            format slot 19 of player with 160:7 named " " to close
            format slot 20 of player with 160:7 named " " to close
            format slot 21 of player with 160:7 named " " to close
            format slot 22 of player with 160:7 named " " to close
            format slot 23 of player with 160:7 named " " to close
            format slot 24 of player with 160:7 named " " to close
            format slot 25 of player with 160:7 named " " to close
            format slot 26 of player with 160:7 named " " to close
ok thank you!
[doublepost=1595147949,1594974067][/doublepost]
Try with this

Code:
 # this is one add
        loop all players in world "world1":   # Change every name in the world with the worlds you want
            add loop-player to {_players1::*}
            set {_online1} to size of {_players1::*}
        loop all players in world "world2":   # Change every name in the world with the worlds you want
            add loop-player to {_players2::*}
            set {_online2} to size of {_players2::*}
        loop all players in world "world3":   # Change every name in the world with the worlds you want
            add loop-player to {_players3::*}
            set {_online3} to size of {_players3::*}        
            wait 0.2 ticks
but How do I do so if nobody is in that world that it says 0, it says alwasy <none>
 
Code:
if {_online1} is not set:
    set {_online1} to 0
if {_online2} is not set:
    set {_online2} to 0
if {_online3} is not set:
    set {_online3} to 0
 
  1. Code:
    every 5 seconds:
    [/LIST]
    
        if {_online1} is not set:
            set {_online1} to 0
        if {_online2} is not set:
            set {_online2} to 0
        if {_online3} is not set:
            set {_online3} to 0

    This should work with minimal lag.
 
or he could just add it to the existing code:
the way you did it, it's extremely unlikely to work properly because with this: set {_online1} to size of {_players1::*}, the variable will be set back to <none>
Code:
command /lobbysel:
    trigger:
        loop all players in world "world1":   #Change every name in the world with the worlds you want
            add loop-player to {_players1::*}
            set {_online1} to size of {_players1::*}
        loop all players in world "world2":
            add loop-player to {_players2::*}
            set {_online2} to size of {_players2::*}
        loop all players in world "world3":
            add loop-player to {_players3::*}
            set {_online3} to size of {_players3::*}
        if {_online1} is not set:
            set {_online1} to 0
        if {_online2} is not set:
            set {_online2} to 0
        if {_online3} is not set:
            set {_online3} to 0
            wait 0.2 ticks
            open chest with 3 rows named "&a&lLobby Selector" to player
            format slot 0 of player with 160:7 named " " to close
            format slot 1 of player with 160:7 named " " to close
            format slot 2 of player with 160:7 named " " to close
            format slot 3 of player with 160:7 named " " to close
            format slot 4 of player with 160:7 named " " to close
            format slot 5 of player with 160:7 named " " to close
            format slot 6 of player with 160:7 named " " to close
            format slot 7 of player with 160:7 named " " to close
            format slot 8 of player with 160:7 named " " to close
            format slot 9 of player with 160:7 named " " to close
            format slot 10 of player with 399 named "&a&lHub 1" with lore "&3Connect to:||&bHub 1||&b%{_online1}%" to close then run [make player execute command "ehub"]
            format slot 11 of player with 160:7 named " " to close
            format slot 12 of player with 160:7 named " " to close
            format slot 13 of player with 399 named "&a&lHub 2" with lore "&3Connect to:||&bHub 2||&b%{_online2}%" to close then run [make player execute command "warp hub2"]
            format slot 14 of player with 160:7 named " " to close
            format slot 15 of player with 160:7 named " " to close
            format slot 16 of player with 399 named "&a&lHub 3" with lore "&3Connect to:||&bHub 3||&b%{_online3}%" to close then run [make player execute command "warp hub3"]
            format slot 17 of player with 160:7 named " " to close
            format slot 18 of player with 160:7 named " " to close
            format slot 19 of player with 160:7 named " " to close
            format slot 20 of player with 160:7 named " " to close
            format slot 21 of player with 160:7 named " " to close
            format slot 22 of player with 160:7 named " " to close
            format slot 23 of player with 160:7 named " " to close
            format slot 24 of player with 160:7 named " " to close
            format slot 25 of player with 160:7 named " " to close
            format slot 26 of player with 160:7 named " " to close
 
Status
Not open for further replies.