-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXcript.pluto
315 lines (280 loc) · 10.8 KB
/
Xcript.pluto
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
--[[
Lua made by L_una-chan (GTAO)
Discord: ip0g
]]
this_load_start_time = os.clock()
if !async_http.have_access() then
util.log("*Xcript requires internet access to run.*")
util.toast("*Xcript requires internet access to run.*")
util.stop_script()
end
-- Required Files
local missing_util_modules = false
xpcall(
function()
local Functions = require "Xcript.functions"
local funcs = require("Xcript.funcs")
local globals = require("Xcript.globals")
end,
function(err)
missing_util_modules = true
util.log("[Xcript | ERROR] Error loading Util Modules. Running the auto-updater to try to fix this..")
util.toast("Error loading Util Modules. Running the auto-updater to try to fix this..")
end
)
-- Auto Update
if !dev_vers then
local response1 = false
local updateError = false
local updateDone = false
local needsUpdate = false
local updateModules = 0
local updateProgress = 0
async_http.init("https://raw.githubusercontent.com", "/iP0G/Xcript/main/version", function(vers_result)
local repository_vers = string.gsub(vers_result, '%s+', '')
if !script_version or repository_vers != script_version or missing_util_modules then
needsUpdate = true
if missing_util_modules then
util.log("[Xcript | AUTO UPDATE] Attempting to retrieve missing files for version "..repository_vers)
else
util.log("[Xcript | AUTO UPDATE] Found new version: "..repository_vers)
end
local modules = {}
for all_modules.script_modules as module do
modules[#modules + 1] = module.path
end
for all_modules.required_modules as module do
modules[#modules + 1] = module.path
end
for all_modules.util_modules as module do
modules[#modules + 1] = module.path
end
updateModules = #modules
for modules as module do
async_http.init("https://raw.githubusercontent.com", "/iP0G/Xcript/main/lib/"..module..".pluto", function(result)
if !result then
util.log("[Xcript | ERROR] Unknown error downloading update.")
updateError = true
return
end
local file = io.open(scriptdir.."lib/"..module..".pluto", "wb")
file:write(result)
file:close()
updateProgress += 1
end,
function(err)
util.log("[Xcript | ERROR] Error getting update for module: "..module.."\nError: "..err)
updateError = true
end)
async_http.dispatch()
end
async_http.init("https://raw.githubusercontent.com", "/iP0G/Xcript/main/Xcript.pluto", function(result)
if !result then
util.log("[Xcript | ERROR] Unknown error downloading update.")
updateError = true
return
end
local file = io.open(THIS_SCRIPT_FILE, "wb")
file:write(result)
file:close()
end,
function(err)
util.log("[Xcript | ERROR] Error getting update for Xcript.pluto\nError: "..err)
updateError = true
end)
async_http.dispatch()
updateDone = true
end
response1 = true
end,
function(err)
util.log("[Xcript | ERROR] Error checking for update: "..err)
response1 = true
end)
async_http.dispatch()
while !response1 do wait() end
if needsUpdate then
while !updateDone do wait() end
while updateProgress != updateModules and !updateError do wait() end
else
log(SCRIPT_NAME.." is up to date", script_version)
end
if needsUpdate and !updateError then
wait(10)
util.log("[Xcript | AUTO UPDATE] Update Success! Restarting "..SCRIPT_NAME.."...")
util.restart_script()
return
end
end
-- Natives
util.require_natives(natives_version)
-- Store Files
if !filesystem.exists(XcriptDir) then
filesystem.mkdir(XcriptDir)
end
if !filesystem.exists(storeDir) then
filesystem.mkdir(storeDir)
end
if !filesystem.exists(storeDir.."Players") then
filesystem.mkdir(storeDir.."Players")
end
if !filesystem.exists(storeDir.."Persistent") then
filesystem.mkdir(storeDir.."Persistent")
end
if !filesystem.exists(PERSISTENT_REMOVEDCOUNT_FILE) then
local file = io.open(PERSISTENT_REMOVEDCOUNT_FILE, "w")
if file != nil then
file:write("0")
file:close()
end
end
if !filesystem.exists(PREV_EXEC_STORE) then
CreateExecStore()
end
if !filesystem.exists(PERSISTENT_MODDER_LOGFILE) then
local file = io.open(PERSISTENT_MODDER_LOGFILE, "w")
if file != nil then
file:write("0")
file:close()
end
end
-- Modules
for i, group in all_modules do
for group as module do
if !filesystem.exists(scriptdir.."lib/"..module.path..".pluto") then
local msgt = "Missing required module "..module.name.." in group '"..i.."'. "
local mext1 = "Functionality may be limited."
local mext2 = "Stopping script. | Download all required files once from https://github.com/iP0G/Xcript and the auto-updater will keep the script updated."
pluto_switch i do
case 'dev_modules':
dev_vers = false
break
case 'script_modules':
util.toast(msgt..mext1)
util.log("[Xcript | WARN]"..msgt..mext1)
break
case 'util_modules':
case 'required_modules':
util.toast(msgt..mext2)
util.log("[Xcript | ERROR]"..msgt..mext2)
wait(10)
util.stop_script()
break
case 'private_modules':
private_vers = false
break
end
end
end
end
util.execute_in_os_thread(function()
for all_modules.private_modules as module do
xpcall(
function()
local required_mod = require(module.path)
end,
function(err)
private_vers = false
end
)
end
if dev_vers then
for all_modules.dev_modules as module do
xpcall(
function()
local required_mod = require(module.path)
end,
function(err)
log("Error loading developer module: "..module.name, "ERROR")
notify("Error loading developer module: "..module.name)
dev_vers = false
end
)
end
end
for i, group in all_modules do
if i != 'dev_modules' and i != 'private_modules' and i != 'util_modules' then
for group as module do
xpcall(
function()
local required_mod = require(module.path)
end,
function(err)
local txt = "Error loading '"..i.."' module: "..module.name..". | Error: "..err
local txt1 = "Error loading '"..i.."' module: "..module.name..". Functionality may be limited. | Error: "..err
local txt2 = "Stopping script."
pluto_switch i do
case 'dev_modules':
dev_vers = false
break
case 'script_modules':
log(txt1, "WARN")
notify(txt1)
break
case 'required_modules':
log(txt, "ERROR")
notify(txt)
log(txt2, "STOP")
notify(txt2)
wait(10)
util.stop_script()
break
case 'private_modules':
private_vers = false
break
end
end
)
end
end
end
end)
-- Init
player_geo_loc_init()
if private_vers then script_version = "Private "..script_version end
if dev_vers then script_version = script_version.."-dev" end
players.dispatch_on_join()
util.keep_running()
if SCRIPT_SILENT_START then
MISC.FORCE_LIGHTNING_FLASH()
MISC.FORCE_LIGHTNING_FLASH()
else
PlaySound(hitmarker_soundfile)
draw_hitmarker()
end
if players.get_host() == players.user() then NETWORK.NETWORK_SESSION_BLOCK_JOIN_REQUESTS(false) end
GetTotalPlayersRemoved()
initModderLog()
if opt_log_total_players_removed then StartLoggingPlayersRemoved() end
local this_load_time_format = string.format("%.0f", ((os.clock() - this_load_start_time) * 1000))
log(script_version.." | Loaded in "..this_load_time_format.."ms.", "Ready")
notify(SCRIPT_NAME.." "..script_version.." | Loaded in "..this_load_time_format.."ms.")
is_starting = false
-- Shadow Start
creditslist.menu_name = "Xcript "..script_version
wait(5)
log("██╗ ██ █████╗ ██████╗ ██╗██████╗ ████████╗")
wait(5)
log("░██╳██╝██╔══██╗██╔══██╗██║██╔══██╗╚══██╔══╝")
wait(5)
log("░░███╳░██║░░╚═╝██████╔╝██║██████╔╝░░░██║░░░")
wait(5)
log("░██╳██╗██║░░██╗██╔══██╗██║██╔═══╝░░░░██║░░░")
wait(5)
log("██╗░░██╗█████╔╝██║░░██║██║██║░░░░░░░░██║░░░")
wait(5)
log("╚═╝░░╚═╝╚════╝░╚═╝░░╚═╝╚═╝╚═╝░░░░░░░░╚═╝░░░")
if ReadExecStore() then
ExecStoreCheck()
else
FirstScriptLoad()
end
populate_remembered_player_menu()
-- PrivateModule0
if private_vers then
pfunc_2()
pfunc_1()
pfunc_0()
end
shadow_starting = false
if dev_vers then log("Finished Initialization", "-- Debug") end