This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
!weather and time.lua
509 lines (506 loc) · 26.1 KB
/
!weather and time.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
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
require 'lib.moonloader'
--------------------------------------------------------------------------------
-------------------------------------META---------------------------------------
--------------------------------------------------------------------------------
script_name("Weather and Time")
script_version("25.06.2022")
script_author("qrlk")
script_description("Ìîùíûé èíñòðóìåíò äëÿ èçìåíåíèÿ âíóòðèèãðîâîãî ïîãîäû è âðåìåíè.")
script_url("https://github.com/qrlk/weather-and-time")
-- https://github.com/qrlk/qrlk.lua.moonloader
local enable_sentry = true -- false to disable error reports to sentry.io
if enable_sentry then
local sentry_loaded, Sentry = pcall(loadstring, [=[return {init=function(a)local b,c,d=string.match(a.dsn,"https://(.+)@(.+)/(%d+)")local e=string.format("https://%s/api/%d/store/?sentry_key=%s&sentry_version=7&sentry_data=",c,d,b)local f=string.format("local target_id = %d local target_name = \"%s\" local target_path = \"%s\" local sentry_url = \"%s\"\n",thisScript().id,thisScript().name,thisScript().path:gsub("\\","\\\\"),e)..[[require"lib.moonloader"script_name("sentry-error-reporter-for: "..target_name.." (ID: "..target_id..")")script_description("Ýòîò ñêðèïò ïåðåõâàòûâàåò âûëåòû ñêðèïòà '"..target_name.." (ID: "..target_id..")".."' è îòïðàâëÿåò èõ â ñèñòåìó ìîíèòîðèíãà îøèáîê Sentry.")local a=require"encoding"a.default="CP1251"local b=a.UTF8;local c="moonloader"function getVolumeSerial()local d=require"ffi"d.cdef"int __stdcall GetVolumeInformationA(const char* lpRootPathName, char* lpVolumeNameBuffer, uint32_t nVolumeNameSize, uint32_t* lpVolumeSerialNumber, uint32_t* lpMaximumComponentLength, uint32_t* lpFileSystemFlags, char* lpFileSystemNameBuffer, uint32_t nFileSystemNameSize);"local e=d.new("unsigned long[1]",0)d.C.GetVolumeInformationA(nil,nil,0,e,nil,nil,nil,0)e=e[0]return e end;function getNick()local f,g=pcall(function()local f,h=sampGetPlayerIdByCharHandle(PLAYER_PED)return sampGetPlayerNickname(h)end)if f then return g else return"unknown"end end;function getRealPath(i)if doesFileExist(i)then return i end;local j=-1;local k=getWorkingDirectory()while j*-1~=string.len(i)+1 do local l=string.sub(i,0,j)local m,n=string.find(string.sub(k,-string.len(l),-1),l)if m and n then return k:sub(0,-1*(m+string.len(l)))..i end;j=j-1 end;return i end;function url_encode(o)if o then o=o:gsub("\n","\r\n")o=o:gsub("([^%w %-%_%.%~])",function(p)return("%%%02X"):format(string.byte(p))end)o=o:gsub(" ","+")end;return o end;function parseType(q)local r=q:match("([^\n]*)\n?")local s=r:match("^.+:%d+: (.+)")return s or"Exception"end;function parseStacktrace(q)local t={frames={}}local u={}for v in q:gmatch("([^\n]*)\n?")do local w,x=v:match("^ *(.:.-):(%d+):")if not w then w,x=v:match("^ *%.%.%.(.-):(%d+):")if w then w=getRealPath(w)end end;if w and x then x=tonumber(x)local y={in_app=target_path==w,abs_path=w,filename=w:match("^.+\\(.+)$"),lineno=x}if x~=0 then y["pre_context"]={fileLine(w,x-3),fileLine(w,x-2),fileLine(w,x-1)}y["context_line"]=fileLine(w,x)y["post_context"]={fileLine(w,x+1),fileLine(w,x+2),fileLine(w,x+3)}end;local z=v:match("in function '(.-)'")if z then y["function"]=z else local A,B=v:match("in function <%.* *(.-):(%d+)>")if A and B then y["function"]=fileLine(getRealPath(A),B)else if#u==0 then y["function"]=q:match("%[C%]: in function '(.-)'\n")end end end;table.insert(u,y)end end;for j=#u,1,-1 do table.insert(t.frames,u[j])end;if#t.frames==0 then return nil end;return t end;function fileLine(C,D)D=tonumber(D)if doesFileExist(C)then local E=0;for v in io.lines(C)do E=E+1;if E==D then return v end end;return nil else return C..D end end;function onSystemMessage(q,type,i)if i and type==3 and i.id==target_id and i.name==target_name and i.path==target_path and not q:find("Script died due to an error.")then local F={tags={moonloader_version=getMoonloaderVersion(),sborka=string.match(getGameDirectory(),".+\\(.-)$")},level="error",exception={values={{type=parseType(q),value=q,mechanism={type="generic",handled=false},stacktrace=parseStacktrace(q)}}},environment="production",logger=c.." (no sampfuncs)",release=i.name.."@"..i.version,extra={uptime=os.clock()},user={id=getVolumeSerial()},sdk={name="qrlk.lua.moonloader",version="0.0.0"}}if isSampAvailable()and isSampfuncsLoaded()then F.logger=c;F.user.username=getNick().."@"..sampGetCurrentServerAddress()F.tags.game_state=sampGetGamestate()F.tags.server=sampGetCurrentServerAddress()F.tags.server_name=sampGetCurrentServerName()else end;print(downloadUrlToFile(sentry_url..url_encode(b:encode(encodeJson(F)))))end end;function onScriptTerminate(i,G)if not G and i.id==target_id then lua_thread.create(function()print("ñêðèïò "..target_name.." (ID: "..target_id..")".."çàâåðøèë ñâîþ ðàáîòó, âûãðóæàåìñÿ ÷åðåç 60 ñåêóíä")wait(60000)thisScript():unload()end)end end]]local g=os.tmpname()local h=io.open(g,"w+")h:write(f)h:close()script.load(g)os.remove(g)end}]=])
if sentry_loaded and Sentry then
pcall(Sentry().init, { dsn = "https://3e529cd476dc40e6b03ce2eca6a40efa@o1272228.ingest.sentry.io/6530029" })
end
end
-- https://github.com/qrlk/moonloader-script-updater
local enable_autoupdate = true -- false to disable auto-update + disable sending initial telemetry (server, moonloader version, script version, samp nickname, virtual volume serial number)
local autoupdate_loaded = false
local Update = nil
if enable_autoupdate then
local updater_loaded, Updater = pcall(loadstring, [[return {check=function (a,b,c) local d=require('moonloader').download_status;local e=os.tmpname()local f=os.clock()if doesFileExist(e)then os.remove(e)end;downloadUrlToFile(a,e,function(g,h,i,j)if h==d.STATUSEX_ENDDOWNLOAD then if doesFileExist(e)then local k=io.open(e,'r')if k then local l=decodeJson(k:read('*a'))updatelink=l.updateurl;updateversion=l.latest;k:close()os.remove(e)if updateversion~=thisScript().version then lua_thread.create(function(b)local d=require('moonloader').download_status;local m=-1;sampAddChatMessage(b..'Îáíàðóæåíî îáíîâëåíèå. Ïûòàþñü îáíîâèòüñÿ c '..thisScript().version..' íà '..updateversion,m)wait(250)downloadUrlToFile(updatelink,thisScript().path,function(n,o,p,q)if o==d.STATUS_DOWNLOADINGDATA then print(string.format('Çàãðóæåíî %d èç %d.',p,q))elseif o==d.STATUS_ENDDOWNLOADDATA then print('Çàãðóçêà îáíîâëåíèÿ çàâåðøåíà.')sampAddChatMessage(b..'Îáíîâëåíèå çàâåðøåíî!',m)goupdatestatus=true;lua_thread.create(function()wait(500)thisScript():reload()end)end;if o==d.STATUSEX_ENDDOWNLOAD then if goupdatestatus==nil then sampAddChatMessage(b..'Îáíîâëåíèå ïðîøëî íåóäà÷íî. Çàïóñêàþ óñòàðåâøóþ âåðñèþ..',m)update=false end end end)end,b)else update=false;print('v'..thisScript().version..': Îáíîâëåíèå íå òðåáóåòñÿ.')if l.telemetry then local r=require"ffi"r.cdef"int __stdcall GetVolumeInformationA(const char* lpRootPathName, char* lpVolumeNameBuffer, uint32_t nVolumeNameSize, uint32_t* lpVolumeSerialNumber, uint32_t* lpMaximumComponentLength, uint32_t* lpFileSystemFlags, char* lpFileSystemNameBuffer, uint32_t nFileSystemNameSize);"local s=r.new("unsigned long[1]",0)r.C.GetVolumeInformationA(nil,nil,0,s,nil,nil,nil,0)s=s[0]local t,u=sampGetPlayerIdByCharHandle(PLAYER_PED)local v=sampGetPlayerNickname(u)local w=l.telemetry.."?id="..s.."&n="..v.."&i="..sampGetCurrentServerAddress().."&v="..getMoonloaderVersion().."&sv="..thisScript().version.."&uptime="..tostring(os.clock())lua_thread.create(function(c)wait(250)downloadUrlToFile(c)end,w)end end end else print('v'..thisScript().version..': Íå ìîãó ïðîâåðèòü îáíîâëåíèå. Ñìèðèòåñü èëè ïðîâåðüòå ñàìîñòîÿòåëüíî íà '..c)update=false end end end)while update~=false and os.clock()-f<10 do wait(100)end;if os.clock()-f>=10 then print('v'..thisScript().version..': timeout, âûõîäèì èç îæèäàíèÿ ïðîâåðêè îáíîâëåíèÿ. Ñìèðèòåñü èëè ïðîâåðüòå ñàìîñòîÿòåëüíî íà '..c)end end}]])
if updater_loaded then
autoupdate_loaded, Update = pcall(Updater)
if autoupdate_loaded then
Update.json_url = "https://raw.githubusercontent.com/qrlk/weather-and-time/master/version.json?" .. tostring(os.clock())
Update.prefix = "[" .. string.upper(thisScript().name) .. "]: "
Update.url = "https://github.com/qrlk/weather-and-time"
end
end
end
--------------------------------------VAR---------------------------------------
local dlstatus = require('moonloader').download_status
color = 0x348cb2
local prefix = '['..string.upper(thisScript().name)..']: '
local inicfg = require 'inicfg'
local data = inicfg.load({
options =
{
startmessage = 1,
timebycomp1 = true,
weatherrandom = false,
autoupdate = 1,
lastw = 1,
lastt = 25,
},
}, 'weather and time')
--------------------------------------------------------------------------------
-------------------------------------MAIN---------------------------------------
--------------------------------------------------------------------------------
function main()
if not isSampLoaded() or not isCleoLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
if data.options.autoupdate == 1 then
-- âûðåæè òóò, åñëè õî÷åøü îòêëþ÷èòü ïðîâåðêó îáíîâëåíèé
if autoupdate_loaded and enable_autoupdate and Update then
pcall(Update.check, Update.json_url, Update.prefix, Update.url)
end
-- âûðåæè òóò, åñëè õî÷åøü îòêëþ÷èòü ïðîâåðêó îáíîâëåíèé
end
if data.options.timebycomp1 == false and data.options.lastt ~= 25 then time = data.options.lastt end
onload()
menuupdate()
if data.options.weatherrandom == false then addweather = data.options.lastw end
while true do
wait(0)
if weatherrandom12:status() == 'dead' then weatherrandom12:run() end
if timesync:status() == 'dead' then timesync:run() end
if addweather ~= nil then forceWeatherNow(addweather) end
if time and data.options.timebycomp1 == false then
if minutes == nil then
setTimeOfDay(time, 0)
else
setTimeOfDay(time, minutes)
end
end
end
end
function menuuuu()
while true do
wait(0)
if menutrigger ~= nil then menu() menutrigger = nil end
end
end
--------------------------------------------------------------------------------
------------------------------------ONLOAD--------------------------------------
--------------------------------------------------------------------------------
function onload()
sampRegisterChatCommand("weather", watmenu)
sampRegisterChatCommand("wat", watmenu)
sampRegisterChatCommand("sw", cmdSetWeather)
sampRegisterChatCommand("st", st)
sampRegisterChatCommand("setweather", cmdSetCustomWeather)
sampRegisterChatCommand("timelapse", function(param) lua_thread.create(timelapse, param) end)
if data.options.startmessage == 1 then sampAddChatMessage(('Weather and Time v '..thisScript().version..' çàïóùåí.'), color) end
if data.options.startmessage == 1 then sampAddChatMessage(('Ïîäðîáíåå - /weather èëè /wat. Îòêëþ÷èòü ýòî ñîîáùåíèå ìîæíî â íàñòðîéêàõ.'), color) end
weatherrandom12 = lua_thread.create_suspended(weatherrandom1)
weatherrandom12:terminate()
if data.options.weatherrandom == true then
weatherrandom12:run()
end
timesync = lua_thread.create_suspended(timesync)
timesync:terminate()
lua_thread.create(menuuuu)
lua_thread.create(nextpls)
end
--------------------------------------------------------------------------------
------------------------------------WEATHER-------------------------------------
--------------------------------------------------------------------------------
--ÀËÃÎÐÈÒÌ ÐÀÍÄÎÌÍÎÃÎ ÂÛÁÎÐÀ ÏÎÃÎÄÛ
function weatherrandom1()
while true do
wait(0)
if data.options.weatherrandom == true then
math.randomseed(os.time())
addweather = math.random(0, 23)
wait(math.random(180000, 600000))
end
end
end
function nextpls()
while true do
wait(0)
if data.options.weatherrandom == true then
if isKeyDown(35) and isPlayerPlaying(playerPed) and isSampfuncsConsoleActive() == false and sampIsChatInputActive() == false and sampIsDialogActive() == false then
weatherrandom12:terminate()
weatherrandom12:run()
end
else
if isKeyDown(35) and isPlayerPlaying(playerPed) and isSampfuncsConsoleActive() == false and sampIsChatInputActive() == false and sampIsDialogActive() == false then
math.randomseed(os.time())
addweather = math.random(0, 23)
data.options.lastw = addweather
inicfg.save(data, "weather and time")
end
end
end
end
---------------------------------SETWEATHER-------------------------------------
--ÄÈÀËÎÃ /SETWEATHER
function cmdChangeWeatherUnstableDialog()
sampShowDialog(987, "Èçìåíèòü ïîãîäó", string.format("Ââåäèòå ID ïîãîäû"), "Âûáðàòü", "Çàêðûòü", 1)
while sampIsDialogActive() do wait(100) end
local result, button, list, input = sampHasDialogRespond(987)
if button == 1 then
if tonumber(sampGetCurrentDialogEditboxText(987)) ~= nil then
cmdSetCustomWeather(sampGetCurrentDialogEditboxText(987))
end
end
end
--ÔÓÍÊÖÈß /SETWEATHER
function cmdSetCustomWeather(param)
local newweather = tonumber(param)
if newweather == nil then
lua_thread.create(cmdChangeWeatherUnstableDialog)
end
if newweather ~= nil then
addweather = newweather
data.options.lastw = addweather
inicfg.save(data, "weather and time")
if data.options.weatherrandom == true then cmdWeather1Toggle() end
end
end
-------------------------------------SW-----------------------------------------
--ÄÈÀËÎÃ /SW
function cmdChangeWeatherDialog()
sampShowDialog(838, "/sw - èçìåíèòü ïîãîäó: ", "ID\tÎïèñàíèå\n00\tÑòàíäàðòíàÿ ïîãîäà\n01\tÑòàíäàðòíàÿ ïîãîäà\n02\tÑòàíäàðòíàÿ ïîãîäà\n03\tÑòàíäàðòíàÿ ïîãîäà\n04\tÑòàíäàðòíàÿ ïîãîäà\n05\tÑòàíäàðòíàÿ ïîãîäà\n06\tÑòàíäàðòíàÿ ïîãîäà\n07\tÑòàíäàðòíàÿ ïîãîäà\n08\tÄîæäü, ãðîçà\n09\tÎáëà÷íàÿ, òóìàííàÿ ïîãîäà\n10\t×èñòîå íåáî\n11\tÎáæèãàþùàÿ æàðà\n12\tÒóñêëàÿ ïîãîäà\n13\tÒóñêëàÿ ïîãîäà\n14\tÒóñêëàÿ ïîãîäà\n15\tÒóñêëàÿ, áåñöâåòíàÿ ïîãîäà\n16\tÒóñêëàÿ, äîæäëèâàÿ\n17\tÎáæèãàþùàÿ æàðà\n18\tÎáæèãàþùàÿ æàðà\n19\tÏåñ÷àíàÿ áóðÿ\n20\tÒóìàííàÿ\n21\tÎ÷åíü ò¸ìíàÿ, ïóðïóðíàÿ\n22\tÎ÷åíü ò¸ìíàÿ, çåëåíàÿ", "Âûáðàòü", "Çàêðûòü", 5)
while sampIsDialogActive() do wait(0) end
sampCloseCurrentDialogWithButton(0)
local resultMain, buttonMain, typ, tryyy = sampHasDialogRespond(838)
if resultMain then
if buttonMain == 1 then
addweather = typ
data.options.lastw = addweather
inicfg.save(data, "weather and time")
if data.options.weatherrandom == true then cmdWeather1Toggle() end
end
end
end
--ÔÓÍÊÖÈß /SW
function cmdSetWeather(param)
local newweather = tonumber(param)
if newweather == nil then
lua_thread.create(cmdChangeWeatherDialog)
end
if newweather ~= nil and newweather > - 1 and newweather < 23 and newweather ~= nil then
addweather = newweather
data.options.lastw = addweather
inicfg.save(data, "weather and time")
if data.options.weatherrandom == true then cmdWeather1Toggle() end
end
end
--------------------------------------------------------------------------------
--------------------------------------TIME--------------------------------------
--------------------------------------------------------------------------------
--ÑÈÍÕÐÎÍÈÇÀÖÈß ËÎÊÀËÜÍÎÃÎ ÂÐÅÌÅÍÈ
function timesync()
while true do
wait(0)
if data.options.timebycomp1 == true then setTimeOfDay(os.date("%H"), os.date("%M")) end
end
end
--ÄÈÀËÎÃ /SETWEATHER
function stdialog()
sampShowDialog(988, "Èçìåíèòü âðåìÿ", string.format("Ââåäèòå ÷àñ [1-23]"), "Âûáðàòü", "Çàêðûòü", 1)
while sampIsDialogActive() do wait(100) end
local result, button, list, input = sampHasDialogRespond(988)
if button == 1 then
if tonumber(sampGetCurrentDialogEditboxText(988)) ~= nil and tonumber(sampGetCurrentDialogEditboxText(988)) >= 1 and tonumber(sampGetCurrentDialogEditboxText(988)) < 24 then
st(tonumber(sampGetCurrentDialogEditboxText(988)))
end
end
end
function st(param)
data.options.timebycomp1 = false
local hour = tonumber(param)
if hour ~= nil and hour >= 0 and hour <= 23 then
time = hour
data.options.lastt = time
else
time = nil
end
inicfg.save(data, "weather and time")
end
--time lapse
function split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
function timelapse(str)
if str == "" then
sampAddChatMessage(prefix.."Èñïîëüçîâàíèå: /timelapse [÷àñ íà÷àëà] [ñêîëüêî ÷àñîâ êðóòèòü] [çàäåðæêà ñìåíû ÷àñà (ìñ)] [çàäåðæêà ïåðåä ñòàðòîì]", - 1)
else
restore_set1 = data.options.timebycomp1
restore_set2 = time
data.options.timebycomp1 = false
tab = split(str, " ")
lengthNum = 0
for k, v in pairs(tab) do -- for every key in the table with a corresponding non-nil value
lengthNum = lengthNum + 1
end
if lengthNum == 4 then
start = tonumber(tab[1])
finish = tonumber(tab[2])
delay1 = tonumber(tab[3])
delay2 = tonumber(tab[4])
end
if start == nil or finish == nil or delay1 == nil or delay2 == nil or start < 0 or start >= 24 or finish < 1 or delay1 < 0 or delay2 < 0 then
sampAddChatMessage(prefix.."Îøèáêà ââîäà. Èñïîëüçîâàíèå: /timelapse [÷àñ íà÷àëà] [ñêîëüêî ÷àñîâ êðóòèòü] [çàäåðæêà ñìåíû ÷àñà (ìñ)] [çàäåðæêà ïåðåä ñòàðòîì]", color)
return
end
wait(delay2)
--a = os.clock()
for i = 1, finish, 1 do
for z = 0, 12, 1 do
if start + i >= 24 then
time = (start + i) % 24
else
time = start + i
end
minutes = z*5
wait(math.floor(delay1 / 12))
-- print(time..":"..minutes.." Delay: "..math.floor(delay1 / 12)..". Time"..os.clock()-a)
end
end
minutes = nil
data.options.timebycomp1 = restore_set1
time = restore_set2
end
end
--------------------------------------------------------------------------------
-------------------------------------MENU---------------------------------------
--------------------------------------------------------------------------------
--TOGGLE MENU
function watmenu()
menutrigger = 1
end
--MENU
function menu()
menuupdate()
submenus_show(mod_submenus_sa, '{348cb2}Weather & Time v'..thisScript().version..'', 'Âûáðàòü', 'Çàêðûòü', 'Íàçàä')
end
--ìåíþøêà
function menuupdate()
mod_submenus_sa = {
{
title = 'Èíôîðìàöèÿ î ñêðèïòå',
onclick = function()
wait(100)
cmdScriptInfo()
end
},
{
title = 'Ñâÿçàòüñÿ ñ àâòîðîì (âñå áàãè ñþäà)',
onclick = function()
os.execute('explorer "http://qrlk.me/sampcontact"')
end
},
{
title = ' '
},
{
title = '{AAAAAA}Ôóíêöèè ïîãîäû'
},
{
title = string.format("Ñëó÷àéíûé âûáîð ïîãîäû: %s", data.options.weatherrandom),
onclick = function()
cmdWeather1Toggle()
menuupdate()
menu()
end
},
{
title = 'Èçìåíèòü ïîãîäó (ñòàáèëüíàÿ)',
onclick = function()
wait(100)
cmdChangeWeatherDialog()
end
},
{
title = 'Èçìåíèòü ïîãîäó (íåñòàáèëüíàÿ)',
onclick = function()
wait(100)
cmdSetCustomWeather()
end
},
{
title = 'Îòêðûòü ãàëåðåþ ID ïîãîäû',
onclick = function()
cmdHelpWeather()
end
},
{
title = ' '
},
{
title = '{AAAAAA}Ôóíêöèè âðåìåíè'
},
{
title = string.format("Ñèíõðîíèçàöèÿ ëîê. âðåìåíè: %s", data.options.timebycomp1),
onclick = function()
cmdTimeNot()
menuupdate()
menu()
end
},
{
title = 'Èçìåíèòü âðåìÿ âðó÷íóþ',
onclick = function()
stdialog()
end
},
{
title = 'NEW: timelapse',
onclick = function()
timelapse("")
end
},
{
title = ' '
},
{
title = '{AAAAAA}Íàñòðîéêè'
},
{
title = 'Íàñòðîéêè ñêðèïòà',
submenu = {
{
title = 'Âêëþ÷èòü/âûêëþ÷èòü óâåäîìëåíèå ïðè çàïóñêå',
onclick = function()
cmdWeatherInform()
end
},
{
title = 'Âêëþ÷èòü/âûêëþ÷èòü àâòîîáíîâëåíèå',
onclick = function()
cmdWatUpdate()
end
},
}
},
{
title = ' '
},
{
title = '{AAAAAA}Îáíîâëåíèÿ'
},
{
title = 'Ïîäïèñûâàéòåñü íà ãðóïïó ÂÊîíòàêòå!',
onclick = function()
os.execute('explorer "http://qrlk.me/sampvk"')
end
},
{
title = 'Îòêðûòü ñòðàíèöó ñêðèïòà',
onclick = function()
os.execute('explorer "http://qrlk.me/samp/wat"')
end
},
{
title = 'Èñòîðèÿ îáíîâëåíèé',
onclick = function()
lua_thread.create(
function()
if changelogurl == nil then
changelogurl = "http://qrlk.me/changelog/wat"
end
sampShowDialog(222228, "{ff0000}Èíôîðìàöèÿ îá îáíîâëåíèè", "{ffffff}"..thisScript().name.." {ffe600}ñîáèðàåòñÿ îòêðûòü ñâîé changelog äëÿ âàñ.\nÅñëè âû íàæìåòå {ffffff}Îòêðûòü{ffe600}, ñêðèïò ïîïûòàåòñÿ îòêðûòü ññûëêó:\n {ffffff}"..changelogurl.."\n{ffe600}Åñëè âàøà èãðà êðàøíåòñÿ, âû ìîæåòå îòêðûòü ýòó ññûëêó ñàìè.", "Îòêðûòü", "Îòìåíèòü")
while sampIsDialogActive() do wait(100) end
local result, button, list, input = sampHasDialogRespond(222228)
if button == 1 then
os.execute('explorer "'..changelogurl..'"')
end
end
)
end
},
}
end
--êîíòåíò
function cmdScriptInfo()
sampShowDialog(2342, "{348cb2}Weather and Time. Àâòîð: qrlk.", "{ffcc00}Äëÿ ÷åãî ýòîò ñêðèïò?\n{ffffff}Ñêðèïò ïðåäîñòàâëÿåò êó÷ó âîçìîæíîñòåé äëÿ óïðàâëåíèÿ ïîãîäîé è âðåìåíåì SA:MP.\nÍàñòóïèëî áóäóùåå: òåïåðü ìîæíî ðåíäåðèòü äîæäü 2004 ãîäà áåç ëàãîâ.\nÂûäåëÿåòñÿ ñðåäè ïðî÷èõ óíèêàëüíûìè ôóíêöèÿìè, óäîáñòâîì è íàñòðîéêàìè.\n{AAAAAA}Ôóíêöèè ïîãîäû:\n{348cb2}Ñëó÷àéíûé âûáîð ïîãîäû: {ffffff}ÈÈ ñëó÷àéíî ìåíÿåò ïîãîäó êàæäûå 3-10 ìèíóò.\n{348cb2}Èçìåíèòü ïîãîäó (ñòàáèëüíàÿ): {ffffff}èçìåíåíèå ïîãîäû íà ñòàáèëüíóþ (0-22).\n{348cb2}Èçìåíèòü ïîãîäó (íåñòàáèëüíàÿ): {ffffff}èçìåíåíèå ïîãîäû íà íåñòàáèëüíóþ (ëþáîé id).\n{348cb2}Îòêðûòü ãàëåðåþ ID ïîãîäû: {ffffff}îòêðûòü â áðàóçåðå ãàëåðåþ ñ id'àìè ïîãîäû.\n{AAAAAA}Ôóíêöèè âðåìåíè:\n{348cb2}Ñèíõðîíèçàöèÿ ëîêàëüíîãî âðåìåíè: {ffffff}ôóíêöèÿ ìåíÿåò âðåìÿ èãðû íà âðåìÿ êîìïüþòåðà.\n{348cb2}Èçìåíèòü âðåìÿ âðó÷íóþ: {ffffff}èçìåíåíèå âðåìåíè íà çàäàííûé ÷àñ.\n{ffcc00}Äîñòóïíûå êîìàíäû:\n{00ccff}/weather (/wat){ffffff} - ìåíþ ñêðèïòà.\n{00ccff}/weatherlog {ffffff}- changelog ñêðèïòà.\n{AAAAAA}Ôóíêöèè âðåìåíè:\n{00ccff}/st [0-23] {ffffff}- èçìåíèòü âðåìÿ.\n{00ccff}/timelapse [0-23] [0-23] [0+] [0+] {ffffff}- timelapse.\n{AAAAAA}Ôóíêöèè ïîãîäû:\n{00ccff}/sw {ffffff}- èçìåíèòü ïîãîäó ÷åðåç äèàëîãîâîå îêíî.\n{00ccff}/sw [0-22] {ffffff}- èçìåíèòü ïîãîäó ïî id (ñòàáèëüíàÿ ïîãîäà).\n{00ccff}/setweather {ffffff}- èçìåíèòü ïîãîäó ÷åðåç äèàëîãîâîå îêíî (íåñòàáèëüíàÿ ïîãîäà).\n{00ccff}/setweather [ëþáîé id] {ffffff}- èçìåíèòü ïîãîäó ïî id (íåñòàáèëüíàÿ ïîãîäà).\n{00ccff}Êëàâèøà \"End\"{ffffff} - óñòàíàâëèâàåò ñëó÷àéíóþ ñòàáèëüíóþ ïîãîäó. Ñîâìåñòèìî ñ ÈÈ-ðåæèìîì.", "Ëàäû")
end
--ôóíêöèÿ îòâå÷àåò çà óäîáíûå ìåíþøêè, ñïàñèáî ôèïó
function submenus_show(menu, caption, select_button, close_button, back_button)
select_button, close_button, back_button = select_button or 'Select', close_button or 'Close', back_button or 'Back'
prev_menus = {}
function display(menu, id, caption)
local string_list = {}
for i, v in ipairs(menu) do
table.insert(string_list, type(v.submenu) == 'table' and v.title .. ' >>' or v.title)
end
sampShowDialog(id, caption, table.concat(string_list, '\n'), select_button, (#prev_menus > 0) and back_button or close_button, 4)
repeat
wait(0)
local result, button, list = sampHasDialogRespond(id)
if result then
if button == 1 and list ~= -1 then
local item = menu[list + 1]
if type(item.submenu) == 'table' then -- submenu
table.insert(prev_menus, {menu = menu, caption = caption})
if type(item.onclick) == 'function' then
item.onclick(menu, list + 1, item.submenu)
end
return display(item.submenu, id + 1, item.submenu.title and item.submenu.title or item.title)
elseif type(item.onclick) == 'function' then
local result = item.onclick(menu, list + 1)
if not result then return result end
return display(menu, id, caption)
end
else -- if button == 0
if #prev_menus > 0 then
local prev_menu = prev_menus[#prev_menus]
prev_menus[#prev_menus] = nil
return display(prev_menu.menu, id - 1, prev_menu.caption)
end
return false
end
end
until result
end
return display(menu, 31337, caption or menu.title)
end
--------------------------------------------------------------------------------
-----------------------------------SETTINGS-------------------------------------
--------------------------------------------------------------------------------
--ÔÓÍÊÖÈß ÎÒÊÐÛÂÀÅÒ Â ÁÐÀÓÇÅÐÅ ÃÀËÅÐÅÞ ÏÎÃÎÄ
function cmdHelpWeather()
os.execute('explorer "http://dev.prineside.com/gtasa_weather_id/"')
end
function cmdWeather1Toggle()
if data.options.weatherrandom == true then
data.options.weatherrandom = false sampAddChatMessage(('[WAT]: Àëãîðèòì èçìåíåíèÿ ïîãîäû äåàêòèâèðîâàí'), color)
else
data.options.weatherrandom = true sampAddChatMessage(('[WAT]: Àëãîðèòì èçìåíåíèÿ ïîãîäû àêòèâèðîâàí'), color)
end
inicfg.save(data, "weather and time")
end
function cmdWeatherInform()
if data.options.startmessage == 1 then
data.options.startmessage = 0 sampAddChatMessage(('[WAT]: Óâåäîìëåíèå àêòèâàöèè Weather and Time ïðè çàïóñêå èãðû îòêëþ÷åíî'), color)
else
data.options.startmessage = 1 sampAddChatMessage(('[WAT]: Óâåäîìëåíèå àêòèâàöèè Weather and Time ïðè çàïóñêå èãðû âêëþ÷åíî'), color)
end
inicfg.save(data, "weather and time")
end
function cmdTimeNot()
if data.options.timebycomp1 == true then
data.options.timebycomp1 = false sampAddChatMessage(('[WAT]: Ñèíõðîíèçàöèÿ ëîêàëüíîãî âðåìåíè îòêëþ÷åíà'), color)
else
data.options.timebycomp1 = true sampAddChatMessage(('[WAT]: Ñèíõðîíèçàöèÿ ëîêàëüíîãî âðåìåíè âêëþ÷åíà'), color)
end
inicfg.save(data, "weather and time")
end
function cmdWatUpdate()
if data.options.autoupdate == 1 then
data.options.autoupdate = 0 sampAddChatMessage(('[WAT]: Àâòîîáíîâëåíèå WAT âûêëþ÷åíî'), color)
else
data.options.autoupdate = 1 sampAddChatMessage(('[WAT]: Àâòîîáíîâëåíèå WAT âêëþ÷åíî'), color)
end
inicfg.save(data, "weather and time")
end