Date: 2014/08/18 22:50:55 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
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
# ---------------------------------------------------------------------------- #
# |
# |
# P e r k P o i n t S y s t e m |
# |
# A system for giving players timed access to your server |
# |
# |
# Author: |Anthony| |
# Version: 0.1 |
# dScript Version: 0.9.5-b150X |
# |
# ---------------------------------------------------------------------------- #
#
#
# ABOUT:
#
#
#
#
# USAGE:
#
#
#
#
# TODO - Future Feature Fluff:
#
#
#______________________________________________________________________________#
'PerkPointSystem':
type: world
debug: true
events:
on server start:
- run locally start instantly delay:2s
on perk command:
- inject locally commandHandler instantly
start:
- inject locally load instantly
- inject locally sqlConnection
sqlConnection:
- ^define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- ^define retry '<yaml[PerkPoints_config].read[config.MySQL.connection.retry]>'
- ^define retryDelay '<yaml[PerkPoints_config].read[config.MySQL.connection.retryDelay]>'
- ^define host '<yaml[PerkPoints_config].read[config.MySQL.connection.host]>'
- ^define port '<yaml[PerkPoints_config].read[config.MySQL.connection.port]>'
- ^define user '<yaml[PerkPoints_config].read[config.MySQL.connection.user]>'
- ^define password '<yaml[PerkPoints_config].read[config.MySQL.connection.password]>'
- ^if <server.list_sql_connections.contains[%db%]> {
- announce "<&b>PerkPoints closing existing database connection..." to_console
- sql disconnect id:%db%
- wait 2s
}
- ^announce "<&b>PerkPoints attempting to connect to the %db% database..." to_console
- ^sql id:%db% connect:%host%:%port%/%db% username:%username% password:%password%
- ^wait 2s
- ^repeat %retry% {
- if !<server.list_sql_connections.contains[%db%]> {
- announce "<&c>PerkPoints failed to connect to database!" to_console
- sql id:%db% connect:%host%:%port%/%db% username:%username% password:%password%
- wait %retryDelay%s
}
else {
- repeat stop
}
}
- ^if <server.list_sql_connections.contains[%db%]> {
- announce "<&b>PerkPoints connected to database!" to_console
}
else {
- announce "<&c>PerkPoints failed to connect to database!" to_console
- announce "<&b>PerkPoints please verify that you have created the <&a>%db%<&b> database and have configured all the MySQL connections info in the config.yml file!" to_console
- queue stop
}
createDatabase:
- announce "<&b>Creating PerkPoints database..." to_console
- define tables '<yaml[PerkPoints_config].list_keys[config.MySQL.tables]>'
- foreach %tables% {
- define table %value%
- inject locally createTable
}
- announce "<&b>PerkPoints database created!" to_console
createTable:
- define tableName '<yaml[PerkPoints_config].read[config.MySQL.tables.%table%.name]>'
- define columns '<yaml[PerkPoints_config].list_keys[config.MySQL.tables.%table%.columns]>'
- foreach %columns% {
- define column %value%
- define type '<yaml[PerkPoints_config].read[config.MySQL.tables.%table%.columns.%column%]>'
- define data '%column% %type%'
- define datalist '<def[datalist].include[%data%] || %data%>'
}
- sql id:%tableName% "update:CREATE table %table%(<def[dataList].comma_separated>);"
loadYaml:
# Loads the yaml files and generates default files if they don't exist.
- announce "<&b>Loading PerkPoints System config files..." to_console
- if !<server.has_file[PerkPoints/config.yml]>
|| !<server.has_file[PerkPoints/packages.yml]> {
- if <player> != null {
- flag <player> ConfigFileGeneratorNotify:true
- run s@ConfigFileGeneratorHelper def:PerkPoints|Configurations|false|true|false instantly
- flag <player> ConfigFileGeneratorNotify:!
}
else run s@ConfigFileGeneratorHelper def:PerkPoints|Configurations instantly
}
- if <yaml.list.contains[PerkPoints_config]> yaml unload 'id:PerkPoints_config'
- yaml 'load:PerkPoints/config.yml' 'id:PerkPoints_config'
- if <yaml.list.contains[PerkPoints_packages]> yaml unload 'id:PerkPoints_packages'
- yaml 'load:PerkPoints/packages.yml' 'id:PerkPoints_packages'
- announce "<&b>PerkPoints System config files Loaded!" to_console
################################################################################
# #
# Configuration Files #
# #
# These are the default config files. They will be used to build the default #
# config file and data storage files. #
# #
#______________________________________________________________________________#
# #
#______________________________DO_NOT_EDIT_THIS_DATA___________________________#
#______________________________________________________________________________#
'PerkPoints_Configurations':
type: task
debug: false
# Where you save this script file
scriptPath: 'scripts/PerkPoints.yml'
config:
MySQL:
connection:
retry: 3
retryDelay: 10s
host: localhost
port: 3306
username: root
password: password
database: PerkPoints
tables:
VoteLogs:
name: perks_votelog
columns:
id: int
playeruuid: varchar(255)
date: date
service: varchar(255)
PerkPoints:
name: perks_points
columns:
id: int
playeruuid: varchar(255)
pointsearned: int
pointsspent: int
pointsbalance: int
packages:
ExamplePackage:
price: 100
description: This is an example package.
hasLimit: false
limit: 3
activeImmediately: true
requireOnline: true
expires: false
expireTime: 3
commands:
- say <def[player].name> has purchased the example package.
expireCommands:
- say <def[player].name><&sq>s example package has expired.
requirePrerequisite: false
prerequisite: ''
requiredInventorySpace: 0