Date: 2015/06/05 09:33:05 UTC-07:00
Type: Denizen 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
Stables Player Logging:
type: world
debug: false
events:
on player join:
- if <player.has_flag[horse]> {
- ^execute as_server "npc spawn <player.flag[horse].replace[n@]>" silent
- log "<player.name>'s horse was spawned with id <player.flag[horse].replace[n@]>" file:plugins/Denizen/logs/stablemaster.log
#- ^execute as_server "npc sel <player.flag[horse].replace[n@]>"
#- teleport <player.flag[horse].as_npc> <player.location>
}
else {
- log "<player.name> Joined the server without a horse." file:plugins/Denizen/logs/stablemaster.log
}
on player quits:
- if <player.has_flag[horse]> {
- log "<player.name>'s horse was despawned on log off with id <player.flag[horse].replace[n@]>." file:plugins/Denizen/logs/stablemaster.log
- if <player.flag[horse].as_entity.is_leashed> && <player.flag[horse].as_entity.get_leash_holder> != <player> {
- give leash qty:1
- log "Gave <player.name> a leash as their horse was leashed when they left." file:plugins/Denizen/logs/stablemaster.log
}
- ^execute as_server "npc despawn <player.flag[horse].as_npc.id>" silent
}
Stable Master:
type: assignment
debug: false
default constants:
HorseCost: 500
actions:
on assignment:
- trigger name:click state:true
- trigger name:chat state:true
interact scripts:
- 10 Stable Master Interact
Stable Master Interact:
type: interact
debug: true
steps:
1:
click trigger:
script:
- if <player.has_flag[horse]> {
- narrate format:npcchat "You already have a horse, Come buy another if it dies." targets:<player>
- disengage
}
else {
- narrate format:npcchat "Hello <player.name>." targets:<player>
- wait 0.5
- narrate format:npcchat "Would you like to buy a horse for $500?" targets:<player>
- wait 0.2
- narrate "Say <blue>Yes <white>or <blue>No<white>." targets:<player>
}
chat trigger:
1:
trigger: /Yes/, I'll take a horse.
script:
- if <player.money> < <npc.constant[HorseCost]> {
- narrate format:npcchat "You don't have enough money to buy a horse." targets:<player>
}
else {
- take money qty:<npc.constant[HorseCost]>
- create horse myhorse <player.location> save:horse
- define horse <entry[horse].created_npc>
- ^flag player horse:<entry[horse].created_npc>
- rename <player.name><&sq>s Horse' npc:%horse%
- adjust %horse% owner:<player>
- vulnerable state:true
- assignment set script:TheHorse npc:%horse%
- ^execute as_server "npc controllable" silent
- give i@leash
- define colours li@black|brown|chestnut|creamy|dark_brown|gray|white
- define styles li@white|white_dots|white_field|black_dots|none
- adjust %horse% color:<def[colours].random>|<def[styles].random>|horse
- wait 0.25
- inventory set o:saddle d:<entry[horse].inventory> slot:1
- ^execute as_server "citizens save" silent
- narrate format:npcchat "Enjoy your riding, I also gave you a leash to tie it up." targets:<player>
- log "<player.name> bought a horse @ <%horse%.id>" file:plugins/Denizen/logs/stablemaster.log
}
- disengage
2:
trigger: /No/, I don't need a horse right now.
script:
- random {
- narrate format:npcchat "Ok, come again soon!" targets:<player>
- narrate format:npcchat "No problem, you're welcome back any time!" targets:<player>
}
- disengage
TheHorse:
type: assignment
debug: true
actions:
on assignment:
- trait state:true health
on death:
- flag <npc.owner> horse:!
- if <npc.inventory.slot[2].material.name> != air {
- drop <npc.inventory.slot[2]> <npc.location>
}
- log "<npc.owner.name>'s horse died." file:plugins/Denizen/logs/stablemaster.log
- wait 1t
- narrate format:ServerChat "Unfortunately, your horse has <blue>perished<white>. <&nl> <blue>Fortunately, you can now buy <blue>another<white>!" targets:<npc.owner>
#- narrate format:ServerChat "Fortunately, you can now buy <blue>another<white>!" targets:<npc.owner>
- remove <npc>
- if <npc.owner> != <context.killer> && <context.killer.entity_type||none> == PLAYER {
- ^flag <context.killer> bounty:<t[<context.killer.as_player.has_flag[bounty]>]:<context.killer.as_player.flag[bounty].add[250]>||250>
- wait 1t
- announce format:ServerChat "<context.killer.name> killed another player's horse and gained <white>$250 <blue>bounty. Total bounty: <white>$<context.killer.as_player.flag[bounty]>" to_server
}
CallHorse:
type: command
debug: false
name: callhorse
description: Calls your horse to you!
usage: /callhorse
allowed help:
- determine <context.server.not>
script:
- if <player.has_flag[horse]> && <player.flag[horse].as_entity.is_leashed> {
- narrate format:ServerChat "Your horse is leashed and cannot be called!"
- log "<player.name> tried to call a leashed horse!" file:plugins/Denizen/logs/stablemaster.log
}
else if <player.has_flag[horse]> {
- narrate format:ServerChat "Your horse has been teleported to your location!"
- teleport <player.flag[horse].as_npc> <player.location>
- log "<player.name> called their horse." file:plugins/Denizen/logs/stablemaster.log
}
else {
- narrate format:ServerChat "You do not have a horse!" targets:<player>
- log "<player.name> attempted to call their horse but they do not have one." file:plugins/Denizen/logs/stablemaster.log
}
Armor and Leash:
type: world
debug: true
events:
on player enters vehicle:
- if <player.has_flag[horse]> {
- if <context.vehicle> == <player.flag[horse]> {
- if <player.is_sneaking> && <context.vehicle.inventory.slot[2].material.name> != air {
- give <context.vehicle.inventory.slot[2]>
- inventory clear d:<context.vehicle.inventory>
- inventory set o:saddle d:<player.flag[horse].as_npc.inventory> slot:1
- ^determine CANCELLED
}
else if <player.item_in_hand.material.name.contains[barding]> {
- inventory set o:<player.item_in_hand.material.name> d:<context.vehicle.as_npc.inventory> slot:2
- take iteminhand
- ^determine CANCELLED
}
else if <context.vehicle.is_leashed> || <player.item_in_hand.material.name> == leash {
- ^determine CANCELLED
}
}
}