Paste #16976: Points

Date: 2015/06/25 22:04:56 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Use this to give points
# - run task_points def:POINTS
task_points:
    type: task
    definitions: points
    script:
    - ^if <global.flag[point_cooldown]> queue clear
    - ^flag global point_cooldown duration:10s
    - ^if <player.flag[point_cooldown]> queue clear
    - ^flag player point_cooldown duration:10m
    - ^flag player points_waiting:+:%points%
    - ^if <player.flag[points_waiting]> < 50 {
      - ^queue clear
      }
    - ^if <player.flag[points_waiting]> < 10 {
      - ^execute as_server "enjin removepoints <player.name> <player.flag[points_waiting].abs.as_int>"
      - ^queue clear
      }
    - ^execute as_server "enjin addpoints <player.name> <player.flag[points_waiting].as_int>"
    - flag player points_waiting:0

enjin_points_listener:
    type: world
    events:
        on entity death:
        - if <context.entity.location.world.name> == TrappeChest queue clear
        - if <context.damager> !matches player queue clear
        - run enjin_entity_death delay:1t def:<context.damager>|<context.entity>
        on player death:
        - if <context.entity.location.world.name> == TrappeChest queue clear
        - run enjin_player_death delay:1t def:<context.damager>|<context.entity>
        on server start:
        - run enjin_points_loop delay:1m
enjin_entity_death:
    type: task
    script:
    - if li@creeper|skeleton|zombie contains <def[2].entity_type> {
      - run task_points as:%1% def:5
      - announce to_console "<def[1].name> gains 5 points for killing a weak mob"
      }
    - if li@silverfish|pig_zombie|spider|witch|blaze|magma_cube contains <def[2].entity_type> {
      - run task_points as:%1% def:10
      - announce to_console "<def[1].name> gains 10 points for killing a big mob"
      }
    - if <def[2].entity_type> == wither {
      - run task_points def:250 as:%1%
      - announce to_console "<def[1].name> gains 250 points for killing a wither"
      }
    - if <def[2].entity_type> == ender_dragon {
      - run task_points def:500 as:%1%
      - announce to_console "<def[1].name> gains 500 points for killing an ender_dragon"
      }
enjin_player_death:
    type: task
    script:
    - run task_points as:%2% def:-10
    - if <def[1].entity_type> == player {
      - run task_points as:%1% def:10
      - announce to_console "<def[1].name> gains 10 points for killing a player"
      }
enjin_points_loop:
    type: task
    script:
    - foreach <server.list_online_players> {
      - flag %value% time_online:++
      - if <def[value].flag[time_online]> >= 60 {
        - run task_points as:%value% def:25
        - flag %value% time_online:0
        - announce to_console "<def[value].name> gains 25 points for being online 60 minutes"
        }
      }
    - run enjin_points_loop delay:1m