-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJM36_Stand_Console.lua
221 lines (171 loc) · 7.59 KB
/
JM36_Stand_Console.lua
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
--[[ Init - Localize Functions ]]
local print <const>, string_format <const>, os_date <const>, string_find <const> = print, string.format, os.date, string.find
--[[ Init - Color Functions ]]
local ansicolors <const> = {}
do
local a=pairs;local b=tostring;local c=setmetatable;local d=string.char;local e={}function e:__tostring()return self.value end;function e:__concat(f)return b(self)..b(f)end;function e:__call(g)return self..g..ansicolors.reset end;e.__metatable={}local function h(i)return c({value=d(27)..'['..b(i)..'m'},e)end;local j={reset=0,clear=0,bright=1,dim=2,underscore=4,blink=5,reverse=7,hidden=8,black=30,red=31,green=32,yellow=33,blue=34,magenta=35,cyan=36,white=37,onblack=40,onred=41,ongreen=42,onyellow=43,onblue=44,onmagenta=45,oncyan=46,onwhite=47}for k,l in a(j)do ansicolors[k]=h(l)end
end
local ColorDefault <const> = {self=0}
local ColorBlue <const> = {self=0}
local ColorRed <const> = {self=0}
local ColorYellow <const> = {self=0}
local ColorGreen <const> = {self=0}
do
local io_write <const> = io.write
local metatable <const> = {__call = function(self) io_write(self.self) end}
local setmetatable <const> = setmetatable
local _reset <const>, _white <const>, _black <const> = ansicolors.reset.value, ansicolors.white.value, ansicolors.black.value
ColorDefault.self = string_format("%s%s%s", _reset, ansicolors.onblack.value, _white) setmetatable(ColorDefault, metatable)
ColorBlue.self = string_format("%s%s%s", _reset, ansicolors.onblue.value, _white) setmetatable(ColorBlue, metatable)
ColorRed.self = string_format("%s%s%s", _reset, ansicolors.onred.value, _white) setmetatable(ColorRed, metatable)
ColorYellow.self = string_format("%s%s%s", _reset, ansicolors.onyellow.value, _black) setmetatable(ColorYellow, metatable)
ColorGreen.self = string_format("%s%s%s", _reset, ansicolors.ongreen.value, _black) setmetatable(ColorGreen, metatable)
end
--[[ Init - Startup ]]
ColorDefault() os.execute("cls && title JM36 Stand Console")
ColorBlue() print("\n", string_format("[ JM36 Stand Console ] - %s - Wrapper Started", os_date()), "\n") ColorDefault()
--[[ What's currently running ]]
local IsOpen_GTA
--[[ Core/Loop ]]
local coroutine <const> = coroutine
local yield <const> = coroutine.yield
local wrap <const> = coroutine.wrap
local Loop <const> =
{
--[[ Logs Display ]]
wrap(function()
local string_gmatch <const> = string.gmatch
local string_split <const> = function(inputstr,sep)
local sep <const> = sep or "%s" local t <const>, n = {}, 0
for str in string_gmatch(inputstr, "([^"..sep.."]+)") do
n=n+1 t[n]=str
end
return t end
--[[ Read ini config ]]
local config_RegExHighlightRed
do
local config <const>, configFile <const> = {}, io.open("JM36_Stand_Console.ini")
if configFile then
local string_gsub <const> = string.gsub
local string_endsWith <const> = function(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
local string_startsWith <const> = function(str, start)
return str:sub(1, #start) == start
end
for line in configFile:lines() do
if not (string_startsWith(line, "[") and string_endsWith(line, "]")) then
line = string_gsub(line, "\n", "")
line = string_gsub(line, "\r", "")
if line ~= "" and string_find(line, "=") then
line = string_split(line, "=")
config[line[1]] = line[2]
end
end
end
configFile:close()
end
-- Comma Separated Values - Highlights matches from logs in red
config_RegExHighlightRed = string_split(config.RegExHighlightRed or " Marking , as modder for ,] Blocked , blocked from , crash from , is spectating , Exception ,0x, Stack trace:,GTA5%+0x,<unknown>, ---- ,---- ERROR INFORMATION BEGINS ----,Type:,Uncaught,ACCESS_VIOLATION,%(GTA5.exe%+,Stack Trace:,%(KERNEL32.DLL%+,BaseThreadInitThunk,%(ntdll.dll%+,RtlUserThreadStart,---- ERROR INFORMATION ENDS ----,Event:,EVENT:,triggered a modder detection:,Crash Event,Kick Event,Modded Event,Invite from,Freeze from,Invalid model sync by,Caught an exception%.,%.dll,%.exe, 0", ",") -- Magic Characters: ( ) . % + - * ? [ ^ $ - Magic Character Escape: %
end
local config_RegExHighlightRed <const> = config_RegExHighlightRed
local config_RegExHighlightRedNum <const> = #config_RegExHighlightRed
--[[ Read log files ]]
local logFileStand, logFileStandChat
do
local config_StandDirGTA
do
local _config_StandDirGTA <const> = io.popen("powershell [Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)")
config_StandDirGTA = string.gsub(_config_StandDirGTA:read("*a"), "\n", "").."\\Stand\\"
_config_StandDirGTA:close()
end
local io_open <const> = io.open
-- local debug_setlocal <const> = debug.setlocal
-- local self <const> = coroutine.running()
-- debug_setlocal(self, 0, 1, io_open(config_StandDirGTA.."Log.txt"))
-- debug_setlocal(self, 0, 2, io_open(config_StandDirGTA.."Chat.txt"))
logFileStand, logFileStandChat = io_open(config_StandDirGTA.."Log.txt"), io_open(config_StandDirGTA.."Chat.txt")
end
local logFileStand <const>, logFileStandChat <const> = logFileStand, logFileStandChat
--[[ Fast forward through logs (do not process) if game not running ]]
if not IsOpen_GTA then
for line in logFileStand:lines() do end
for line in logFileStandChat:lines() do end
end
--[[ Loop ]]
local lineLastPrint
local table_concat <const> = table.concat
local table_remove <const> = table.remove
local yield <const> = yield
while true do
if IsOpen_GTA then
for line in logFileStand:lines() do
if string_find(line, " from ") then
line = string_split(line, ":")
for i=4,#line do
line[i]=nil
end
line = table_concat(line, ":")
end
local lineInfo = string_split(line, "]") -- local lineInfo = string_split(line, "]")[2]
table_remove(lineInfo, 1)
lineInfo = table_concat(lineInfo, "]")
if lineInfo ~= lineLastPrint then
local Hostile
for i=1, config_RegExHighlightRedNum do
if string_find(line, config_RegExHighlightRed[i]) then
Hostile = true
break end
end
if not Hostile then
print(line)
else
ColorRed() print(line) ColorDefault()
end
lineLastPrint = lineInfo
end
end
for line in logFileStandChat:lines() do
print(line)
end
end
yield()
end
end),
--[[ Detect Game ]]
wrap(function()
local io_popen <const> = io.popen
local yield <const> = yield
while true do
local _IsOpen_GTA <const> = io_popen('tasklist | findstr GTA5.exe')
IsOpen_GTA = string_find(_IsOpen_GTA:read("*a"), "GTA5.exe")
_IsOpen_GTA:close()
yield()
end
end),
--[[ Detect Termination ]]
wrap(function()
local WasOpen_GTA = IsOpen_GTA
local yield = yield
while true do
if IsOpen_GTA ~= WasOpen_GTA then
if not IsOpen_GTA then
ColorYellow() print("\n", string_format("[ JM36 Stand Console ] - %s - Wrapper Lost Grand Theft Auto V", os_date()), "\n") ColorDefault()
ColorYellow() print("\n", string_format("[ JM36 Stand Console ] - %s - Wrapper Running Solo | Press [ENTER] To Recommence", os_date()), "\n") ColorDefault()
if not io.read() then os.exit() end
ColorGreen() print("\n", string_format("[ JM36 Stand Console ] - %s - Wrapper Resumed", os_date()), "\n") ColorDefault()
else
ColorGreen() print("\n", string_format("[ JM36 Stand Console ] - %s - Wrapper Found Grand Theft Auto V", os_date()), "\n") ColorDefault()
end
WasOpen_GTA = IsOpen_GTA
end
yield()
end
end),
}
local LoopNum <const> = #Loop
while true do
for i=1, LoopNum do
Loop[i]()
end
end