Solved Need help with hiding player when joining.

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

Adrihun

Member
Feb 1, 2017
368
6
0
So I have this Vanish Script, and it works, but whenever i quit & join back, I can be seen again and my Actionbar is gone. The way i know i'm still vanished, is if i type in /Vanish, it will say not vanished anymore.

So how do I make it so If i join, and i'm in vanish mode, i'm hidden again, and my actionbar comes back.

code_language.skript:
command /Vanish:
    permission: Vanish.use
    permission message: no no
    trigger:
        if {sql_.mineplex.Vanish.%player%} is true:
            loop all players:
                loop-value doesn't have permission "Vanish.see"
                add loop-value to {_Vanishto::*}
            reveal player from all players
            set {sql_.mineplex.Vanish.%player%} to false
            send "not vanishd"
            loop all players:
                loop-value doesn't have permission "Vanish.see"
                send "join %player%" to loop-player
        else:
            loop all players:
                loop-value doesn't have permission "Vanish.see"
                add loop-value to {_Vanishto::*}
                send "quit %player%" to loop-player
            hide player from {_Vanishto::*}
            set {sql_.mineplex.Vanish.%player%} to true
            send "vanishd"
            while {sql_.mineplex.Vanish.%player%} is true:
                show an action bar from "you are in vanish" to player
                wait a second
 
try:

code_language.skript:
on join:
    if {sql_.mineplex.Vanish.%player%} is true:
        hide player from {_vanishTo::*}
    else:
        stop
 
@couger44 I added it and it still didn't work, the other player can still see me.

It also happens when they quit and join back, they see me
 
code_language.skript:
        hide player from {_vanishTo::*}

{_vanishTo::*} is the problem. Nothing is actually inside the list variable because you didn't add anything in it. To fix this, make it global variable and add a player to it.
 
@White Update:

I fixed the first problem by doing this:

code_language.skript:
on join:
    if {sql_.mineplex.Vanish.%player%} is true:
        loop all players:
            loop-value doesn't have permission "vanish.see":
                add loop-value to {_VanishTo::*}
                hide player from {_VanishTo::*}
    else:
        stop

So now if i leave and join back, they can't see me.

But if they quit & join they can see me
-------------------------------------------
@White If my server has MySQL, can i make it / should i make it {sql_.vanishTo::*}
 
@White Update:

I fixed the first problem by doing this:

code_language.skript:
on join:
    if {sql_.mineplex.Vanish.%player%} is true:
        loop all players:
            loop-value doesn't have permission "vanish.see":
                add loop-value to {_VanishTo::*}
                hide player from {_VanishTo::*}
    else:
        stop

So now if i leave and join back, they can't see me.

But if they quit & join they can see me
-------------------------------------------
@White If my server has MySQL, can i make it / should i make it {sql_.vanishTo::*}

You don't have to set it global variable since this code makes wayyyy more sense than cougar44's code.
In this case, the variable, vanishTo, doesn't need to be added because you can just make the loop-player hidden for the player.
code_language.skript:
hide player from loop-player
 
I fixed the problem where if i quit & join they can see me. But if they do it, they'll see me
How do i fix that?
 
code_language.skript:
on join:
    if {sql_.mineplex.Vanish.%player%} is true:
        loop all players:
            loop-value doesn't have permission "vanish.see":
                hide player from loop-player
    if {sql_.mineplex.Vanish.%player%} is false:
        loop all players:
            if {sql_.mineplex.Vanish.%loop-player%} is true:
                hide loop-player from player
    else:
           stop
That's because you only made a condition for the joined player with vanish being invisible to other players who are already on the server. The new code includes a condition in which if the player joins the server, they won't be able to see the vanished player who is still on the server.
 
Okay thanks @White BTW do you like my code?
The code isn't horrendous, but needs more conditions/logic to further make the code work for all players. At first, the code is really confusing to read which I'm sure other people can agree on.

Another thing, please make sure you understand which variable works with what. in your older code, the variables were pretty messy.
 
  • Like
Reactions: Adrihun
@White Last Question
So If the Vanished player leaves, and joins back, they are still invisible.
How can I make it so when they quit & join, their actionbar will stay there?
 
Status
Not open for further replies.