You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
218 lines
6.4 KiB
218 lines
6.4 KiB
script_author('SRP-Number')
|
|
local sampev = require 'lib.samp.events'
|
|
local number = {}
|
|
|
|
local mode = {
|
|
[1] = { run = false, title = 'Ïîèñê íîìåðà' },
|
|
[2] = { run = 30, title = 'Çàäåðæêà'},
|
|
[3] = { run = 3, title = 'Ñîâïàäàþùèå öèôðû' },
|
|
[4] = { run = '', title = 'Èçáðàííûå íîìåðà' },
|
|
[5] = { run = '', title = 'Îïèñàíèå ñêðèïòà' },
|
|
}
|
|
|
|
local func = {
|
|
function(button, index)
|
|
if button == 1 then
|
|
mode[index].run = not mode[index].run
|
|
return true
|
|
end
|
|
end,
|
|
function(button, index)
|
|
if button == 1 then
|
|
sampShowDialog(55524, 'Çàäåðæêà äëÿ ïîèñêà íîìåðà', text, 'Âûáðàòü', 'Íàçàä', 1)
|
|
return false
|
|
end
|
|
end,
|
|
function(button, index)
|
|
if button == 1 then
|
|
if type(mode[index].run) == 'number' then
|
|
mode[index].run = mode[index].run + 1
|
|
if mode[index].run > 6 then
|
|
mode[index].run = 1
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
end,
|
|
function(button, index)
|
|
if button == 1 then
|
|
FileRead()
|
|
local text = 'Äîáàâèòü íîìåð\n'
|
|
dialogLine = {}
|
|
for k,v in pairs(number) do
|
|
text = text..k..'\n'
|
|
dialogLine[#dialogLine + 1] = k
|
|
end
|
|
sampShowDialog(55524, 'Èçáðàííûå íîìåðà äëÿ ïîèñêà', text, 'Âûáðàòü', 'Íàçàä', 4)
|
|
return false
|
|
end
|
|
end,
|
|
function(button, index)
|
|
if button == 1 then
|
|
sampShowDialog(55524, 'Îïèñàíèå ñêðèïòà äëÿ ïîèñêà íîìåðà', '{FFFFFF}Ñêðèïò ñîçäàí äëÿ ïîèñêà íîìåðà íà ñåðâåðå SAMP-RP\nÂû çàïóñêàåòå ïîèñê íîìåðà, îòêðûâàåòå äèàëîã â 24-7 ñ ïîêóïêîé íîìåðà è íàæèìàåòå íà ïîêóïêó íîìåðà.\nÄàëüøå ñêðèïò èùåò íîìåð ïîäõîäÿùèé ïîä âàøè íàñòðîéêè.\n\n Íàñòðîéêè ïîèñêà\n1. Åñòü èçáðàííûå íîìåðà â ìåíþ /num, ìîæåòå äîáàâëÿòü ñâîè.\n2. Ìîæåòå óêàçàòü ñêîëüêî ìàêñèìóì îäèíàêîâûõ öèôð â âàøåì íîìåðå ìîæåò áûòü.\n Åñëè âû óêàçàëè öèôðó 1 - âñå öèôðû â íîìåðå áóäóò îäèíàêîâûå.\n Åñëè âû óêàçàëè öèôðó 2 - â íîìåðå áóäóò òîëüêî 2 îäèíàêîâûå öèôðû, ïðèìåð 111222, 554544\nÒàê æå åñëè âû óêàçàëè öèôðó 2, òî è öèôðà 1 òîæå áóäåò ñ÷èòàòüñÿ çà ñîâïàäåíèå, è ïîèñê íîìåðà îñòàíîâèòñÿ.', 'Âûáðàòü', 'Íàçàä', 0)
|
|
return false
|
|
end
|
|
end,
|
|
}
|
|
|
|
function main()
|
|
if not isSampLoaded() or not isSampfuncsLoaded() then return end
|
|
while not isSampAvailable() do wait(100) end
|
|
while true do
|
|
wait(0)
|
|
local caption = sampGetDialogCaption()
|
|
local result, button, list, input = sampHasDialogRespond(55524)
|
|
if caption == 'Ïîèñê íîìåðà äëÿ Samp-RP' and dialogLine ~= nil then
|
|
if result then
|
|
if func[list + 1](button, list + 1) then
|
|
ShowDialog()
|
|
end
|
|
end
|
|
end
|
|
if caption == 'Èçáðàííûå íîìåðà äëÿ ïîèñêà' and dialogLine ~= nil then
|
|
if result then
|
|
if button == 1 then
|
|
if list == 0 then
|
|
sampShowDialog(55524, 'Äîáàâëåíèå íîìåðà äëÿ ïîèñêà', '{FFFFFF}Ââåäèòå íîìåð äëÿ äîáàâëåíèÿ â ñïèñîê.', 'Äîáàâèòü', 'Íàçàä', 1)
|
|
else
|
|
if dialogLine[list] ~= nil then
|
|
local file = io.open("moonloader\\SRP-Number.txt", "r")
|
|
local fileText = ""
|
|
if file ~= nil then
|
|
for line in file:lines() do
|
|
if line ~= dialogLine[list] then
|
|
fileText = fileText..line.."\n"
|
|
end
|
|
end
|
|
io.close(file)
|
|
end
|
|
file = io.open("moonloader\\SRP-Number.txt", "w")
|
|
file:write(fileText)
|
|
file:flush()
|
|
io.close(file)
|
|
FileRead()
|
|
end
|
|
func['Èçáðàííûå íîìåðà'](1)
|
|
end
|
|
else
|
|
ShowDialog()
|
|
end
|
|
end
|
|
end
|
|
if caption == 'Äîáàâëåíèå íîìåðà äëÿ ïîèñêà' and dialogLine ~= nil then
|
|
if result then
|
|
if button == 1 then
|
|
if input:find('(%d+)') then
|
|
local file = io.open("moonloader\\SRP-Number.txt", "a")
|
|
file:write(input:match('(%d+)')..'\n')
|
|
file:flush()
|
|
io.close(file)
|
|
FileRead()
|
|
func['Èçáðàííûå íîìåðà'](1)
|
|
end
|
|
else
|
|
func['Èçáðàííûå íîìåðà'](1)
|
|
end
|
|
end
|
|
end
|
|
if caption == 'Çàäåðæêà äëÿ ïîèñêà íîìåðà' and dialogLine ~= nil then
|
|
if result then
|
|
if button == 1 then
|
|
if input:find('(%d+)') then
|
|
mode[2]["run"] = tonumber(input:match('(%d+)'))
|
|
end
|
|
end
|
|
ShowDialog()
|
|
end
|
|
end
|
|
if caption == 'Îïèñàíèå ñêðèïòà äëÿ ïîèñêà íîìåðà' and dialogLine ~= nil then
|
|
if result then
|
|
ShowDialog()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function sampev.onServerMessage(color, message)
|
|
if string.find(message, " Âàø íîâûé íîìåð ìîáèëüíîãî .+") and mode[1].run then
|
|
local str = string.match(message, " Âàø íîâûé íîìåð ìîáèëüíîãî (.+)")
|
|
local MyNumber, text = isMyNumber(str)
|
|
if number[str] ~= nil or tonumber(MyNumber) <= mode[3].run then
|
|
sampAddChatMessage(" > Íàéäåíû ïîâòîðû öèôð: "..text..". > Enter - èñêàòü äàëüøå." , -1)
|
|
else
|
|
lua_thread.create(function()
|
|
repeat wait(10) until sampIsDialogActive() and string.find(sampGetDialogCaption(), "Ìàãàçèí")
|
|
wait(mode[2]["run"])
|
|
if mode[1]["run"] then
|
|
local dialogId = sampGetCurrentDialogId()
|
|
sampSendDialogResponse(dialogId,1,2,"")
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
|
|
function sampev.onSendCommand(cmd)
|
|
if cmd:lower() == "/num" then
|
|
ShowDialog()
|
|
return false
|
|
end
|
|
end
|
|
|
|
function sampev.onSendDialogResponse(dialogId, button, listboxId, input)
|
|
if button ~= 1 and string.find(sampGetDialogCaption(), "Ìàãàçèí") and mode[1].run then
|
|
sampAddChatMessage(" > Ïîèñê íîìåðà îòêëþ÷åí", -1)
|
|
mode[1].run = false
|
|
end
|
|
end
|
|
|
|
function FileRead()
|
|
number = {}
|
|
if doesFileExist("moonloader\\SRP-Number.txt") then
|
|
local f = io.open("moonloader\\SRP-Number.txt", 'r')
|
|
if f then
|
|
for line in f:lines() do
|
|
number[line] = true
|
|
end
|
|
f:close()
|
|
end
|
|
else
|
|
local file = io.open("moonloader\\SRP-Number.txt", "w")
|
|
file:write('777\n')
|
|
number['777'] = true
|
|
file:flush()
|
|
io.close(file)
|
|
end
|
|
end
|
|
|
|
function isMyNumber(n)
|
|
local search, text = 0, ''
|
|
for i = 1, 10 do
|
|
numbers = i - 1
|
|
if string.find(n, tostring(numbers)) then
|
|
string.gsub(n, tostring(numbers), '')
|
|
if text == '' then
|
|
text = numbers
|
|
else
|
|
text = text..', '..numbers
|
|
end
|
|
search = search + 1
|
|
end
|
|
end
|
|
return search, text
|
|
end
|
|
|
|
|
|
function ShowDialog()
|
|
dialogLine = {}
|
|
local text = ""
|
|
for i = 1, #mode do
|
|
local modes = mode[i].run
|
|
if type(mode[i].run) == 'boolean' then
|
|
modes = mode[i].run and '{06940f}ON' or '{d10000}OFF'
|
|
end
|
|
text = string.format('%s%s\t%s\n', text, mode[i].title, modes)
|
|
dialogLine[i] = mode[i].title
|
|
end
|
|
sampShowDialog(55524, 'Ïîèñê íîìåðà äëÿ Samp-RP', text, "Âûáðàòü", "Çàêðûòü", 4)
|
|
end |