Jump to content

Tutorial | Simple Custom Whitelist Skript ;)


CoolProgrammer

Recommended Posts

Hi bros and bro-ettes. 🙂

I've seen multiple people go around, asking "HoW tO mAkE a CuStOm WhItElIsT sKrIpT?!?!"

So today, I'm going to show you how to make a custom whitelist system with Skript.

As an example, I'll show you how to disallow a player if they have offline for 10 minutes or more.

If they've been offline for less than 10 minutes, let them in. Or else, get lost! ❤️

It's simple, trust me 😉

 

What do we need???

Command - Ofcouse we need a command for our custom whitelist system (/whitelist).

Player Connect Event - This event is called when the player successfully joins the server. Here you can kick/disallow the player for a reason. (on connect)

Player Quit Event - This event is called when the player leaves the server. Note that this is also called whenever the player is kicked from the server, e.g. causes like lag, /kick, /ban, etc. (on quit)

 

How to???

Think about it... What can be done in the "on connect" event, what can be done with the "on quit" event, and how to whitelist?

Simple! We will use "on connect" event to check if the server is whitelisted and calculate the time the players has been offline for. Disallow them if they have been offline for 10+ minutes or else let them in👍. We will use "on quit" event to set the timestamp at when they left!

3 things, 2 events, 1 command. Code them, and then pog!

 

Things to keep in mind...

Add Permission To Bypass - Oh? Aren't you disallowing ALL players if they are 10 minutes late?! What if your fellow staff members are late?! Won't that tell them to "get lost"? That's rude and not cool at all... Simply check if player has permission, and bypass if they have. (Useful if you want to allow people with a rank to bypass) 😉

 

Coding Part 😮

Let's start with the events!

Starting with on connect event first?

on connect:
    # To check if the server is whitelisted (this variable will be modified in the command code)
    if {whitelist} is set:
        # We check here if player is allowed to bypass the whitelist ;)
        if player does not have permission "whitelist.bypass":
            # Just to make sure to not let player in if they're joining late for the first time
            if {lastdisconnect::%uuid of player%} is not set:
                kick the player due to "You're late! Get lost! (jk <3)"
                stop
            # We set a temp variable {_leavetime} which will calculate and store the amount of time player has been offline
            set {_leavetime} to difference between {lastdisconnect::%uuid of player%} and now
            # Check if the player is offline for more than 10 minutes
            if {_leavetime} is greater than 10 minutes:
                # Pretty rude kick message, but okay 
                kick the player due to "You're late! Get lost! (jk <3)"
                delete {lastdisconnect::%uuid of player%}
                stop

 

Now the on quit event!

on quit:
    # Once again, just to extempt people with this permission
    if player does not have permission "whitelist.bypass":
        # This variable will store time when the player left!
        set {lastdisconnect::%uuid of player%} to now

 

Sweet! We have our 2 events in place! Now let's do deh command.

command /whitelist [<text>]:
    permission: whitelist.command
    permission message: &cNo bro, this command is not for you >:(
    trigger:
        if arg 1 is "on":
            if {whitelist} is not set:
                set {whitelist} to true
                broadcast "Whitelist was turned on! If you go offline for more than 10 minutes, you will not be able to join again! Panik"
                stop
            send "&cWhitelist is already turned on."
        else if arg 1 is "off":
            if {whitelist} is set:
                delete {whitelist}
                broadcast "Whitelist was turned off!"
                stop
            send "&cWhitelist is already turned off."
        else:
            send "&cUsage: /whitelist (on/off)"

 

Done I guess? That's it!

Okay, okay, want some more fancy stuff?

Let's make it so that if the player joins in time, it will broadcast "<player> joined within <time> of leaving! Phew."

We need another event for this. It's on join event! (Note that on join and on connect events are different)

Here!

on join:
    # Permission for extempting staff members
    if player does not have permission "whitelist.bypass":
        # Check if the last disconnect variable is set. This is to avoid the ugly <none> being put in the message >.>
        if {lastdisconnect::%uuid of player%} is set:
            # I hope you know what this is ;) (if not, go to the on connect event block)
            set {_timediff} to difference between {lastdisconnect::%uuid of player%} and now
            broadcast "&e%player% &fjoined back in &e%{_timediff}% &fafter leaving! Phew!!!"
            delete {lastdisconnect::%uuid of player%}

 

Yay! This is just an example, you can change and create your own version. I'm not a native english speaker so might have embarrassing english mistakes >.> sorry.

 

NOTE THAT I MADE THIS IN 10 MINUTES AFTER I WOKE UP. CODE QUALITY IS/MIGHT BE BAD. THE PURPOSE OF THIS IS JUST TO SHOW HOW TO MAKE A CUSTOM WHITELIST SKRIPT. THIS IS UNTESTED AND MIGHT HAVE STUPID MISTAKES AND BUGS. I WILL EDIT IT ONCE I TEST IT AND FIND BUGS.

❤️

Edited by CoolProgrammer
Spelling mistakes :)
  • Like 5

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

42 minutes ago, Vocallity said:

This is super informative, nice work. 

That was so fast! 😮

Thanks a lot ❤️ 😄

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

1 hour ago, PatentClover32 said:

This is crap

1. Read the note they left at the bottom
2. If you don't have anything nice to say don't say anything at all

Edited by AgentGamerPro

 

 

image.png.bc433d6489d70ad831075fe76809b993.png
 

Lifestealed | Minecraft Servers
 

OG [VIP] 12/26/20 - 10/27/2021
OG [PRO] 12/27/21 - 11/18/2022
OG [LEGEND] 11/18/2022 - 3/14/2023
[DEFAULT] 3/14/2023 - Present

 

Link to comment
Share on other sites

14 hours ago, PatentClover32 said:

This is crap

Ok nerd. 🤓

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

Intriguing that people cant join if they aren't online 24/7...

but good tutorial, quite informative. Love how it explains what bundles of code so the reader gains an understanding of the script

VIP since January 7th, 2020

Support since September 19th, 2020

Helper since November 3rd, 2020

Moderator since March 8th, 2021

unknown.png

5.png.e14b1bf83edf0ac2edc1bfb822177184.png

image.png.fe30b7b2c0be5a541ba4ed2187b23030.png

Link to comment
Share on other sites

38 minutes ago, TheGoose said:

Intriguing that people cant join if they aren't online 24/7...

but good tutorial, quite informative. Love how it explains what bundles of code so the reader gains an understanding of the script

Thanks Goose, I appreciate it ❤️

 

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

  • 1 month later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...