Resource icon

Simple PvP Toggle 1.0

Hydra

Helper
Staff member
Helper
Jan 26, 2019
23
6
3
31
Nice script! Would recommend some changes though if you'd like some feedback:

In your two code blocks here:
YAML:
- if <player.has_flag[pvp_on]>:
     - flag player no_pvp
     - flag <player> pvp_on:!
     - narrate '<green>🗡 PvP disabled'
- else if <player.has_flag[no_pvp]>:
     - flag player pvp_on
     - flag <player> no_pvp:!
     - narrate '<red>🗡 PvP enabled'
- else if <player.has_flag[null]>:
     - narrate '<red>Error - see console'
     - stop
and
YAML:
- define on <context.args[1]>
- define off <context.args[1]>
- if <context.args.get[1]> == on:
    - flag player pvp_on
    - flag <player> no_pvp:!
    - narrate '<red>🗡 PvP enabled'
- if <context.args.get[1]> == off:
    - flag player no_pvp
    - flag <player> pvp_on:!
    - narrate '<green>🗡 PvP disabled'

  • <player.has_flag[null]> checks for a flag this script never checks; it might be good to leave it out if this occurs from another script of yours
  • You could replace both of these two flags with a single flag, like say named pvp_enabled - this would allow you to run a quick check like this:
YAML:
- if <player.has_flag[pvp_enabled]>:
  - narrate "<green>🗡 PvP disabled!"
  - flag <player> pvp_enabled:!
- else:
  - narrate "<green>🗡 PvP disabled!"
  - flag <player> pvp_enabled

Good simple script idea though regardless, easy way to replace a plugin that does more than you'd need!
 
  • Like
Reactions: xIdentified