Paste #674: Cooldown and Target Checks!

Date: 2013/12/25 19:18:32 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


ValidTargetCheck:
  type: procedure
  definitions: target|range|region
  script:
    - ^if %target% == null ^determine false
    - ^if !<e@%target%.is_living> ^determine false
    - ^if <e@%target%.location.distance[<player.location>]> > %range% {
       - ^narrate "<&3>Your target is out of range!"
       - ^determine false }
    - ^if <e@%target%.is_npc> || <e@%target%.is_player> && <cu@misty_shores.is_within[<e@%target%.location>]> {
       - ^narrate "<red>NO PVP allowed here!"
       - ^determine false }
    - ^determine true

CooldownCheck:
  type: procedure
  definitions: scriptname
  script:
  - ^if "<s@%scriptname%.cooldown[<player>].in_seconds.is[MORE].than[1]>" {
     - ^narrate "<&b>You must wait <&2><s@%scriptname%.cooldown[<player>].formatted> <&b>before you may use this again!"
     - ^determine false }
  - ^determine true