· 6 years ago · Jul 26, 2019, 03:22 PM
1#------------------------------------------------------------------------------------
2# MYSQL |
3# MYSQL |
4# MYSQL |
5#------------------------------------------------------------------------------------
6script options:
7 $ db url jdbc:mysql://193.37.152.198:3306/matrixmc
8 $ db username exonip
9 $ db password z!4AZAzr8jm6Taxvv6^Z$N_Tf&J7G6L5GcGaE@NecVsdFc-QeUYG!2YEJrAnk=RREceEy9VZSt
10
11options:
12 debug: true
13
14#------------------------------------------------------------------------------------
15# CREATE DATABASE |
16# CREATE DATABASE |
17# CREATE DATABASE |
18#------------------------------------------------------------------------------------
19On script load:
20 update "CREATE TABLE IF NOT EXISTS `players` (`uuid` VARCHAR(100) NOT NULL,`name` VARCHAR(255) NOT NULL,`rang` VARCHAR(255) NOT NULL,`coins` INT(20) NOT NULL,`language` INT(1) NOT NULL, `receive` INT(1) NOT NULL, `knockbackffadeathmessages` INT(1) NOT NULL, `cookies` INT(10) NOT NULL, UNIQUE INDEX `uuid` (`uuid`))"
21 update "CREATE TABLE IF NOT EXISTS `stats` (`uuid` VARCHAR(100) NOT NULL,`name` VARCHAR(255) NOT NULL DEFAULT '0',`coinsSKYPVP` VARCHAR(255) NOT NULL DEFAULT '0',`killsSKYPVP` VARCHAR(255) NOT NULL DEFAULT '0',`deathsSKYPVP` VARCHAR(255) NOT NULL DEFAULT '0',`killsKBFFA` VARCHAR(255) NOT NULL DEFAULT '0',`deathsKBFFA` VARCHAR(255) NOT NULL DEFAULT '0',`killsGUNGAME` VARCHAR(255) NOT NULL DEFAULT '0',`deathsGUNGAME` VARCHAR(255) NOT NULL DEFAULT '0',`killsFFA` VARCHAR(255) NOT NULL DEFAULT '0',`deathsFFA` VARCHAR(255) NOT NULL DEFAULT '0',`spieleMLGRUSH` VARCHAR(255) NOT NULL DEFAULT '0',`bettenMLGRUSH` VARCHAR(255) NOT NULL DEFAULT '0',`killsMLGRUSH` VARCHAR(255) NOT NULL DEFAULT '0',`deathsMLGRUSH` VARCHAR(255) NOT NULL DEFAULT '0',`winsMLGRUSH` VARCHAR(255) NOT NULL DEFAULT '0',`spieleBW` VARCHAR(255) NOT NULL DEFAULT '0',`bettenBW` VARCHAR(255) NOT NULL DEFAULT '0',`killsBW` VARCHAR(255) NOT NULL DEFAULT '0',`deathsBW` VARCHAR(255) NOT NULL DEFAULT '0',`winsBW` VARCHAR(255) NOT NULL DEFAULT '0',`spieleSW` VARCHAR(255) NOT NULL DEFAULT '0',`killsSW` VARCHAR(255) NOT NULL DEFAULT '0',`deathsSW` VARCHAR(255) NOT NULL DEFAULT '0',`winsSW` VARCHAR(255) NOT NULL DEFAULT '0',UNIQUE INDEX `uuid` (`uuid`))COLLATE='utf8mb4_general_ci'ENGINE=InnoDB;
22"
23 send "[MYSQL] Das Mysql System wurde erfolgreich geladen" to console
24
25#------------------------------------------------------------------------------------
26# INSERT FUNCTION |
27# INSERT FUNCTION |
28# INSERT FUNCTION |
29#------------------------------------------------------------------------------------
30command /dbinsert [<text>] [<text>] [<text>]:
31 permission: "*"
32 trigger:
33 set {query} to "INSERT INTO `%arg 1%` (`uuid`,`name`, `knockbackffadeathmessages`, `cookies`) VALUES ('%arg 3%', '%arg 4%')"
34 update {query}
35 if {@debug} is true:
36 send "[MYSQL] Query: %{query}%" to console
37
38#------------------------------------------------------------------------------------
39# DELETE FUNCTION |
40# DELETE FUNCTION |
41# DELETE FUNCTION |
42#------------------------------------------------------------------------------------
43command /dbdelete [<text>] [<text>]:
44 permission: "*"
45 trigger:
46 set {query} to "DELETE FROM `%arg 2%` WHERE `uuid` = '%arg 2%'"
47 update {query}
48 if {@debug} is true:
49 send "[MYSQL] Query: %{query}%" to console
50#------------------------------------------------------------------------------------
51# UPDATE FUNCTION |
52# UPDATE FUNCTION |
53# UPDATE FUNCTION |
54#------------------------------------------------------------------------------------
55
56command /dbupdate [<text>] [<text>] [<text>] [<text>]:
57 permission: "*"
58 trigger:
59 set {query} to "UPDATE `%arg 2%` SET `%arg 3%` = '%arg 4%' WHERE `uuid` = '%arg 2%'"
60 update {query}
61 if {@debug} is true:
62 send "[MYSQL] Query: %{query}%" to console
63
64
65
66
67
68
69#------------------------------------------------------------------------------------
70# GET FUNCTION |
71# GET FUNCTION |
72# GET FUNCTION |
73#------------------------------------------------------------------------------------
74command /dbget [<text>] [<text>] [<text>]:
75 permission: "*"
76 trigger:
77 set {_uuid} to arg 2
78 set {_name} to arg 3
79 set {query} to "SELECT %{_name}% FROM %arg 1% WHERE uuid = '%{_uuid}%'"
80 if {@debug} is true:
81 send "[MYSQL] Query: %{query}%" to console
82 set {_SetResult::*} to objects in column {_name} from result of query {query}
83 delete {_GetResult}
84 loop {_SetResult::*}:
85 If loop-value is set:
86 set {_GetResult} to loop-value
87 If {_GetResult} is set:
88 delete {result}
89 set {result} to {_GetResult}
90 send {_GetResult}
91 else:
92 delete {result}
93 set {result} to "ERROR"
94 send "ERROR"
95
96command /dbgetuuid [<text>] [<text>]:
97 permission: "*"
98 trigger:
99 set {query} to "SELECT uuid FROM %arg 1% WHERE name = '%arg 2%'"
100 if {@debug} is true:
101 send "[MYSQL] Query: %{query}%" to console
102 set {_SetResult::*} to objects in column "uuid" from result of query {query}
103 delete {_GetResult}
104 loop {_SetResult::*}:
105 If loop-value is set:
106 set {_GetResult} to loop-value
107 If {_GetResult} is set:
108 delete {result}
109 set {result} to {_GetResult}
110 send {_GetResult}
111 else:
112 delete {result}
113 set {result} to "ERROR"
114 send "ERROR"
115
116
117
118#------------------------------------------------------------------------------------
119# DB JOIN EVENT |
120# DB JOIN EVENT |
121# DB JOIN EVENT |
122#------------------------------------------------------------------------------------
123
124#Insert Player / Change Username in DB
125on join:
126 make console execute command "/dbget %player's uuid% name"
127 set {_uuid} to player's uuid
128 set {_name} to player's name
129 if {result} is not {_name}:
130 if {result} is "ERROR":
131 make console execute command "/dbinsert %{_uuid}% %{_name}% Spieler 100 0"
132 else:
133 make console execute command "/dbupdate %{_uuid}% name %{_name}%"
134
135
136#Variablen setzen
137on join:
138 set {uuid.%player%} to player's uuid
139
140 make console execute command "/dbget %player's uuid% rang"
141 set {rang.%player%} to {result}
142 make console execute command "/pp user %player% setrank %{rang.%player%}%"
143 make console execute command "/dbget %player's uuid% coins"
144 set {coins.%player%} to {result}
145
146 make console execute command "/dbget %player's uuid% cookies"
147 set {cookies.%player%} to {result}
148
149 make console execute command "/dbget %player's uuid% knockbackffadeathmessages"
150 set {knockbackffadeathmessages} to {result}
151
152 if {knockbackffadeathmessages} is "1":
153
154 set {knockbackffadeathmessages.%player%} to true
155
156 else:
157
158 set {knockbackffadeathmessages.%player%} to false
159
160 make console execute command "/dbget %player's uuid% receive"
161 set {receive} to {result}
162
163 if {receive} is "1":
164
165 set {receive.%player%} to true
166
167 else:
168
169 set {receive.%player%} to false
170
171 make console execute command "/dbget %player's uuid% language"
172 if {result} is 0:
173 set {language.%player%} to "german"
174 else:
175 set {language.%player%} to "english"