Paste #9022: Edit of P#9021 - ctf

Date: 2014/08/31 06:28:26 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


dCaptureTheFlag:
  type: world
  events:
#-----------------------------------------------------------# 
#Add Arena Info Then do Ctfreload   
#To create a arena simply do /ctfwand (ArenaName[Has to be one word]) Then select point 1 and point 2 
    on server start:
    - run restart

    on player clicks block:
    - if <player.has_flag[selectingSign]> {
      - flag global CtfSign<player.flag[signname]>:<context.location>
      - narrate "Block inside <global.flag[CtfSign]>"
      - sign type:wall_sign 1|<player.flag[signtext]> <context.location>
      - sign type:wall_sign 2|<global.flag[CurrentPlayers]>/20 <context.location>
      - flag player selectingSign:!
      } else {
      - foreach <server.list_flags[CtfSign]> {
        - if <global.flag[color]> == null {
        - flag player tcolor:Blue
        - flag global color:Red
        }
        } else if <global.flag[color]> == Red {
          - flag player tcolor:Red
          - flag global color:Blue
        } else if <global.flag[color]> == Blue {
          - flag player tcolor:Blue
          - flag global color:team
        }
      }
    on player breaks block with i@SelectorWand:
      - define ArenaCount <yaml[CtfConfig].list_keys[Arenas].size||0>
      - if <player.has_flag[BS1]> {
        - narrate "<blue>You select Blues Spawn pos1 <context.location>"
        - flag player BS1:!
        - flag player BS2
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.BlueSpawn1:<context.location> id:Ctfconfig
        - determine cancelled
        } else if <player.has_flag[BS2]> {
        - narrate "<blue>You select Blues Spawn pos2 <context.location>"
        - flag player BS2:!
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.BlueSpawn2:<context.location> id:Ctfconfig
        - flag player RS1
        - determine cancelled
        } else if <player.has_flag[RS1]> {
        - narrate "<blue>You select Reds Spawn pos1 <context.location>"
        - flag player RS1:!
        - flag player RS2
        - determine cancelled
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.RedSpawn1:<context.location> id:Ctfconfig
        } else if <player.has_flag[RS2]> {
        - narrate "<red>You select Reds Spawn pos2 <context.location>"
        - flag player RS2:!
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.RedSpawn2:<context.location> id:Ctfconfig
        - flag player ESign
        - determine cancelled
        } else if <player.has_flag[ESign]> {
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.SignLocation:<context.location> id:Ctfconfig
        - narrate "Are you happy with your selections? Say yes to Create Arena"
        - flag player confirmation
        - flag player ESign:!
        - determine cancelled
        } else if <player.has_flag[pos1s]> {
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.Pos2:<context.location> id:Ctfconfig
        - narrate "Pos2:<context.location>"
        - flag player pos1s:!
        - flag player BS1
        - determine cancelled
        } else {
        - yaml set Arenas.<def[ArenaCount].as_int>.ArenaName.Pos1:<context.location> id:Ctfconfig
        - narrate "Pos1:<context.location>"
        - flag player pos1s
        - determine cancelled
        }
    on player chats:
      - if <player.has_flag[confirmation]> {
        - if <context.message> == Yes {
          - yaml savefile:CaptureTheFlag/CTFConfig.yml id:Ctfconfig
          - narrate "You create a arena within the coords <player.flag[pos1]>, and <player.flag[pos2]> named"
          }
        }
    on resetarenas command:
      - flag global arenanumber:<yaml[Config].list_keys[ArenaCount].size||0>
    on restartarenas command:
    - run restart
    on Ctf command:
    - if <context.args.get[1].is[==].to[help]||true> {
      - narrate "/ctf SignText (signname) (text) to create wall sign"
      - narrate "/ctf admin to view admin commands"
      - determine fulfilled
      } else if <context.args.get[1].is[==].to[admin]> {
      - narrate "/ctf resetarenas  to remove all arenas"
      - narrate "/ctf CreateArena (Arenaname)  to get wand for selecting arena"
      - narrate "/ctf ViewArenas"
      } else if <context.args.get[1].is[==].to[ViewArenas]> {
      - foreach <yaml[CtfConfig].list_keys[Arenas]> {
        - narrate "Key<&co> %value% <&co> <yaml[CtfConfig].read[Arenas.%value%.ArenaName]>"
        }
      } else if <context.args.get[1].is[==].to[CreateArena]> {
      - if <context.args.get[2].to[<context.args.size>].as_string.is[==].to[null]||true> {
        - narrate "Please add a arena name"
        } else {
        - define ArenaCount <yaml[CtfConfig].list_keys[Arenas].size||0>
        - define Arenaname <context.args.get[2].to[<context.args.size>].as_string>
        - flag player arenaname:ArenaName
        - yaml set Arenas.<def[ArenaCount].add[1].as_int>.ArenaName:%Arenaname% id:Ctfconfig
        - yaml savefile:CaptureTheFlag/CTFConfig.yml id:CtfConfig
        - narrate "Created Arena <context.args[2]>"
        }
      } else if <context.args.get[1].is[==].to[RemoveArena]> {
      - if <context.args.get[2].as_int.is[LESS].than[1]||false> || <yaml[Ctfconfig].read[Arenas.<context.args.get[2].as_int>].is[==].to[null]> {
        - narrate "<gold>Ctf Invalid arena id number"
        - queue clear
        }
      - yaml set Arenas.<context.args.get[2].as_int>:! id:Ctfconfig
      - yaml create id:temp_CtfConfig
      - foreach <yaml[Ctfconfig].list_keys[Arenas]> {
        - yaml set Arenas.%loop_index%.ArenaName:<yaml[Ctfconfig].read[Arenas.%value%.ArenaName]> id:temp_CtfConfig
        }
      - yaml savefile:CaptureTheFlag/CTFConfig.yml id:temp_CtfConfig
      - yaml unload id:temp_CtfConfig
      - run restart
      } else if <context.args.get[1].is[==].to[Wand]> {
      - give i@SelectorWand
      - narrate "<gold>Select your areas"
      } else if <context.args.get[1].is[==].to[OpenArena]> {
      - if <context.args.get[2].as_int.is[LESS].than[1]||false> || <yaml[Ctfconfig].read[Arenas.<context.args.get[2].as_int>].is[==].to[null]> {
        - note cu@Arenas.<context.args.get[2].as_int>.ArenaName.Pos1|Arenas.<context.args.get[2].as_int>.ArenaName.Pos2 as:Arena<context.args.get[2].as_int>Coords
        - note cu@Arenas.<context.args.get[2].as_int>.ArenaName.BlueSpawn1|Arenas.<context.args.get[2].as_int>.ArenaName.BlueSpawn2 as:BS<context.args.get[2].as_int>Coords
        - note cu@Arenas.<context.args.get[2].as_int>.ArenaName.RedSpawn1|Arenas.<context.args.get[2].as_int>.ArenaName.RedSpawn2 as:RS<context.args.get[2].as_int>Coords
        - note cu@Arenas.<context.args.get[2].as_int>.ArenaName.SignLocation|Arenas.<context.args.get[2].as_int>.ArenaName.SignLocation as:Sign<context.args.get[2].as_int>Coords
        - narrate "Worked"
        }
      } else {
      - narrate "/ctf SignText (signname) (text) to create wall sign"
      - narrate "/ctf admin to view admin commands"
      - determine fulfilled
      }
    - determine fulfilled

restart:
  type: task
  script:
  - if <server.has_file[CaptureTheFlag/CTFConfig.yml]> { 
    - announce "<red><&lb>dCTF<&rb> <green>Loading Ctf Config File"
    - yaml load:CaptureTheFlag/CTFConfig.yml id:CtfConfig
    } else { 
    - announce "<red><&lb>dCTF<&rb> <green>Creating Ctf Config File"
    - yaml create CaptureTheFlag/CTFConfig.yml id:dbroadcast_saves
    - yaml savefile:CaptureTheFlag/CTFConfig.yml id:CtfConfig
    } 
SelectorWand:
  type: item
  material: 349
  display name: <&3>Selection_Wand
  lore: 
  - <&3>Pos1 hit/break block <&7>Pos2 Hit/break again
  no_id: false