- mcmonkey studios -
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


TitleEdit of P#11846 - Edit of P#11845 - Edit of P#11844 - Edit of P#11843 - Untitled Paste
TypeDenizen Script
Date2014/12/05 13:31:35 UTC-08:00
ByGuest
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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
30400
# +----------------------------------
# |   Character script
# +----------------------------------


# Permissions

# char.reset
# char.name

# flags

# Characters - holds all your character names
# Character - holds your current character's name
# Gender - holds male or female
# Jobs - holds all your jobs
# Second_Jobs - holds all your second jobs
# Race - holds all your races.
# Character_Slots

# +----------------------------------
# |   Character YAML scripts
# +----------------------------------

Character_World_Script:
    type: world
    events:
        on server start:
        - run Load_Characters instantly
        - run Save_Characters delay:5m

Load_Characters:
    type: task
    Script:
      - if <server.has_file[Characters.yml]> {
        - yaml "load:Characters.yml" id:Characters
        } else {
        - yaml create id:Characters
        }
Save_Characters:
    type: task
    Script:
      - yaml "savefile:Characters.yml" id:Characters
      - announce "saving -Characters- data" to_ops
      - run Save_Characters delay:5m


# +----------------------------------
# |   Character Help
# +----------------------------------
Character_Command:
    type: command
    name: char
    description: Handles most character commands
    usage: /char <args>
    script:
      - if <context.args.size.is[EQUALS].to[0]> || <context.parsed_args.get[1]> == help {
        - narrate "<gold>--====||||  <red>Arithia Characters <gold>||||====--"
        - narrate "<gold>/char info <green>- See information about your characters."
        - narrate "<gold>/char new <green>- Create a new character."
        - narrate "<gold>/char [nickname] <green>- Switches to the character with the nickname. (12 hours cooldown)"
        - narrate "<gold>/char kill <&4>- Kill the character you're currently playing as."
# Checking if the command is run by a staff member
        - if <player.is_op> || <player.in_group[Mod]> || <player.in_group[Admin]> || <player.in_group[Owner]> {
          - narrate "<gold>--====||||  <red>Staff Character Commands <gold>||||====--"
          - if <player.has_permissions[char.name]> {
            - narrate "<gold>/char name <&lt>Character Number<&gt> <&lt>player<&gt> <&lt>New Name<&gt> <green>- set a character name."
            }
          }
        - queue clear
        }

# +----------------------------------
# |   Character Info
# +----------------------------------
      - if <context.args.get[1]> == info {
        - define Character <player.flag[Character]>
        - define Char_Number <yaml[Characters].list_keys[Players.<player.name>].find[%Character%]>
        - narrate "<red>You are currently playing as<&co> <green><player.flag[Character]>"
        - narrate "<gold>You have<&co> <green><yaml[Characters].list_keys[Players.<player.name>].size> <gold>Characters"
        - narrate "<green><yaml[Characters].list_keys[players.<Player.name>].formatted>"
        - narrate "<gold>You are using Character slot<&co> <green>%Char_Number%"
        - narrate "<gold>Race<&co> <green><yaml[Characters].list_keys[Players.<player.name>.%Character%.Race]>"
        - narrate "<gold>Gender<&co> <green><yaml[Characters].list_keys[Players.<player.name>.%Character%.Gender]>"
        - narrate "<gold>Jobs<&co> <green><yaml[Characters].list_keys[Players.<player.name>.%Character%.Jobs].formatted>"
        - queue clear
        }

# +----------------------------------
# |   Character Manual Name
# +----------------------------------
      - if <context.args.get[1]> == name {
        - if !<player.has_permissions[char.name]> {
          - narrate "<red>You don't have permission to use this command"
          - queue clear
          }
# Check if the staff member have all the correct arguments
        - if !<context.args.size.is[EQUALS].to[4]> {
          - narrate "<red>You have missing arguments. /char name <Character Number> <Player> <New Name>"
          - narrate "<red>e.g /char name 1 wonderdude Mark_Lyck"
          - queue clear
          }
# Check if they put a number for the character number.
        - if %Char_Number% matches number {
          } else {
          - narrate "Argument 2 has to be a number!"
          - narrate "<red>e.g /char name 1 wonderdude Mark_Lyck"
          - queue clear
          }
        - define Target <context.args.get[3]>
        - define Char_Number <context.args.get[2]>
        - define New_Name <context.args.get[4]>
# Check if the Target is currently playing as the character that's getting a name change.
        - if <server.match_player[%Target%].flag[Character]> == <yaml[Characters].list_keys[Players.%Target%].get[%Char_Number%]> {
          - execute as_server "removename %Target%"
          - execute as_server "name %Target% %New_Name%"
          - flag <server.match_player[%Target%]> Character:%New_Name%
          }
        - yaml id:Characters set players.%Target%[%Char_Number%]:%New_Name%
        - queue clear
        }



# +----------------------------------
# |   Character switch
# +----------------------------------
      - if <context.args.get[1]> == switch {
        - if <yaml[Characters].list_keys[Players.<player.name>].size> != 2 {
          - narrate "<red>You can only use the /char switch command if you have exactly 2 characters."
          - queue clear
          }
# Check if they are currently playing as character 2, if yes, force switch to 1, if not switch to 2.
        - if <player.flag[Character]> == <yaml[Characters].list_keys[Players.<player.name>].get[2]> {
          - execute as_player "char 1"
          } else {
          - execute as_player "char 2"
          }
        - queue clear
        }

# +----------------------------------
# |   Character Kill
# +----------------------------------
      - if <context.args.get[1]> == kill {
# Checking that they have a character to kill
        - if <yaml[Characters].list_keys[Players.<player.name>].size> == 0 || <yaml[Characters].list_keys[Players.<player.name>]> == null {
          - narrate "<red>You don't have any characters to kill"
          - queue clear
          }
        - define Character <player.flag[Character]>
        - define Char_Number <yaml[Characters].list_keys[Players.<player.name>].find[%Character%]>
        - yaml id:Characters set players.<player.name>.[%Char_Number%]:!
        - flag player Character_CD:!
        - flag player Character:!
        - if <yaml[Characters].list_keys[Players.<player.name>].size> > 0 {
          - execute as_player "char 1"
          } else {
          - execute as_player "char new"
          }
        - flag player Character_CD:!
        }


# Checking for jobs to remove
#        - execute as_server "manudelsub <player.name> <yaml[Characters].list_keys[Players.<player.name>.%Character%.Jobs].get[1]>"
#        - execute as_server "manudelsub <player.name> <yaml[Characters].list_keys[Players.<player.name>.%Character%.Jobs].get[2]>"
#        - yaml id:characters set players.<player.name>.%Character%.jobs:<-:Miner:Lumberjack:Farmer:Hunter:Engineer:Cook:Alchemist:Blacksmith:Leader
#        - if 1 > 2
#        - flag player Character_CD:!
#        - yaml id:characters set players.<player.name>.%Character%.Gender:<-:Male:Female
#        - if 1 > 2
#        - yaml id:characters set players.<player.name>.%Character%.Race:<-:Human:Elven:Barbarian:Halfling:Dwarven:Undead
#        - if 1 > 2

#players.<player.name>.character_name.jobs:|:engineer|miner or :->:miner and :->:engineer

# +----------------------------------
# |   Character New
# +----------------------------------
      - if <context.args.get[1]> == new {
        - if <player.flag[Character_Slots]> >= <yaml[Characters].list_keys[Players.<player.name>].size> {
          - narrate "<red>You don't have any open character slots, you can purchase more on the store or kill one of your current characters."
          - queue clear
          }
# Make a new character. Giving it a temporary name so we can switch to it.
        - if <yaml[Characters].list_keys[Players.<player.name>].contains[Unnamed]> {
          - narrate "You can only make 1 new character at a time"
          - queue clear
          }
# Check if they have other characters. If they do they much be playing one of them, and we can simply switch to it.
        - if <yaml[Characters].list_keys[Players.<player.name>].size> > 0 {
          - execute as_player "char <yaml[Characters].list_keys[Players.<player.name>].find[Unnamed]>"
          } else {
# If they don't have any characters, we need to create a blank one.
          - yaml id:Characters set players.<player.name>.Unnamed.Gender
          - yaml id:Characters set players.<player.name>.Unnamed.Race
          - yaml id:Characters set players.<player.name>.Unnamed.Jobs
          - yaml id:Characters set players.<player.name>.Unnamed.City
          - yaml id:Characters set players.<player.name>.Unnamed.Mamed
# Teleport the player to the first quest
          - execute as_server "tppos <player.name> 0 100 0"
          }
        - narrate "<green>You succesfully created a new Character!"
        - queue clear instantly
        }

# +----------------------------------
# |   Character manual Switch
# +----------------------------------
# Checking if trying to switch character with a valid number or a valid name
      - if <context.args.get[1]> matches number && <context.args.get[1]> <= <yaml[Characters].list_keys[Players.<player.name>].size> || <yaml[Characters].list_keys[Players.<player.name>].contains[<context.args.get[1]>]> {
        - if 1 > 2
# Checking if the player is currently playing as the character they want to switch to.
        - if <context.args.get[1]> == <player.flag[Character]> {
          - narrate "<red>You are already playing as <gold><player.flag[Character]>"
          - queue clear
          }
        - if <context.args.get[1]> matches number {
          - define Char_Number <context.args.get[1]>
          } else {
          - define Char_Number <yaml[Characters].list_keys[Players.<player.name>].find[<context.args.get[1]>]>
          }
        - flag player Character:<yaml[Characters].list_keys[Players.<player.name>].get[%Char_Number%]>
# Changing the name
        - execute as_server "removename <player.name>"
        - execute as_server "name <player.name> <player.flag[Character]>"
# Leaving the town for good measure
        - execute as_player "town leave"
# Saving the character's items in a list
        - define Char_Items_Li li@
        - foreach <player.inventory.list_contents.full> {
          - define Char_Items_Li <def[Char_Items_Li].include[%value%]>
          }
        - flag player Char_%Char_Number%_Items:%Char_Items_Li%
# Saving the character's location
        - flag player Char_%Char_Number%_Location:<player.location>

# Adding them to their town.
        - execute as_server "manuaddsub <player.name> Cora"
        - execute as_server "townyadmin town Cora add <player.name>"
        - execute as_player "accept"
# Teleporting them to their new location.
        - teleport <player.flag[Char_%Char_Number%_Location]>
# Changing the items
        - give <player.flag[Char_%Char_Number%_Items]>
# Resetting thee No-Character Group
        - execute as_server "manudelsub <player.name> No-Character"
        - execute as_server "manuaddsub <player.name> No-Character"
# Setting a 12 hour cooldown.
        - flag player Character_CD duration:12h
        - queue clear
        } else {
        - narrate "<red>You don't have a character with that name or number"
        }























#This is used to set data
#      - yaml id:characters set players.<player.name>:character_name
#      - yaml id:characters set players.<player.name>.character_name.gender:male

#This is used to load data
# This should list all the players character names (because the next "entry" is the character names)
#      - yaml <id[Characters].list_keys[players.<player.name>]>


#players.<player.name>.character_name.jobs:|:engineer|miner or :->:miner and :->:engineer
#set replaces!


#[17:06] <BlackCoyote> if you'd do entry:value
#[17:06] <BlackCoyote> and then entry:->:value2
#[17:06] <BlackCoyote> your value 1 would have been erased
#[17:06] <BlackCoyote> due to yaml restrictions
#[17:06] <BlackCoyote> sooo be sure to do entry:->:value
#[17:07] <BlackCoyote> even if it's the first one
#[17:07] <BlackCoyote> if there should be the ability to add more later

#[17:07] <BlackCoyote> wonderdude, also note that - value
#[17:07] <BlackCoyote> can't have any sub values anymore (i think)
#[17:08] <BlackCoyote> i may be wrong
#[17:08] <BlackCoyote> idk



RawRaw



Pastes made: 48631