-
Notifications
You must be signed in to change notification settings - Fork 3
/
AdminHelper.ahk
executable file
·161 lines (115 loc) · 3.75 KB
/
AdminHelper.ahk
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
;;
;; AdminHelper.ahk
;; Author: Danil Valov <[email protected]>
;;
#UseHook
#NoEnv
#SingleInstance force
#Include %A_ScriptDir%
SetWorkingDir %A_ScriptDir%
; VersionChecker
#Include %A_ScriptDir%\scripts\VersionChecker.ahk
#Include %A_ScriptDir%\Updater.ahk
#Include %A_ScriptDir%\scripts\ConfigReader.ahk
If (FileExist(".cache\AdminHelper.ahk")) {
Run .cache\AdminHelper.ahk %1%
ExitApp
Return
}
AdminHelper := {}
AdminHelper["Modules"] := []
AdminHelper["Plugins"] := []
AdminHelper["Events"] := []
Loop, Files, %A_ScriptDir%\modules\*.*, D
{
AdminHelper["Modules"].Insert(A_LoopFileName)
}
Loop, % Config["EnabledPlugins"].MaxIndex()
{
IniRead, PluginAdminLVL, % A_ScriptDir "\plugins\" Config["EnabledPlugins"][A_Index] "\Meta.ini", Config, AdminLVL
If (Config["AdminLVL"] >= PluginAdminLVL) {
AdminHelper["Plugins"].Insert(Config["EnabledPlugins"][A_Index])
}
}
Loop, Files, %A_ScriptDir%\events\*.*, D
{
AdminHelper["Events"].Insert(A_LoopFileName)
}
MergedFile =
MergedFile .= "#UseHook`n"
MergedFile .= "#NoEnv`n"
MergedFile .= "#IfWinActive GTA:SA:MP`n"
MergedFile .= "#SingleInstance force`n"
MergedFile .= "#Include " A_ScriptDir "`n"
MergedFile .= "SetWorkingDir " A_ScriptDir "`n"
MergedFile .= "`n`n`;`; Configs`n`n"
MergedFile .= "#Include scripts\ConfigReader.ahk`n"
MergedFile .= "`n`n`;`; Libraries`n`n"
Loop, Files, %A_ScriptDir%\libraries\*.ahk, F
{
MergedFile .= "#Include libraries\" A_LoopFileName "`n"
}
MergedFile .= "`n`n`;`; Modules Funcs`n`n"
Loop, % AdminHelper["Modules"].MaxIndex()
{
ModuleName := AdminHelper["Modules"][A_Index]
If (FileExist(A_ScriptDir "\modules\" ModuleName "\Funcs.ahk")) {
MergedFile .= "#Include modules\" ModuleName "\Funcs.ahk`n"
}
}
MergedFile .= "`n`n`;`; Events Funcs`n`n"
Loop, % AdminHelper["Events"].MaxIndex()
{
EventName := AdminHelper["Events"][A_Index]
If (FileExist(A_ScriptDir "\events\" EventName "\Funcs.ahk")) {
MergedFile .= "#Include events\" EventName "\Funcs.ahk`n"
}
}
MergedFile .= "`n`n`;`; Plugins Funcs`n`n"
Loop, % AdminHelper["Plugins"].MaxIndex()
{
PluginName := AdminHelper["Plugins"][A_Index]
If (FileExist(A_ScriptDir "\plugins\" PluginName "\Funcs.ahk")) {
MergedFile .= "#Include plugins\" PluginName "\Funcs.ahk`n`n"
}
}
MergedFile .= "`n`n`;`; GUI`n`n"
MergedFile .= "#Include GUI.ahk`n"
MergedFile .= "`n`n`;`; Modules Binds`n`n"
Loop, % AdminHelper["Modules"].MaxIndex()
{
ModuleName := AdminHelper["Modules"][A_Index]
If (FileExist(A_ScriptDir "\modules\" ModuleName "\Binds.ahk")) {
MergedFile .= "#Include modules\" ModuleName "\Binds.ahk`n`n"
}
}
MergedFile .= "`n`n`;`; Binds`n`n"
MergedFile .= "#Include *i UserBinds.ahk`n"
MergedFile .= "`n`nReturn`n`n"
MergedFile .= "`n`n`;`; Modules Labels`n`n"
Loop, % AdminHelper["Modules"].MaxIndex()
{
ModuleName := AdminHelper["Modules"][A_Index]
If (FileExist(A_ScriptDir "\modules\" ModuleName "\Labels.ahk")) {
MergedFile .= "#Include modules\" ModuleName "\Labels.ahk`n`n"
}
}
MergedFile .= "`n`n`;`; Events Labels`n`n"
Loop, % AdminHelper["Events"].MaxIndex()
{
EventName := AdminHelper["Events"][A_Index]
If (FileExist(A_ScriptDir "\events\" EventName "\Labels.ahk")) {
MergedFile .= "#Include events\" EventName "\Labels.ahk`n"
}
}
MergedFile .= "`n`n`;`; Plugins Labels`n`n"
Loop, % AdminHelper["Plugins"].MaxIndex()
{
PluginName := AdminHelper["Plugins"][A_Index]
If (FileExist(A_ScriptDir "\plugins\" PluginName "\Labels.ahk")) {
MergedFile .= "#Include plugins\" PluginName "\Labels.ahk`n`n"
}
}
FileAppend, %MergedFile%`n, .cache\AdminHelper.ahk
Sleep 1000
Run .cache\AdminHelper.ahk %1%