Jump to content

Safe Spectator


kegnh

Recommended Posts

Safe Spectator is a script where when a player stops spectating, it will teleport them to wherever they started spectating from.
I personally use this for staff members who I don't want to abuse spectator gamemode, however its also safe to allow players to use it.

#  ,---.           ,---.        ,---.                       
# '   .-'  ,--,--./  .-' ,---. '   .-'  ,---.  ,---.  ,---. 
# `.  `-. ' ,-.  ||  `-,| .-. :`.  `-. | .-. || .-. :| .--' 
# .-'    |\ '-'  ||  .-'\   --..-'    || '-' '\   --.\ `--. 
# `-----'  `--`--'`--'   `----'`-----' |  |-'  `----' `---' 
#                        by kegnh#123  `--'

options:
    # Config #
    permission: safespec.use

#  __  
# |  | 
# |  | 
# |  |  WARNING: DO NOT EDIT ANYTHING BELOW THIS LINE!
# |__|           EDITING THE FILE MAY BREAK IT.
#  __  
# |__| 
# 

command /safespec:
    aliases: /spec, /gmsp, /spectate, /sspec
    permission: {@permission}
    trigger:
        if {spectate::%player's uuid%} is set:
            teleport player to {spectate::%player's uuid%}
            delete {spectate::%player's uuid%}
            set player's gamemode to survival
            send "&a&l! &fyou are no longer spectating!" to player
        else:
            set {spectate::%player's uuid%} to player's location
            set player's gamemode to spectator
            send "&a&l! &fyou are now spectating!" to player

on quit:
    if {spectate::%player's uuid%} is set:
        teleport player to {spectate::%player's uuid%}
        delete {spectate::%player's uuid%}

on gamemode change:
    if gamemode of player is not spectator:
        if {spectate::%player's uuid%} is set:
            teleport player to {spectate::%player's uuid%}
            delete {spectate::%player's uuid%}
            set player's gamemode to survival
            send "&a&l! &fyou are no longer spectating!" to player

If you like the script consider liking the post! It helps out a ton, and motivates me to work on more public releases!

  • Like 1

Minecraft Ranks
[DEFAULT] - 9th October 2020
[PRO] - 21st November 2020
[PATRON] - 27th October 2021

Proficiency
Python - 8 Years
C/C++ - 5 Years
Skript - 4 Years
Javascript - 3 Year
Java - 1 Year

Links
Discord - kegnh#1234

 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...