- 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








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





dGraveyards


By BloodEko
Created: 2017/01/05 21:52:49 UTC-08:00 (7 years and 352 days ago)
Edited: 2018/12/02 11:44:01 UTC-08:00 (6 years and 21 days ago)
Likes: 2

Denizen Version: tested for 1.12, should work in other versions as well
Script Version: 1.0
Description:

When a player dies in of the defined worlds
and one/multiple graveyards exist in this
world, he will respawn on the nearest one
to him and get affected by the defined
settings(loose items/xp, message) , else
he would just respawn normally and don't
get affected by dGraveyards.


Download script | View raw script
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
21300

#---------------------------------------------+ 
#Created:      05.01.17                       |
#Last rewrite: 02.12.18                       |
#Last change:  02.12.18                       |
#                                             |
#dGraveyards by BloodEko                      |
#                                             |
#   Let your players spawn on the nearest     |
#      of your predefined locations           |
#                                             |
#   spawning: no permission required          |
#   editing graveyards: op / dGrave.admin     |
#                                             |
#---------------------------------------------+
# Usage: /dGrave                              |
#---------------------------------------------+
# When a player dies in of the defined worlds |
# and one/multiple graveyards exist in this   |
# world, he will respawn on the nearest one   |
# to him and get affected by the defined      |
# settings(loose items/xp, message) , else    |
# he would just respawn normally and don't    |
# get affected by dGraveyards.                |
#---------------------------------------------+


# This is a version script to use certain functions of the repo.
dGraveyards_config:
  type: version
  version: 1.0
  id: 124
  linkhttp://one.denizenscript.com/denizen/repo/entry/124



dGraveyards_eventHandler:
  type: world

  #Teleport the player, when he dies in these worlds.
  worlds:
  - w@Spielplatz
  - w@world
  - w@world_nether
  - w@world_end

  # KEEP_NOTHING = Loose XP and Items
  # KEEP_INV     = Loose XP
  # KEEP_LEVEL   = LOOSE ITEMS
  # KEEP_ALL     = LOOSE NOTHING
  deathType: KEEP_ALL

  #Message showed to player after respawn.
  message"You respawned on a safe place."



############################
#BELOW INTERNAL PLUGIN CODE#
#EDITS ARE NOT RECOMMED    #
############################

  events:
    on player respawns:
    - if !<player.has_flag[dGrave.respawn]> queue clear

    - define loc <server.flag[dGrave.locs.<pl.world>].sort_by_number[distance_squared[<pl.location>]].get[1]||x>
    - if <def[loc]> == x queue clear

    - narrate <script.yaml_key[message]>
    - determine <def[loc]>



    on player dies:
    - if !<script.yaml_key[worlds].contains[<pl.world>]>
      || !<server.has_flag[dGrave.locs.<pl.world>]> queue clear

    - choose <script.yaml_key[deathType]||all>:
      - case KEEP_INV:
        - determine passively KEEP_INV
      - case KEEP_LEVEL:
        - determine passively KEEP_LEVEL
      - case KEEP_ALL:
        - determine passively KEEP_INV
        - determine passively KEEP_LEVEL
      - default:
        - define 1 1

    - flag player dGrave.respawn

    #on system time hourly:
    #- ~webget "http://morphanone.space/webizen.aspx/tracker?script=124&version=<s@dGraveyards_config.yaml_key[version]||0.1>&players=<server.list_online_players.size||0>"



dGrave_CommandHandler:
  type: command
  name: dGrave
  usage: /dGrave
  description: Managing graveyard ingame
  permission: dGrave.admin
  permission message: You don't have the permission for using this command.
  script:
  - if <context.server> {
    - debug error "/dGrave is only useable ingame."
    - queue clear
    }

  - choose <context.args.get[1]||x>:
    - case set:
      - if <context.args.size> < 2 inject locally syntaxError
      - define name <c.args.get[2]||x>
      - if <server.has_flag[dGrave.name.<def[name]>]> {
        - narrate "<&4>ERROR Graveyard with the name <&6><def[name]> <&4>already exists."
        - queue clear
        }

      - narrate "<&2>Created <&2>graveyard<&6>[<def[name]>]"
      - define loc <pl.location>
      - flag server dGrave.locs.<pl.world>:->:<def[loc]>
      - flag server dGrave.name.<def[name]>:<def[loc]>
      - flag server dGrave.loc.<def[loc].escaped>:<def[name]>



    - case delete:
      - if <context.args.size> < 2 inject locally syntaxError
      - define name <c.args.get[2]||x>
      - if !<server.has_flag[dGrave.name.<def[name]>]> {
        - narrate "<&4>ERROR Graveyard with the name <&6><def[name]> <&4>doesn't exists."
        - queue clear
        }

      - narrate "<&2>Deleted <&2>graveyard<&6>[<def[name]>]"
      - define loc <server.flag[dGrave.name.<def[name]>]>
      - flag server dGrave.locs.<pl.world>:<-:<def[loc]>
      - flag server dGrave.name.<def[name]>:!
      - flag server dGrave.loc.<def[loc].escaped>:!



    - case list:
      - define list <server.list_flags[dGrave.name].remove[1]||li@>
      - define size <def[list].size||0>
      - if <def[size]> == 0 {
        - narrate "No graveyards found."
        - queue clear
        }

      - define page <context.args.get[2].as_int||1>
      - if <def[page]> !matches number {
        - narrate "<&4>ERROR <&6><def[page]> <&4>is no valid number."
        - queue clear
        }

      - define pages <def[size].div[10].round_up>
      - if <def[pages]> < <context.args.get[2]||1> {
        - narrate "<&6>There are only <&f><def[pages]> <&6>pages. Showing page <&f><&6>instead."
        - define page "1"
        }

      - if <def[size]> <= 10 {
        - narrate "-----[<&6>Graveyard page <&f>1/1]-----"
        }
        else {
        - narrate "-----[<&6>Graveyard page <&f><def[page]>/<def[pages]>]-----"
        }
      - define pageFrom <el@val[1].add[<def[page].sub[1].mul[10]>]>
      - define pageTo   <def[page].mul[10]>
      - foreach <def[list].get[<def[pageFrom]>].to[<def[pageTo]>]> {
        - narrate "   <&a><def[value].after[dGrave.name.]>"
        }




    - case tp:
      - if <context.args.size> < 2 inject locally syntaxError
      - define name <c.args.get[2]||x>
      - if !<server.has_flag[dGrave.name.<def[name]>]> {
        - narrate "<&4>ERROR Graveyard with the name <&6><def[name]> <&4>doesn't exists."
        - queue clear
        }
      - narrate "<&2>Teleporting <&2> to <&6>[<def[name]>]"
      - teleport <server.flag[dGrave.name.<def[name]>]>



    - case nearest:
      - if !<server.has_flag[dGrave.locs.<pl.world>]> {
        - narrate "No graveyards found."
        - queue clear
        }
      - define nearest <server.flag[dGrave.locs.<pl.world>].sort_by_number[distance_squared[<pl.location>]].get[1]||x>
      - define distance <def[nearest].distance[<pl.location>].round_to[2]>

      - narrate "<&2>Nearest graveyard is <&6><server.flag[dGrave.loc.<def[nearest].escaped>]> <&2>with a distance of <&6><def[distance]> <&2>blocks."
      - showfake red_wool <def[nearest]> d:5s

    - default:
      - inject locally syntaxError


  syntaxError:
  - narrate "/dGrave | set (name) | delete (name) | list | tp (name) | nearest"
  - queue clear











View History