Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

Can you create me a Minecraft Skript that toggles pvp on and off, but players with…

  1. User

    Can you create me a Minecraft Skript that toggles pvp on and off, but players with permission event.pvpbypass can attack even if pvp is disabled?

  2. Assistant

    Sure, here's a Skript that toggles PvP on and off with a permission to bypass:

    command /pvp:
        permission: pvp.toggle
        trigger:
            if {pvp} is true:
                set {pvp} to false
                broadcast "&6PvP has been &cdisabled"
            else:
                set {pvp} to true
                broadcast "&6PvP has been &aenabled"
    
    on damage of a player by another player:
        cancel event if {pvp} is false and player has no permission "event.pvpbypass"
    
    on enable:
        set {pvp} to true
    

    To explain, this Skript creates a command /pvp that toggles the variable {pvp} between true and false, and broadcasts a message to all players indicating whether PvP has been enabled or disabled.

    Then, when one player attacks another, the on damage event is triggered. If PvP is disabled ({pvp} is false) and the player doesn't have the event.pvpbypass permission, the event is cancelled, preventing any damage from being dealt.

    Finally, when the Skript is enabled (e.g. by restarting the server), {pvp} is set to true by default so that PvP is enabled.