- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleUntitled Paste
TypeDenizen Script
Date2016/10/17 18:22:59 UTC-07:00
ByMwthorn
Other
Paste
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
10800
# ClearLag - A replacement script for the plugin called ClearLagg
# By Mwthorn

# Use "/clearlag clear" to request a clear. (goes outside the normal timer)
# Use "/clearlag" to check when the next clear is inbound.

# Config Area below
ClearLag_Data:
    type: yaml data
    config:
        timer:
            # Here you can change the time for each clear and adjust it to the player-base on the server.
            # This means that there will be faster clear times if more players are online.
            # This is because; if a lot of players are online, many items could be dropped. (depends on your server gamemode)
            # The example goes like this:
            # Players 0-40 = 3m delay per clear
            # Players 40-70 = 2m delay per clear
            # Players 70-100 = 1m delay per clear
            # Players 100-1000 = 1m delay per clear
            1: 
                players: 40
                time: 3m
            2: 
                players: 70
                time: 2m
            3: 
                players: 100
                time: 1m
            4: 
                players: 1000
                time: 1m

# End of config (beyond is the actual script code, edit if you know what you are doing)

ClearLag_Events:
    type: world
    events:
        on server start:
        - run Clearlag_Event_Cycle instantly
        
        on system time hourly:
        - wait 25s
        - if <server.has_flag[ClearLag_Countdown].not> {
            - wait 5s
            - if <server.has_flag[ClearLag_Countdown].not> {
                - run Clearlag_Event_Cycle instantly
            }
        }

Clearlag_Event_Cycle:
    type: task
    debug: false
    script:
    - announce format:util_ff "<&7>Removing all ground items in 10 seconds"
    - wait 10s
    - flag server ClearLag_While
    - define size <server.list_online_players.size>
    - while <server.has_flag[ClearLag_While]> {
        - if <def[size]> < <s@ClearLag_Data.yaml_key[config.timer.<def[loop_index]>.players]> {
            - define time <s@ClearLag_Data.yaml_key[config.timer.<def[loop_index]>.time]>
            - flag server ClearLag_While:!
        }
        - wait 1t
    }
    - flag server ClearLag_Countdown duration:<def[time]>
    - inject Clearlag_Task
    - wait <def[time].as_duration.sub[10]>
    - run Clearlag_Event_Cycle instantly
    
Clearlag_Task_Forced:
    type: task
    script:
    - announce format:util_ff "<&7>Staff has requested to remove items in 3 seconds"
    - wait 3s
    - inject Clearlag_Task
    
Clearlag_Task:
    type: task
    debug: false
    script:
    - define arrows <w@world.entities.filter[name.is[EQUALS].to[ARROW]].filter[is_on_ground]>
    - define items <w@world.entities.filter[name.is[EQUALS].to[DROPPED_ITEM]]>
    - define total <def[items].include[<def[arrows]>]>
    - remove <def[total]>
    - announce format:util_ff "<&7>Removed <&e><def[total].size> <&7>items."
    
Clearlag_Commands:
    type: command
    debug: false
    name: clearlag
    aliases:
    - lagg
    - cleartime
    - cleart
    - cleartid
    - clearlagtime
    - clearlagtid
    - clearlagg
    - clearlaggtime
    script:
    - if <player.has_permission[qmod.mod].global> && <context.args.size> >= 1 {
        - if <context.args.get[1]> == "clear" {
            - inject Clearlag_Task_Forced
        }
        - queue clear
    }
    - narrate format:util_ff "Next clear lag is in <&b><server.flag[ClearLag_Countdown].expiration.formatted||0>"



RawRaw



Pastes made: 66664