Date: 2017/03/08 09:28:27 UTC-08: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
Sql_Main_Events:
type: world
debug: false
events:
on server start:
- inject Sql_Main_Update
on reload scripts:
- inject Sql_Main_Update
Sql_Main_Config:
type: yaml data
debug: false
config:
id: "denizen_sql"
Sql_Main_Update:
type: task
debug: false
script:
- if <server.has_file[/data/sql/config.yml].not> {
- yaml create id:sql_pass
- yaml id:sql_pass set Username:User
- yaml id:sql_pass set Password:MyPassword
- yaml id:sql_pass set path:localhost:3306/test
- yaml id:sql_pass "savefile:/data/sql/config.yml"
- yaml unload id:sql_pass
}
SQL_Main_Disconnect:
type: task
debug: false
script:
- define id <s@Sql_Main_Config.yaml_key[config.id]>
- sql disconnect id:<def[id]>
SQL_Main_Connect:
type: task
debug: false
script:
- define id <s@Sql_Main_Config.yaml_key[config.id]>
- if <server.list_sql_connections.contains[<def[id]>].not> {
- yaml "load:/data/sql/config.yml" id:sql_pass
#- wait 1s
- define pass <yaml[sql_pass].read[Password]>
- define user <yaml[sql_pass].read[Username]>
- define path <yaml[sql_pass].read[path]>
- yaml unload id:sql_pass
- ~sql id:<def[id]> "connect:<def[path]>" "username:<def[user]>" "password:<def[pass]>"
- if <server.list_sql_connections.contains[<def[id]>].not> {
- narrate format:util_ff "<&c>Kunne ikke oprette forbindelse... prøv igen senere..."
- determine "false" passively
- queue clear
}
}
- determine "true" passively
SQL_Main_Run:
type: task
debug: false
script:
- inject SQL_Main_Connect
# - ~sql id:updater "update:UPDATE `servers_status` SET `TPS`=20,`Players`=0,`Max`=5,`Status`=1 WHERE `Server Name` = 'Lobby'"