Removing a player from player count

  • 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 community!

    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.
Ummm @Donut

code_language.skript:
                    add player to {list_of_vanished_players::*}
                    set {_numGlobal} to size of all bungeecord players
                    set {_player_count} to difference between {_numGlobal} and {_vanished_player_amount}
                    set {_vanished_player_amount} to size of {list_of_vanished_players::*}
                    broadcast "%{_vanished_player_amount}%"
It said 1 for me in the chat but i was the only one online and i was vanished so it should say "0"
How do i fix this. I'm really confused I don't get this part

code_language.skript:
set {_player_count} to difference between {_numGlobal} and {_vanished_player_amount}
 
Last edited by a moderator:
You need to put line 4 before line 3 and that line just sets the player count variable to the number of players online minus the vanished players
[doublepost=1495669949,1495669864][/doublepost]Also make sure you don't forget to remove players from the vanished list and re-set the player count when they unvanish
 
@Donut I did what you said, and I also removed the variable file.

When I do /vanish, it will broadcast 1 in the chat. It should broadcast 0
What am I doing wrong?


code_language.skript:
                    add player to {list_of_vanished_players::*}
                    set {_numGlobal} to size of all bungeecord players
                    set {_vanished_player_amount} to size of {list_of_vanished_players::*}
                    set {_player_count} to difference between {_numGlobal} and {_vanished_player_amount}
                    broadcast "%{_vanished_player_amount}%"
 
You're broadcasting the vanished player amount variable which should be 1. You want to broadcast the player count variable which will be 0.
 
@Donut it says <none> when i replaced broadcast "%{_vanished_player_amount}%"
with
broadcast "%{_player_count}%"
 
Last edited by a moderator:
Why are you starting these projects when you not even know how to start?!
 
Of course you know how to start after someone helped you. Your threadopener explains itself that you had* no idea.
 
@Donut it says <none> when i replaced broadcast "%{_vanished_player_amount}%"
with
broadcast "%{_player_count}%"

Unless you have absolutely no problem solving skills, you can solve simple issues like this by logically thinking through the problem.

So let's logically think through this... first, let's look at the line where we set {_player_count} since that's the variable that we're having problems with. In this line we're setting {_player_count} to {_numGlobal} minus {_vanished_player_amount}. Now we know that {_vanished_player_amount} is being set correctly since you were previously broadcasting it. Therefore the problem must be caused by {_numGlobal}. If I were you I would broadcast {_numGlobal} and see if it's what you expect it to be. If it's not what you expect then you need to relook at the line where you set {_numGlobal} and test different code until you get the desired result.

There's a lot of trial and error involved in coding and you can't expect to have flawless code the first time you write it. If you don't want to live on these forums the rest of your life you need to learn to take the time to actually think through problems.
 
@Pikachu I'll stop posting for 2 weeks if you tell me the event/effect and what addon it needs. I can't find it.
 
Last edited by a moderator:
code_language.skript:
                    add player to {list_of_vanished_players::*}
                    set {_numGlobal} to size of all bungeecord players
                    set {_vanished_player_amount} to size of {list_of_vanished_players::*}
                    set {_amountGlobal} to {_numGlobal} parsed as an integer
                    set {_amountVanished} to {_vanished_player_amount} parsed as an integer
                    set {_player_count} to {_amountGlobal} - {_amountVanished}
                    broadcast "%{_player_count}%"

If this doesn't work, then there is definitely a problem with your variables.


You're literally wasting time and adding more posts to this thread by not telling him the specific "expression" you're talking about.
 
You're literally wasting time and adding more posts to this thread by not telling him the specific "expression" you're talking about.

The idea is that it will get him to learn to look for himself, and if he already does look for himself to know how to look better in the future
 
  • Like
Reactions: BrettPlayMC
@White Thanks. But i already figured it out before you made the script for me. Although i got 1 problem..

When you go into vanish:
code_language.skript:
                    add player to {sql_.invis::*}
                    set {numGlobal} to size of all bungeecord players
                    set {invis} to size of {sql_.invis::*}
                    remove player from {sql_.invis::*}
                    broadcast "%{numGlobal}-{invis}%"

When you come out of vanish:
code_language.skript:
                remove player from {sql_.invis::*}
                set {numGlobal} to size of all bungeecord players
                set {invis} to size of {sql_.invis::*}
                broadcast "%{numGlobal}%"

If i have two admins go into vanish, it won't take away 1 from the number.

So say if i have 2 players, 1 goes into vanish, it will say "1" in chat.
If the 2nd player goes into vanish, it would still broadcast "1"
 
You're literally wasting time and adding more posts to this thread by not telling him the specific "expression" you're talking about.

But thats the help Adrihun needs. He claims he's searching something in docs, but nobody can verify this.
So giving him hints instead of the solution is the proper help.
 
@Pikachu Are you talking about this?

Message of the day, in other words, your server name shown in server list. This expression can only be used in "on server ping" event.

Thats the only thing i found related to MOTD/player count on the page you sent me.
 
@White Thanks. But i already figured it out before you made the script for me. Although i got 1 problem..

When you go into vanish:
code_language.skript:
                    add player to {sql_.invis::*}
                    set {numGlobal} to size of all bungeecord players
                    set {invis} to size of {sql_.invis::*}
                    remove player from {sql_.invis::*}
                    broadcast "%{numGlobal}-{invis}%"

When you come out of vanish:
code_language.skript:
                remove player from {sql_.invis::*}
                set {numGlobal} to size of all bungeecord players
                set {invis} to size of {sql_.invis::*}
                broadcast "%{numGlobal}%"

If i have two admins go into vanish, it won't take away 1 from the number.

So say if i have 2 players, 1 goes into vanish, it will say "1" in chat.
If the 2nd player goes into vanish, it would still broadcast "1"

Why are you removing the player from {sql_.invis::*} when they go into vanish? I'm pretty sure that's the problem.
 
  • Like
Reactions: Adrihun
Status
Not open for further replies.