· 6 years ago · Jun 18, 2019, 05:20 PM
1script options:
2 $ db url jdbc:mysql://127.0.01:3306/banter
3 $ db username banter
4 $ db password lUp7uGMctFGS2YmQ
5options:
6 Table: SQLVariables
7
8
9on join:
10 $ thread
11 set sql var "pn::%player's uuid%" to "%player's name%"
12 $ thread
13 set sql var "pu::%player's name%" to "%player's uuid%"
14
15on skript load:
16 update "CREATE TABLE IF NOT EXISTS `{@Table}` (`VarName` varchar(255),`VarValue` varchar(255))"
17 if {MySKQ.Tables.Alter} is not set:
18 set {MySKQ.Tables.Alter} to true
19 update "ALTER TABLE {@Table} ADD UNIQUE (VarName, VarValue)"
20
21custom effect logic for "(set|define)[ the] (global|sql) var[iable] %string%['s value] to %string%":
22 set {_Variable} to string expression 1
23 set {_Value} to string expression 2
24 set {_UUIDCheck::*} to {_Variable} split at "::"
25 if {_Variable} does not contain "pu::" or "pn::" or "key::":
26 loop {_UUIDCheck::*}:
27 sql var "pu::%loop-value%" exists
28 set {_uuid} to value of sql var "pu::%loop-value%"
29 replace all "%loop-value%" with "%{_uuid}%" in {_Variable}
30 set {_Objects::*} to objects in column "VarName" from result of query "SELECT * FROM {@Table} WHERE VarName = '%{_Variable}%'"
31 loop {_Objects::*}:
32 if loop-value is {_Variable}:
33 set {_Exists} to true
34 if {_Exists} is true:
35 update "UPDATE `{@Table}` SET `VarValue` = '%{_value}%' WHERE `{@Table}`.`VarName` ='%{_Variable}%'"
36 else:
37 update "INSERT INTO `{@Table}` (`VarName`,`VarValue`) VALUES ('%{_Variable}%', '%{_Value}%')"
38
39custom effect logic for "(delete|remove|destroy)[ the] (global|sql) var[iable] %string%":
40 set {_Variable} to string expression 1
41 set {_UUIDCheck::*} to {_Variable} split at "::"
42 if {_Variable} does not contain "pu::" or "pn::" or "key::":
43 loop {_UUIDCheck::*}:
44 sql var "pu::%loop-value%" exists
45 set {_uuid} to value of sql var "pu::%loop-value%"
46 replace all "%loop-value%" with "%{_uuid}%" in {_Variable}
47 set {_Objects::*} to objects in column "VarName" from result of query "SELECT * FROM {@Table} WHERE VarName = '%{_Variable}%'"
48 loop {_Objects::*}:
49 if loop-value is {_Variable}:
50 set {_Exists} to true
51 if {_Exists} is true:
52 update "DELETE FROM {@Table} WHERE VarName = '%{_Variable}%'"
53
54custom expression logic for "value of[ the] (global|sql) var[iable] %string%":
55 set {_Variable} to string expression 1
56 set {_UUIDCheck::*} to {_Variable} split at "::"
57 if {_Variable} does not contain "pu::" or "pn::" or "key::":
58 loop {_UUIDCheck::*}:
59 sql var "pu::%loop-value%" exists
60 set {_uuid} to value of sql var "pu::%loop-value%"
61 replace all "%loop-value%" with "%{_uuid}%" in {_Variable}
62 set {_Objects::*} to objects in column "VarValue" from result of query "SELECT * FROM {@Table} WHERE VarName = '%{_Variable}%'"
63 loop {_Objects::*}:
64 if loop-value is set:
65 set {_Value} to loop-value
66 if {_Value} is set:
67 set expression return value to "%{_Value}%"
68 else:
69 set expression return value to "<none>"
70
71custom expression logic for "[the ](global|sql) var[iable] %string% exists":
72 set {_Variable} to string expression 1
73 set {_UUIDCheck::*} to {_Variable} split at "::"
74 if {_Variable} does not contain "pu::" or "pn::" or "key::":
75 loop {_UUIDCheck::*}:
76 sql var "pu::%loop-value%" exists
77 set {_uuid} to value of sql var "pu::%loop-value%"
78 replace all "%loop-value%" with "%{_uuid}%" in {_Variable}
79 set {_Objects::*} to objects in column "VarName" from result of query "SELECT * FROM {@Table} WHERE VarName = '%{_Variable}%'"
80 loop {_Objects::*}:
81 if loop-value is {_Variable}:
82 set {_Exists} to true
83 if {_Exists} is true:
84 set expression return value to true
85 else:
86 set expression return value to false