-
Notifications
You must be signed in to change notification settings - Fork 0
/
!adblock.lua
644 lines (634 loc) · 36.1 KB
/
!adblock.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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
require "lib.moonloader"
--------------------------------------------------------------------------------
-------------------------------------META---------------------------------------
--------------------------------------------------------------------------------
script_name("ADBLOCK")
script_version("19.07.2023")
script_author("qrlk")
script_description("/ads")
script_url("https://github.com/qrlk/adblock")
-- 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://ecd9cd07f8cb4f50ad12ee54e3ffe294@o1272228.ingest.sentry.io/6529708" })
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/adblock/master/version.json?" .. tostring(os.clock())
Update.prefix = "[" .. string.upper(thisScript().name) .. "]: "
Update.url = "https://github.com/qrlk/adblock"
end
end
end
-------------------------------------var----------------------------------------
math.randomseed(os.time())
local prefix = '['..string.upper(thisScript().name)..']: '
local sampev = require 'lib.samp.events'
local dlstatus = require('moonloader').download_status
local inicfg = require 'inicfg'
local data = inicfg.load({
options =
{
toggle = true,
},
}, 'adblock')
local ffi = require('ffi')
local id = -1
local ads1 = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n"
local adnicks = {}
local adnomers = {}
local allads = {}
local coolads = {}
local blocked = 0
local adscount = 0
local LSN = 0
local SFN = 0
local LVN = 0
local color = 0x348cb2
local servers = {
["95.181.158.74"] = "Samp-Rp",
["95.181.158.63"] = "Samp-Rp",
["95.181.158.69"] = "Samp-Rp",
["95.181.158.77"] = "Samp-Rp",
["185.169.134.67"] = "Evolve-Rp",
["185.169.134.68"] = "Evolve-Rp",
["185.169.134.91"] = "Evolve-Rp",
["176.32.37.58"] = "ImperiaL",
["play.imperial-rpg.ru"] = "ImperiaL",
["54.37.142.72"] = "Advance-Rp",
["54.37.142.73"] = "Advance-Rp",
["54.37.142.74"] = "Advance-Rp",
["54.37.142.75"] = "Advance-Rp",
["51.83.207.240"] = "Diamond-Rp",
["51.75.33.152"] = "Diamond-Rp",
["51.83.207.241"] = "Diamond-Rp",
["51.75.33.153"] = "Diamond-Rp",
["51.83.207.242"] = "Diamond-Rp",
["51.83.207.243"] = "Diamond-Rp",
["51.75.33.154"] = "Diamond-Rp",
["185.169.134.3"] = "Arizona-Rp",
["185.169.134.4"] = "Arizona-Rp",
["185.169.134.43"] = "Arizona-Rp",
["185.169.134.44"] = "Arizona-Rp",
["185.169.134.45"] = "Arizona-Rp",
["185.169.134.5"] = "Arizona-Rp",
["185.169.134.59"] = "Arizona-Rp",
["185.169.134.61"] = "Arizona-Rp",
["185.169.134.107"] = "Arizona-Rp",
["185.169.134.109"] = "Arizona-Rp",
["185.169.134.166"] = "Arizona-Rp",
["185.169.134.171"] = "Arizona-Rp",
["185.169.134.172"] = "Arizona-Rp",
["185.169.134.173"] = "Arizona-Rp",
["185.169.134.83"] = "Trinity-Rp",
["185.169.134.84"] = "Trinity-Rp",
["185.169.134.85"] = "Trinity-Rp"
}
local serversNames = {
["SRP"] = "Samp-Rp",
["Samp-Rp"] = "Samp-Rp",
["Evolve"] = "Evolve-Rp",
["ImperiaL"] = "ImperiaL",
["Advance"] = "Advance-Rp",
["Diamond"] = "Diamond-Rp",
["Arizona"] = "Arizona-Rp",
["Trinity"] = "Trinity-Rp"
}
function getModeByServerName(sname)
for k, v in pairs(serversNames) do
if string.find(sname, k, 1, true) then
return v
end
end
end
-------------------------------------MAIN---------------------------------------
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
while sampGetCurrentServerAddress() == nil do wait(100) end
-- âûðåæè òóò, åñëè õî÷åøü îòêëþ÷èòü ïðîâåðêó îáíîâëåíèé
if autoupdate_loaded and enable_autoupdate and Update then
pcall(Update.check, Update.json_url, Update.prefix, Update.url)
end
-- âûðåæè òóò, åñëè õî÷åøü îòêëþ÷èòü ïðîâåðêó îáíîâëåíèé
while sampGetCurrentServerName() == "SA-MP" do wait(100) end
mode = servers[sampGetCurrentServerAddress()] or getModeByServerName(sampGetCurrentServerName())
-- âûðåçàòü òóò, åñëè õî÷åøü îòêëþ÷èòü ñîîáùåíèå ïðè âõîäå â èãðó
if mode ~= nil then
sampAddChatMessage(("ADBLOCK v"..thisScript().version.." successfully loaded! /ads - show hidden ads! /tads - toggle! Mode: "..mode..". <> by qrlk."), color)
else
sampAddChatMessage(("ADBLOCK v"..thisScript().version.." not loaded! Reason: unknown server. <> by qrlk."), 0xFF4500)
end
-- âûðåçàòü òóò, åñëè õî÷åøü îòêëþ÷èòü ñîîáùåíèå ïðè âõîäå â èãðó
if mode == nil then thisScript():unload() end
sampRegisterChatCommand("ads", ads)
sampRegisterChatCommand("tads",
function()
data.options.toggle = not data.options.toggle
inicfg.save(data, "adblock")
sampAddChatMessage("Ñêðûòèå îáúÿâ â ÷àòå: "..tostring(data.options.toggle), 0x348cb2)
end
)
while true do
wait(0)
if Enable and (mode == "Samp-Rp" or mode == "Evolve-Rp") then
sampSendChat("/ad "..floodtext)
wait(1100)
end
end
end
--------------------------------------------------------------------------------
-----------------------------ÐÅÆÈÌÛ ÏÎÄ ÊÀÆÄÛÉ ÑÅÐÂÅÐ---------------------------
--------------------------------------------------------------------------------
--samp-rp
function samprp(text)
trigger = false
--sampAddChatMessage(text, - 1) -- ýòî âûâîäèò â ÷àò îáúÿâó, êîòîðóþ ñêðèïò âíîñèò â äèàëîã
for i = #allads - 25, #allads do
if allads[i] ~= nil and text == allads[i] then trigger = true blocked = blocked + 1 break end
end
if trigger == false then
id = id + 1
allads[id] = text
adtext, adnick, adnomer = string.match(text, " Îáúÿâëåíèå: (.+) Ïðèñëàë.*: (.+)%. Òåë: (%d+)")
if adnick == nil then
adtext = "ERROR"
adnick = "ERROR"
adnomer = "ERROR"
end
adnicks[id] = adnick
adnomers[id] = adnomer
if string.find(string.rlower(adtext), "êóïëþ") then color = "{FFFF00}" end
if string.find(string.rlower(adtext), "ïðîäàì") then color = "{00FF00}" end
if string.find(string.rlower(adtext), "ñòî") then color = "{800080}" end
if string.find(string.rlower(adtext), "ñòàíöèÿ") then color = "{800080}" end
if string.find(string.rlower(adtext), "ìàñòåðñêàÿ") then color = "{800080}" end
if string.find(string.rlower(adtext), "ôåðìà") then color = "{800080}" end
if string.find(string.rlower(adtext), "farm") then color = "{800080}" end
if string.find(string.rlower(adtext), "êàçèíî") then color = "{FF0000}" end
if not string.find(string.rlower(adtext), "ôåðìà") and not string.find(string.rlower(adtext), "farm") and not string.find(string.rlower(adtext), "ñòî") and not string.find(string.rlower(adtext), "ñòàíöèÿ") and not string.find(string.rlower(adtext), "ìàñòåðñêàÿ") and not string.find(string.rlower(adtext), "ïðîäàì") and not string.find(string.rlower(adtext), "êóïëþ") and not string.find(string.rlower(adtext), "êàçèíî") then color = "{00FFFF}" end
coolads[id] = color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"
end
trigger = false
end
--advance-rp
function advancerp(text)
trigger = false
--sampAddChatMessage(text, - 1) -- ýòî âûâîäèò â ÷àò îáúÿâó, êîòîðóþ ñêðèïò âíîñèò â äèàëîã
if not string.find(text, "Îòïðàâèëà") then
for i = #allads - 25, #allads do
if allads[i] ~= nil and text == allads[i] then trigger = true blocked = blocked + 1 break end
end
if trigger == false then
id = id + 1
allads[id] = text
adtext = string.sub(text, 6, string.find(text, " | Îòïðàâèë ", 1, true) - 1)
adnick = string.sub(text, string.find(text, "| Îòïðàâèë ", 1, true) + 11, string.find(text, "òåë.", 1, true) - 3)
adnick = string.sub(adnick, 1, string.find(adnick, "[", 1, true) - 1)
adnomer = string.sub(text, string.find(text, "(òåë. ", 1, true) + 6, string.len(text) - 1)
adnicks[id] = adnick
adnomers[id] = adnomer
if string.find(string.rlower(adtext), "êóïëþ") then color = "{FFFF00}" end
if string.find(string.rlower(adtext), "ïðîäàì") then color = "{00FF00}" end
if not string.find(string.rlower(adtext), "ïðîäàì") and not string.find(string.rlower(adtext), "êóïëþ") then color = "{00FFFF}" end
coolads[id] = color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"
end
trigger = false
end
end
--diamond-rp
function diamondrp(text)
trigger = false
--sampAddChatMessage(text, - 1) -- ýòî âûâîäèò â ÷àò îáúÿâó, êîòîðóþ ñêðèïò âíîñèò â äèàëîã
if not string.find(text, "Îòïðàâèëà") then
for i = #allads - 25, #allads do
if allads[i] ~= nil and text == allads[i] then trigger = true blocked = blocked + 1 break end
end
if trigger == false then
id = id + 1
allads[id] = text
adtext = string.sub(text, 1, string.find(text, " Îòïðàâèòåëü:", 1, true) - 1)
adnick = string.sub(text, string.find(text, " Îòïðàâèòåëü:", 1, true) + 14, string.find(text, "òåë.", string.len(text) - 15, true) - 3)
adnomer = string.sub(text, string.find(text, "(òåë. ", 1, true) + 6, string.len(text) - 1)
adnicks[id] = adnick
adnomers[id] = adnomer
if string.find(string.rlower(adtext), "êóïëþ") then color = "{FFFF00}" end
if string.find(string.rlower(adtext), "ïðîäàì") then color = "{00FF00}" end
if not string.find(string.rlower(adtext), "ïðîäàì") and not string.find(string.rlower(adtext), "êóïëþ") then color = "{00FFFF}" end
coolads[id] = color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"
end
trigger = false
end
end
--arizona-rp
function arizonarp(text)
trigger = false
--sampAddChatMessage(text, - 1) -- ýòî âûâîäèò â ÷àò îáúÿâó, êîòîðóþ ñêðèïò âíîñèò â äèàëîã
if not string.find(text, "Îòïðàâèëà") then
for i = #allads - 25, #allads do
if allads[i] ~= nil and text == allads[i] then trigger = true blocked = blocked + 1 break end
end
if trigger == false then
id = id + 1
allads[id] = text
adtext, adnick, adnomer = string.match(text, "Îáúÿâëåíèå: (.+) Îòïðàâèë: (%g+)%[%d+%] Òåë. (%d+)")
adnicks[id] = adnick
adnomers[id] = adnomer
if string.find(string.rlower(adtext), "êóïëþ") then color = "{FFFF00}" end
if string.find(string.rlower(adtext), "ïðîäàì") then color = "{00FF00}" end
if not string.find(string.rlower(adtext), "ïðîäàì") and not string.find(string.rlower(adtext), "êóïëþ") then color = "{00FFFF}" end
coolads[id] = color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"
end
trigger = false
end
end
--trinity-rp
function trinityrp(text)
trigger = false
--sampAddChatMessage(text, - 1) -- ýòî âûâîäèò â ÷àò îáúÿâó, êîòîðóþ ñêðèïò âíîñèò â äèàëîã
if not string.find(text, "Òåë.") then
adtext = string.sub(text, string.find(text, "]", 1, true) + 10, string.len(text))
else
adnick = string.sub(text, string.find(text, "{ffffff}", 1, true) + 8, string.find(text, "{EEA9B8} Òåë.", 1, true) - 1)
if string.find(text, "{EEA9B8}", string.find(text, "Òåë. {ffffff}", 1, true), true) then
adnomer = string.sub(text, string.find(text, "Òåë. {ffffff}", 1, true) + 13, string.find(text, "{EEA9B8}", string.find(text, "Òåë. {ffffff}", 1, true), true) - 1)
else
adnomer = string.sub(text, string.find(text, "Òåë. {ffffff}", 1, true) + 13, text:len())
end
end
if adtext ~= nil and adnick ~= nil then
id = id + 1
adscount = adscount + 1
allads[id] = text
adnicks[id] = adnick
adnomers[id] = adnomer
if string.find(string.rlower(adtext), "êóïëþ") then color = "{FFFF00}" end
if string.find(string.rlower(adtext), "ïðîäàì") then color = "{00FF00}" end
if not string.find(string.rlower(adtext), "ïðîäàì") and not string.find(string.rlower(adtext), "êóïëþ") then color = "{00FFFF}" end
coolads[id] = color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"
ads1 = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n"..color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"..string.gsub(ads1, "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n", "")
adtext = nil
adnick = nil
adnick = nil
end
trigger = false
end
--imperial RPG
function imperial(text1)
trigger = false
-- sampAddChatMessage(text, - 1) -- ýòî âûâîäèò â ÷àò îáúÿâó, êîòîðóþ ñêðèïò âíîñèò â äèàëîã
for i = #allads - 35, #allads do
if allads[i] ~= nil and text1 == allads[i] then trigger = true blocked = blocked + 1 break end
end
if trigger == false then
id = id + 1
allads[id] = text1
adtext = string.sub(text1, 11, string.find(text1, "]:") - 13)
adnick = string.sub(text1, string.find(text1, "]: ") + 3, string.find(text1, "%[(%d+)%]") - 1)
adnomer = string.sub(text1, string.find(text1, "%[(%d+)%]") + 1, (string.len(text1) - 1))
adnicks[id] = adnick
adnomers[id] = adnomer
if string.find(string.rlower(adtext), "êóïëþ") then color = "{FFFF00}" end
if string.find(string.rlower(adtext), "ïðîäàì") then color = "{00FF00}" end
if not string.find(string.rlower(adtext), "ïðîäàì") and not string.find(string.rlower(adtext), "êóïëþ") then color = "{00FFFF}" end
coolads[id] = color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"
ads1 = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n"..color.."["..id.."]\t"..color.."["..os.date("%H:%M:%S").."] "..adtext.."\t"..color..adnick.."\t"..color..string.format("%s", adnomer).."\n"..string.gsub(ads1, "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n", "")
end
trigger = false
end
--------------------------------------------------------------------------------
----------------------ÄÈÀËÎà ÎÁÚßÂ È ÂÑÅ ×ÒÎ ÑÂßÇÀÍÎ Ñ ÍÈÌ----------------------
--------------------------------------------------------------------------------
--àêòèâàöèÿ äèàëîãà, âûêëþ÷åíèå ôëóäåðêè
function ads()
if Enable then
Enable = false
else
lua_thread.create(adss)
end
end
--äèàëîã /ads
function adss()
if (mode == "Samp-Rp" or mode == "Evolve-Rp" or mode == "ImperiaL" or mode == "Advance-Rp" or mode == "Diamond-Rp" or mode == "Arizona-Rp" or mode == "Trinity-Rp") then
if tab == nil then tab = 1 end
length = #coolads - (tab - 1) * 25
ads1 = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n"
lastid = nil
for i = length, length - 25, - 1 do
if coolads[i] ~= nil then
ads1 = ads1..coolads[i]
if lastid == nil then lastid = i end
if i > lastid then lastid = i end
end
end
sampShowDialog(5125, "{348cb2}"..thisScript().name.." v"..thisScript().version.." LSN: "..LSN..". SFN: "..SFN..". LVN: "..LVN..". Blocked: "..blocked.."/"..adscount..". Tab: "..tab..". Use arrows to control.", ads1, "Âûáðàòü", "Çàêðûòü", 5)
dialog = sampGetDialogText()
while sampIsDialogActive(5125) do
wait(0)
if wasKeyPressed(37) then
if tab ~= 1 then
tab = tab - 1
if tab == nil then tab = 1 end
length = #coolads - (tab - 1) * 25
ads1 = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n"
lastid = nil
for i = length, length - 25, - 1 do
if coolads[i] ~= nil then
if lastid == nil then lastid = i end
ads1 = ads1..coolads[i]
if i > lastid then lastid = i end
end
end
sampShowDialog(5125, "{348cb2}"..thisScript().name.." v"..thisScript().version.." LSN: "..LSN..". SFN: "..SFN..". LVN: "..LVN..". Blocked: "..blocked.."/"..adscount..". Tab: "..tab..". Use arrows to control.", ads1, "Âûáðàòü", "Çàêðûòü", 5)
dialog = sampGetDialogText()
end
end
if wasKeyPressed(39) then
if tab ~= math.ceil(#coolads / 25) then
tab = tab + 1
if tab == nil then tab = 1 end
length = #coolads - (tab - 1) * 25
ads1 = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n"
lastid = nil
for i = length, length - 25, - 1 do
if coolads[i] ~= nil then
if lastid == nil then lastid = i end
if i > lastid then lastid = i end
ads1 = ads1..coolads[i]
end
end
sampShowDialog(5125, "{348cb2}"..thisScript().name.." v"..thisScript().version.." LSN: "..LSN..". SFN: "..SFN..". LVN: "..LVN..". Blocked: "..blocked.."/"..adscount..". Tab: "..tab..". Use arrows to control.", ads1, "Âûáðàòü", "Çàêðûòü", 5)
dialog = sampGetDialogText()
end
end
end
local resultMain, buttonMain, typ = sampHasDialogRespond(5125)
if buttonMain == 1 and typ == 0 then
if mode == "Samp-Rp" or mode == "Evolve-Rp" then
sampShowDialog(9890, "Ôëóäåð /ad", "Ââåäèòå òåêñò îáúÿâëåíèÿ è íàæìèòå \"Ôëóäèòü\".\nÂâåäèòå /ads, ÷òîáû îñòàíîâèòü ôëóäåð.", "Ôëóäèòü", "Çàêðûòü", 1)
while sampIsDialogActive(9890) do wait(100) end
local resultMain, buttonMain, typ = sampHasDialogRespond(9890)
if buttonMain == 1 then
if sampGetCurrentDialogEditboxText(9890) ~= "" then
floodtext = sampGetCurrentDialogEditboxText(9890)
Enable = true
end
else
ads()
end
else
sampShowDialog(9899, "{348cb2}"..thisScript().name.." v"..thisScript().version, "Ôëóäåð /ad íå ïîääåðæèâàåò âàø ïðîåêò.", "Îêåé")
end
elseif buttonMain == 1 and ads1 ~= "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n" and typ == 1 then
sampShowDialog(9891, "Ïîèñê â /ads", "Ââåäèòå òåêñò äëÿ ïîèñêà è íàæìèòå \"Íàéòè\".\nÌîæíî âáèâàòü íèêè, íîìåðà è òåêñò îáúÿâëåíèÿ.", "Íàéòè", "Çàêðûòü", 1)
while sampIsDialogActive(9891) do wait(100) end
local resultMain, buttonMain, typ = sampHasDialogRespond(9891)
if buttonMain == 1 then
if sampGetCurrentDialogEditboxText(9891) ~= "" then
zapros = sampGetCurrentDialogEditboxText(9891)
result = "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n"
scount = 0
snicks = {}
snomers = {}
for i = 0, #coolads do
i = #coolads - i
if string.find(string.rlower(coolads[i]), string.rlower(sampGetCurrentDialogEditboxText(9891)), 1, true) then
result = result..coolads[i]
snicks[scount] = adnicks[i]
snomers[scount] = adnomers[i]
scount = scount + 1
end
end
if scount < 25 then
wait(400)
searchres()
else
sampShowDialog(9899, "{348cb2}"..thisScript().name.." v"..thisScript().version, "Ïî çàïðîñó \""..zapros.."\" íàéäåíî ñëèøêîì ìíîãî îáúÿâëåíèé.\nÍàéäåíî: "..scount.." ñîâïàäåíèé.\nÏîïðîáóéòå óòî÷íèòü çàïðîñ.", "Îêåé")
end
else
ads()
end
else
ads()
end
elseif buttonMain == 1 and ads1 ~= "ID\tÎáúÿâëåíèå\tÏðèñëàë\tÍîìåð\n \tÏîäàòü îáúÿâëåíèå\n \tÏîèñê ïî îáúÿâëåíèÿì\n" and typ > 1 and mode ~= "Arizona-Rp" then
for i = 0, 1001 do
if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == adnicks[lastid - typ + 2] then
sampShowDialog(9899, "Ïîëó÷àòåëü: "..adnicks[lastid - typ + 2], "Ââåäèòå òåêñò ñìñêè è íàæìèòå \"Îòïðàâèòü\".", "Îòïðàâèòü", "Çàêðûòü", 1)
while sampIsDialogActive(9899) do wait(100) end
local resultMain, buttonMain, typ = sampHasDialogRespond(9899)
if buttonMain == 1 then
if sampGetCurrentDialogEditboxText(9899) ~= "" then
if (mode == "ImperiaL") then sampSendChat("/pm "..i.." "..sampGetCurrentDialogEditboxText(9899)) end
if (mode == "Advance-Rp" or mode == "Diamond-Rp" or mode == "Arizona-Rp" or mode == "Trinity-Rp") then sampSendChat("/sms "..adnomers[lastid - typ + 2].." "..sampGetCurrentDialogEditboxText(9899)) end
if (mode == "Samp-Rp" or mode == "Evolve-Rp") then sampSendChat("/t "..i.." "..sampGetCurrentDialogEditboxText(9899)) end
ads()
end
else
ads()
end
break
end
if i == 1001 then sampShowDialog(9899, "{348cb2}"..thisScript().name.." v"..thisScript().version, "Èãðîê "..adnicks[lastid - typ + 2].." îôôëàéí.", "Îêåé") break end
end
end
end
end
--äèàëîã ñ ðåçóëüòàòàìè ïîèñêà
function searchres()
sampShowDialog(4145, "{348cb2}"..thisScript().name.." v"..thisScript().version.." Çàïðîñ: "..zapros..". Íàéäåíî: "..scount..".", result, "Âûáðàòü", "Çàêðûòü", 5)
while sampIsDialogActive(4145) do wait(100) end
local resultMain, buttonMain, typ = sampHasDialogRespond(4145)
if buttonMain == 1 and scount ~= 0 and mode ~= "Arizona-Rp" then
for i = 0, 1001 do
if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == snicks[typ] then
sampShowDialog(9899, "Ïîëó÷àòåëü: "..snicks[typ], "Ââåäèòå òåêñò ñìñêè è íàæìèòå \"Îòïðàâèòü\".", "Îòïðàâèòü", "Çàêðûòü", 1)
while sampIsDialogActive(9899) do wait(100) end
local resultMain, buttonMain, typ = sampHasDialogRespond(9899)
if buttonMain == 1 then
if sampGetCurrentDialogEditboxText(9899) ~= "" then
if (mode == "Samp-Rp" or mode == "Evolve-Rp") then sampSendChat("/t "..i.." "..sampGetCurrentDialogEditboxText(9899)) end
if (mode == "Advance-Rp" or mode == "Diamond-Rp" or mode == "Arizona-Rp" or mode == "Trinity-Rp") then sampSendChat("/sms "..adnomers[typ].." "..sampGetCurrentDialogEditboxText(9899)) end
if (mode == "ImperiaL") then sampSendChat("/pm "..i.." "..sampGetCurrentDialogEditboxText(9899)) end
wait(400)
searchres()
end
else
wait(500)
searchres()
end
break
end
if i == 1001 then sampShowDialog(9899, "{348cb2}"..thisScript().name.." v"..thisScript().version, "Èãðîê "..snicks[typ].." îôôëàéí.", "Îêåé") break end
end
else
ads()
end
end
--------------------------------------------------------------------------------
-------------------------------------HOOK---------------------------------------
--------------------------------------------------------------------------------
function sampev.onServerMessage(color, text)
--samp-rp è âîëüâî
if mode == "Samp-Rp" then
if color == 14221567 and string.find(text, "Îáúÿâëåíèå:") then
if not string.find(text, "101.1", 1, true) and not string.find(text, "102.2", 1, true) and not string.find(text, "103.3", 1, true) and not string.find(text, "radio") and not string.find(text, "FM") and not string.find(text, "Ñâîáîäíàÿ") and not string.find(text, "Ýôèð") and not string.find(text, "÷àéòåñü") and not string.find(text, "News") then
lua_thread.create(samprp, text)
else
blocked = blocked + 1
end
if data.options.toggle == true then return false end
end
if color == 14221567 and string.find(text, "Ðåäàêöèÿ News") then
if string.find(text, "LV") then LVN = LVN + 1 end
if string.find(text, "LS") then LSN = LSN + 1 end
if string.find(text, "SF") then SFN = SFN + 1 end
adscount = adscount + 1
if data.options.toggle == true then return false end
end
end
if mode == "Evolve-Rp" then
if color == 14221512 and string.find(text, "Îáúÿâëåíèå:") then
if not string.find(text, "101.1", 1, true) and not string.find(text, "102.2", 1, true) and not string.find(text, "103.3", 1, true) and not string.find(text, "radio") and not string.find(text, "FM") and not string.find(text, "Ñâîáîäíàÿ") and not string.find(text, "Ýôèð") and not string.find(text, "÷àéòåñü") and not string.find(text, "News") then
lua_thread.create(samprp, text)
else
blocked = blocked + 1
end
if data.options.toggle == true then return false end
end
if color == 14221512 and string.find(text, "ñîòðóäíèê") then
if string.find(text, "LV") then LVN = LVN + 1 end
if string.find(text, "LS") then LSN = LSN + 1 end
if string.find(text, "SF") then SFN = SFN + 1 end
adscount = adscount + 1
if data.options.toggle == true then return false end
end
end
--àäâàíñ ðï
if mode == "Advance-Rp" then
if color == 13369599 and string.find(text, "Îòïðàâèë") then
if string.find(text, "LV |") then LVN = LVN + 1 end
if string.find(text, "LS |") then LSN = LSN + 1 end
if string.find(text, "SF |") then SFN = SFN + 1 end
adscount = adscount + 1
lua_thread.create(advancerp, text)
if data.options.toggle == true then return false end
end
if color == 10027263 and string.find(text, "ñîòðóäíèê") then
if data.options.toggle == true then return false end
end
end
--äàéìîíä ðï
if mode == "Diamond-Rp" then
if color == 16711935 and string.find(text, "Îòïðàâèòåëü") then
lua_thread.create(diamondrp, text)
local temptext = string.sub(text, 1, 5)
if string.find(temptext, "LV") then LVN = LVN + 1 end
if string.find(temptext, "LS") then LSN = LSN + 1 end
if string.find(temptext, "SF") then SFN = SFN + 1 end
adscount = adscount + 1
if data.options.toggle == true then return false end
end
if color == 866792362 and string.find(text, "Îáúÿâëåíèå ïðîâåðèë") then
if data.options.toggle == true then return false end
end
end
--àðèçîíà ðï
if mode == "Arizona-Rp" then
if color == 1941201407 and string.find(text, "Îòïðàâèë") then
adscount = adscount + 1
lua_thread.create(arizonarp, text)
if data.options.toggle == true then return false end
end
if color == 1941201407 and string.find(text, "ñîòðóäíèê ÑÌÈ") then
if string.find(text, "LV") then LVN = LVN + 1 end
if string.find(text, "LS") then LSN = LSN + 1 end
if string.find(text, "SF") then SFN = SFN + 1 end
if data.options.toggle == true then return false end
end
text2 = text
if string.find(text2, "{C17C2D}") then
if string.find(text2, "ñîòðóäíèê ÑÌÈ") then
if string.find(text2, "LV") then LVN = LVN + 1 end
if string.find(text2, "LS") then LSN = LSN + 1 end
if string.find(text2, "SF") then SFN = SFN + 1 end
if data.options.toggle == true then return false end
end
end
text3 = text
if string.find(text3, "{FCAA4D}[VIP]", 1, true) then
if string.find(text3, "åíèå") then
adscount = adscount + 1
lua_thread.create(arizonarp, string.sub(text3, 15, string.len(text3)))
if data.options.toggle == true then return false end
end
end
end
--òðèíèòè ðï
if mode == "Trinity-Rp" then
if color == -290866945 and string.find(text, "[Ðåêëàìà", 1, true) then
lua_thread.create(trinityrp, text)
if data.options.toggle == true then return false end
end
end
--èìïåðèàë ðïã
if mode == "ImperiaL" then
if color == 332279551 and string.find(text, "[Ðåêëàìà]", 1, true) and string.find(text, "]:", 1, true) then
lua_thread.create(imperial, text)
adscount = adscount + 1
if data.options.toggle == true then return false end
end
end
end
--------------------------------------------------------------------------------
----------------------------------RUSSTRING-------------------------------------
--------------------------------------------------------------------------------
local russian_characters = {
[168] = '¨', [184] = '¸', [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] = 'ÿ',
}
function string.rlower(s)
s = s:lower()
local strlen = s:len()
if strlen == 0 then return s end
s = s:lower()
local output = ''
for i = 1, strlen do
local ch = s:byte(i)
if ch >= 192 and ch <= 223 then -- upper russian characters
output = output .. russian_characters[ch + 32]
elseif ch == 168 then -- ¨
output = output .. russian_characters[184]
else
output = output .. string.char(ch)
end
end
return output
end
function string.rupper(s)
s = s:upper()
local strlen = s:len()
if strlen == 0 then return s end
s = s:upper()
local output = ''
for i = 1, strlen do
local ch = s:byte(i)
if ch >= 224 and ch <= 255 then -- lower russian characters
output = output .. russian_characters[ch - 32]
elseif ch == 184 then -- ¸
output = output .. russian_characters[168]
else
output = output .. string.char(ch)
end
end
return output
end