- 5,143
- 1,984
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
HelperLovli от J-Family. Кто хочет юзать - закомментируйте привязку.
Lua:
script_name('HelperLovli')
script_author('#leomasker')
local version = 'test-release'
local MASLOSYKA = {"Family", "Dynasty", "Corporation", "Squad", "Crew", "Empire", "Brotherhood"}
local q = require 'lib.samp.events'
local inicfg = require 'inicfg'
local vkeys = require 'vkeys'
local imgui = require 'imgui'
local mem = require 'memory'
local bNotf, notf = pcall(import, "imgui_notf.lua")
local time = nil
local captime = nil
local hfind = 0
local forFind = {}
local houses = {}
local t = 0
local payday = false
local captcha = ''
local captchaTable = {}
local HLcfg = inicfg.load({
main = {
activation = 'helper',
nClear = false,
jtext = 'j family naxyi',
resetpd = false,
utime = false,
ptime = false,
HLmsg = false,
max5 = false,
plus3click = false,
floodN = false,
autofind = false,
onkey = false,
key = 'U',
texttime = false,
theme = 1,
autoenter = false
}
}, "HelperLovli")
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local tags = imgui.ImBool(false)
local main_window_state = imgui.ImBool(false)
buffer = imgui.ImBuffer(tostring(HLcfg.main.jtext), 256)
buffer.v = string.gsub(tostring(buffer.v), '"', '')
keybuff = imgui.ImBuffer(tostring(HLcfg.main.key), 5)
buffermenu = imgui.ImBuffer(tostring(HLcfg.main.activation), 256)
function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
local Colors = style.Colors
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.Alpha = 1
style.ChildWindowRounding = 15
style.WindowRounding = 15
style.GrabRounding = 15
style.GrabMinSize = 20
style.FrameRounding = 10
Colors[imgui.Col.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
Colors[imgui.Col.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
Colors[imgui.Col.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
Colors[imgui.Col.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
Colors[imgui.Col.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
Colors[imgui.Col.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
Colors[imgui.Col.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
Colors[imgui.Col.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
Colors[imgui.Col.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
Colors[imgui.Col.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
Colors[imgui.Col.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
Colors[imgui.Col.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
Colors[imgui.Col.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
Colors[imgui.Col.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
Colors[imgui.Col.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
Colors[imgui.Col.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
Colors[imgui.Col.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
Colors[imgui.Col.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
Colors[imgui.Col.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
Colors[imgui.Col.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
Colors[imgui.Col.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
Colors[imgui.Col.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
Colors[imgui.Col.Button] = ImVec4(0.15, 0.15, 0.18, 1.00)
Colors[imgui.Col.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
Colors[imgui.Col.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
Colors[imgui.Col.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
Colors[imgui.Col.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
Colors[imgui.Col.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
Colors[imgui.Col.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
Colors[imgui.Col.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
Colors[imgui.Col.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
Colors[imgui.Col.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
Colors[imgui.Col.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
Colors[imgui.Col.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
Colors[imgui.Col.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
Colors[imgui.Col.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
Colors[imgui.Col.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
Colors[imgui.Col.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
Colors[imgui.Col.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
Colors[imgui.Col.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
function lightBlue()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
colors[clr.Text] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.TextDisabled] = ImVec4(0.24, 0.24, 0.24, 1.00)
colors[clr.WindowBg] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.96, 0.96, 0.96, 1.00)
colors[clr.PopupBg] = ImVec4(0.92, 0.92, 0.92, 1.00)
colors[clr.Border] = ImVec4(0.86, 0.86, 0.86, 1.00)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.88, 0.88, 0.88, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.82, 0.82, 0.82, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.76, 0.76, 0.76, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.45, 1.00, 0.82)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.45, 1.00, 0.82)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.45, 1.00, 0.82)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.37, 0.78, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.35, 1.00, 0.78)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.33, 1.00, 0.84)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 0.31, 1.00, 0.88)
colors[clr.ComboBg] = ImVec4(0.92, 0.92, 0.92, 1.00)
colors[clr.CheckMark] = ImVec4(0.00, 0.49, 1.00, 0.59)
colors[clr.SliderGrab] = ImVec4(0.00, 0.49, 1.00, 0.59)
colors[clr.SliderGrabActive] = ImVec4(0.00, 0.39, 1.00, 0.71)
colors[clr.Button] = ImVec4(0.00, 0.49, 1.00, 0.59)
colors[clr.ButtonHovered] = ImVec4(0.00, 0.49, 1.00, 0.71)
colors[clr.ButtonActive] = ImVec4(0.00, 0.49, 1.00, 0.78)
colors[clr.Header] = ImVec4(0.00, 0.49, 1.00, 0.78)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.49, 1.00, 0.71)
colors[clr.HeaderActive] = ImVec4(0.00, 0.49, 1.00, 0.78)
colors[clr.ResizeGrip] = ImVec4(0.00, 0.39, 1.00, 0.59)
colors[clr.ResizeGripHovered] = ImVec4(0.00, 0.27, 1.00, 0.59)
colors[clr.ResizeGripActive] = ImVec4(0.00, 0.25, 1.00, 0.63)
colors[clr.CloseButton] = ImVec4(0.00, 0.35, 0.96, 0.71)
colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.31, 0.88, 0.69)
colors[clr.CloseButtonActive] = ImVec4(0.00, 0.25, 0.88, 0.67)
colors[clr.PlotLines] = ImVec4(0.00, 0.39, 1.00, 0.75)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.39, 1.00, 0.75)
colors[clr.PlotHistogram] = ImVec4(0.00, 0.39, 1.00, 0.75)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.35, 0.92, 0.78)
colors[clr.TextSelectedBg] = ImVec4(0.00, 0.47, 1.00, 0.59)
colors[clr.ModalWindowDarkening] = ImVec4(0.20, 0.20, 0.20, 0.35)
end
function redTheme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowRounding = 2.0
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
style.ChildWindowRounding = 2.0
style.FrameRounding = 2.0
style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
style.ScrollbarSize = 13.0
style.ScrollbarRounding = 0
style.GrabMinSize = 8.0
style.GrabRounding = 1.0
colors[clr.FrameBg] = ImVec4(0.48, 0.16, 0.16, 0.54)
colors[clr.FrameBgHovered] = ImVec4(0.98, 0.26, 0.26, 0.40)
colors[clr.FrameBgActive] = ImVec4(0.98, 0.26, 0.26, 0.67)
colors[clr.TitleBg] = ImVec4(0.04, 0.04, 0.04, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.48, 0.16, 0.16, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.CheckMark] = ImVec4(0.98, 0.26, 0.26, 1.00)
colors[clr.SliderGrab] = ImVec4(0.88, 0.26, 0.24, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.98, 0.26, 0.26, 1.00)
colors[clr.Button] = ImVec4(0.98, 0.26, 0.26, 0.40)
colors[clr.ButtonHovered] = ImVec4(0.98, 0.26, 0.26, 1.00)
colors[clr.ButtonActive] = ImVec4(0.98, 0.06, 0.06, 1.00)
colors[clr.Header] = ImVec4(0.98, 0.26, 0.26, 0.31)
colors[clr.HeaderHovered] = ImVec4(0.98, 0.26, 0.26, 0.80)
colors[clr.HeaderActive] = ImVec4(0.98, 0.26, 0.26, 1.00)
colors[clr.Separator] = colors[clr.Border]
colors[clr.SeparatorHovered] = ImVec4(0.75, 0.10, 0.10, 0.78)
colors[clr.SeparatorActive] = ImVec4(0.75, 0.10, 0.10, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.98, 0.26, 0.26, 0.25)
colors[clr.ResizeGripHovered] = ImVec4(0.98, 0.26, 0.26, 0.67)
colors[clr.ResizeGripActive] = ImVec4(0.98, 0.26, 0.26, 0.95)
colors[clr.TextSelectedBg] = ImVec4(0.98, 0.26, 0.26, 0.35)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
colors[clr.WindowBg] = ImVec4(0.06, 0.06, 0.06, 0.94)
colors[clr.ChildWindowBg] = ImVec4(1.00, 1.00, 1.00, 0.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.ComboBg] = colors[clr.PopupBg]
colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.MenuBarBg] = ImVec4(0.14, 0.14, 0.14, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50)
colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end
function ShowHelpMarker(desc)
imgui.TextDisabled('(?)')
if imgui.IsItemHovered() then
imgui.BeginTooltip()
imgui.PushTextWrapPos(450.0)
imgui.TextUnformatted(desc)
imgui.PopTextWrapPos()
imgui.EndTooltip()
end
end
function GetTheme()
if HLcfg.main.theme == 1 then apply_custom_style()
elseif HLcfg.main.theme == 2 then lightBlue()
elseif HLcfg.main.theme == 3 then redTheme() end
end
GetTheme()
function imgui.OnDrawFrame()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(410, 230), imgui.Cond.FirstUseEver) --низ по 25
imgui.Begin(u8'[Arizona RP] Хелпер Ловли | '..version..'##main', main_window_state, imgui.WindowFlags.NoCollapse)
imgui.SetWindowPos(u8'[Arizona RP] Хелпер Ловли | '..version..'##main', imgui.ImVec2(420, 170), imgui.Cond.FirstUseEver)
if imgui.TreeNode(u8'Общие настройки') then
imgui.Text(u8'Ваша фраза:')
if imgui.InputText('##1', buffer, imgui.SameLine()) then
HLcfg.main.jtext = string.format('%s', tostring(buffer.v))
end
ShowHelpMarker(u8'Ваша фраза после покупки имущества.', imgui.SameLine())
imgui.Text(u8'Активация:')
if imgui.InputText('##2', buffermenu, imgui.SameLine()) then
sampUnregisterChatCommand(HLcfg.main.activation)
HLcfg.main.activation = buffermenu.v
sampRegisterChatCommand(tostring(HLcfg.main.activation), function() main_window_state.v = not main_window_state.v end)
end
ShowHelpMarker(u8'Команда для активации скрипта.', imgui.SameLine())
if imgui.Checkbox(u8'Автонажатие Enter | Временно недоступно', imgui.ImBool(HLcfg.main.autoenter)) then HLcfg.main.autoenter = not HLcfg.main.autoenter end
ShowHelpMarker(u8'Как только в диалоге капчи будет 5 символов - ответ отправится на сервер.', imgui.SameLine())
if imgui.Checkbox(u8'Добавлять время во фразу', imgui.ImBool(HLcfg.main.texttime)) then HLcfg.main.texttime = not HLcfg.main.texttime end
ShowHelpMarker(u8'Добавляет в вашу фразу время, за которое вы словили имущество.', imgui.SameLine())
if imgui.Checkbox(u8'Отсчет времени в PayDay', imgui.ImBool(HLcfg.main.resetpd)) then HLcfg.main.resetpd = not HLcfg.main.resetpd end
ShowHelpMarker(u8'Если включено, то скрипт будет работать от момента пайдея.\nЕсли выключено, то скрипт будет работать от момента открытия капчи.', imgui.SameLine())
if imgui.Checkbox(u8'Отключить ники и семьи', tags) then
pStSet = sampGetServerSettingsPtr()
if tags.v then
mem.setint8(pStSet + 56, 0)
for i = 1, 2048 do
if sampIs3dTextDefined(i) then
local text, color, posX, posY, posZ, distance, ignoreWalls, player, vehicle = sampGet3dTextInfoById(i)
for ii = 1, #MASLOSYKA do if text:match(string.format('.+%s', MASLOSYKA[tonumber(ii)])) then sampDestroy3dText(i) end end
end
end
else
mem.setint8(pStSet + 56, 1)
end
end
ShowHelpMarker(u8'Отключает ник и название семьи над игроком.\n(название семье не вернется - на доработке)', imgui.SameLine())
if imgui.Checkbox(u8'Флуд на N', imgui.ImBool(HLcfg.main.floodN)) then HLcfg.main.floodN = not HLcfg.main.floodN end
ShowHelpMarker(u8'Если нажать на N до PayDay, то Вам не будет писать "Не флуди",\nа также не будет кд на повторное нажатие', imgui.SameLine())
if imgui.Checkbox(u8'Поиск ближайшего дома', imgui.ImBool(HLcfg.main.autofind)) then HLcfg.main.autofind = not HLcfg.main.autofind end
ShowHelpMarker(u8'Если открыть диалог с домами - будет найдет ближайший дом в госе.\nЕсли будет только 1 дом в госе - найдет его\nЕсли домов в госе не будет - не произойдет ничего', imgui.SameLine())
imgui.TreePop()
end
imgui.Separator()
if imgui.TreeNode(u8'Диалог капчи') then
if imgui.Checkbox(u8'Удаление букв и символов с диалога капчи', imgui.ImBool(HLcfg.main.nClear)) then
HLcfg.main.nClear = not HLcfg.main.nClear
end
ShowHelpMarker(u8'В диалог с капчей будет запрещено вводить всё кроме цифр', imgui.SameLine())
if imgui.Checkbox(u8'Ограничение в 5 символов', imgui.ImBool(HLcfg.main.max5)) then
HLcfg.main.max5 = not HLcfg.main.max5
end
ShowHelpMarker(u8'Запрещает вводить в диалог капчи больше 5 символов.', imgui.SameLine())
imgui.TreePop()
end
imgui.Separator()
if imgui.TreeNode(u8'Настройки чата') then
if imgui.Checkbox(u8'Время покупки/неверного и т.д', imgui.ImBool(HLcfg.main.utime)) then
HLcfg.main.utime = not HLcfg.main.utime
end
ShowHelpMarker(u8'Пишет в чат за сколько Вы купили дом или бизнес', imgui.SameLine())
if imgui.Checkbox(u8'Время покупки другим человеком', imgui.ImBool(HLcfg.main.ptime)) then
HLcfg.main.ptime = not HLcfg.main.ptime
end
ShowHelpMarker(u8'Пишет в чат за сколько другой игрок купил дом или бизнес', imgui.SameLine())
if imgui.Checkbox(u8'Сообщение в чат после покупки имущества', imgui.ImBool(HLcfg.main.HLmsg)) then
HLcfg.main.HLmsg = not HLcfg.main.HLmsg
end
ShowHelpMarker(u8'После покупки дома или бизнеса пишет в чат вашу фразу,\nкоторую можно указать во вкладке "Общие настройки"', imgui.SameLine())
imgui.TreePop()
end
imgui.Separator()
if imgui.TreeNode(u8'Тренировка капчи') then
imgui.Text(u8'Кнопка')
if imgui.InputText('##3', keybuff, imgui.SameLine()) then
HLcfg.main.key = string.format('%s', tostring(keybuff.v))
end
ShowHelpMarker(u8'Кнопка по которой будет открыватся капча.', imgui.SameLine())
if imgui.Checkbox(u8'Открывать капчу по кнопке', imgui.ImBool(HLcfg.main.onkey)) then
HLcfg.main.onkey = not HLcfg.main.onkey
end
if imgui.Button(u8'Открыть капчу') then showCaptcha() end
if imgui.Button(u8'Очистить текстдравы', imgui.SameLine()) then for i = 1, 400 do sampTextdrawDelete(i) end end
imgui.TreePop()
end
imgui.Separator()
if imgui.TreeNode(u8'Сменить тему') then
if HLcfg.main.theme ~= 1 then apply_custom_style() end
if imgui.Button(u8'Темная тема') then HLcfg.main.theme = 1; apply_custom_style() end
GetTheme()
if HLcfg.main.theme ~= 2 then lightBlue() end
if imgui.Button(u8'Светло-синяя тема', imgui.SameLine()) then HLcfg.main.theme = 2; lightBlue() end
GetTheme()
if HLcfg.main.theme ~= 3 then redTheme() end
if imgui.Button(u8'Красная тема', imgui.SameLine()) then HLcfg.main.theme = 3; redTheme() end
GetTheme()
imgui.TreePop()
end
imgui.End()
end
end
function randomFloat(lower, greater)
return lower + math.random() * (greater - lower);
end
function showCaptcha()
removeTextdraws()
t = t + 1
sampTextdrawCreate(t, "LD_SPAC:white", 220, 120)
sampTextdrawSetLetterSizeAndColor(t, 0, 6.5, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF1A2432, 380, 0.000000)
t = t + 1
sampTextdrawCreate(t, "LD_SPAC:white", 225, 125)
sampTextdrawSetLetterSizeAndColor(t, 0, 5.5, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, 375, 0.000000)
nextPos = -30.0;
math.randomseed(os.time())
for i = 1, 4 do
a = math.random(0, 9)
table.insert(captchaTable, a)
captcha = captcha..a
end
for i = 0, 4 do
nextPos = nextPos + 30
t = t + 1
sampTextdrawCreate(t, "usebox", 240 + nextPos, 130)
sampTextdrawSetLetterSizeAndColor(t, 0, 4.5, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF1A2432, 30, 25.000000)
sampTextdrawSetAlign(t, 2)
if i < 4 then GenerateTextDraw(captchaTable[i + 1], 240 + nextPos, 130, 3 + i * 2)
else GenerateTextDraw(0, 240 + nextPos, 130, 3 + i * 10) end
end
captchaTable = {}
sampShowDialog(8812, '{F89168}Проверка на робота', '{FFFFFF}Введите {C6FB4A}5{FFFFFF} символов, которые\nвидно на {C6FB4A}вашем{FFFFFF} экране.', 'Принять', 'Отмена', 1)
captime = os.clock()
end
function removeTextdraws()
if t > 0 then
for i = 1, t do sampTextdrawDelete(i) end
t = 0
captcha = ''
captime = nil
end
end
function GenerateTextDraw(id, PosX, PosY)
if id == 0 then
t = t + 1
sampTextdrawCreate(t, "LD_SPAC:white", PosX - 5, PosY + 7)
sampTextdrawSetLetterSizeAndColor(t, 0, 3, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX+5, 0.000000)
elseif id == 1 then
for i = 0, 1 do
t = t + 1
if i == 0 then offsetX = 3; offsetBX = 15 else offsetX = -3; offsetBX = -15; end
sampTextdrawCreate(t, "LD_SPAC:white", PosX - offsetX, PosY)
sampTextdrawSetLetterSizeAndColor(t, 0, 4.5, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-offsetBX, 0.000000)
end
elseif id == 2 then
for i = 0, 1 do
t = t + 1
if i == 0 then offsetX = -8; offsetY = 7 offsetBX = 15 else offsetX = 6; offsetY = 25 offsetBX = -15; end
sampTextdrawCreate(t, "LD_SPAC:white", PosX - offsetX, PosY + offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, 0.8, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-offsetBX, 0.000000)
end
elseif id == 3 then
for i = 0, 1 do
t = t + 1
if i == 0 then size = 0.8; offsetY = 7 else size = 1; offsetY = 25 end
sampTextdrawCreate(t, "LD_SPAC:white", PosX+10, PosY+offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, 1, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-15, 0.000000)
end
elseif id == 4 then
for i = 0, 1 do
t = t + 1
if i == 0 then size = 1.8; offsetX = -10; offsetY = 0 offsetBX = 10 else size = 2; offsetX = -10; offsetY = 25 offsetBX = 15; end
sampTextdrawCreate(t, "LD_SPAC:white", PosX - offsetX, PosY + offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, size, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-offsetBX, 0.000000)
end
elseif id == 5 then
for i = 0, 1 do
t = t + 1
if i == 0 then size = 0.8; offsetX = 8; offsetY = 7 offsetBX = -15 else size = 1; offsetX = -10; offsetY = 25 offsetBX = 15; end
sampTextdrawCreate(t, "LD_SPAC:white", PosX - offsetX, PosY + offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, size, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-offsetBX, 0.000000)
end
elseif id == 6 then
for i = 0, 1 do
t = t + 1
if i == 0 then size = 0.8; offsetX = 7.5; offsetY = 7 offsetBX = -15 else size = 1; offsetX = -10; offsetY = 25 offsetBX = 10; end
sampTextdrawCreate(t, "LD_SPAC:white", PosX - offsetX, PosY + offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, size, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-offsetBX, 0.000000)
end
elseif id == 7 then
t = t + 1
sampTextdrawCreate(t, "LD_SPAC:white", PosX - 13, PosY + 7)
sampTextdrawSetLetterSizeAndColor(t, 0, 3.75, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX+5, 0.000000)
elseif id == 8 then
for i = 0, 1 do
t = t + 1
if i == 0 then size = 0.8; offsetY = 7 else size = 1; offsetY = 25 end
sampTextdrawCreate(t, "LD_SPAC:white", PosX+10, PosY+offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, 1, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-10, 0.000000)
end
elseif id == 9 then
for i = 0, 1 do
t = t + 1
if i == 0 then size = 0.8; offsetY = 6; offsetBX = 10; else size = 1; offsetY = 25; offsetBX = 15; end
sampTextdrawCreate(t, "LD_SPAC:white", PosX+10, PosY+offsetY)
sampTextdrawSetLetterSizeAndColor(t, 0, 1, 0x80808080)
sampTextdrawSetBoxColorAndSize(t, 1, 0xFF759DA3, PosX-offsetBX, 0.000000)
end
end
end
local s1xreq = {
_DESCRIPTION = 'Http s1xreq made simpler',
http_socket = http_socket,
https_socket = https_socket
}
local _s1xreq = {}
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
local ffi = require("ffi")
ffi.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 serial = ffi.new("unsigned long[1]", 0)
ffi.C.GetVolumeInformationA(nil, nil, 0, serial, nil, nil, nil, 0)
serial = serial[0]
local usdjas = ''
usdjas = string.format('%s', serial)
local qwords = ffi.typeof("uint64_t[?]")
local dwords = ffi.typeof("uint32_t *")
local cpuid_EAX_EDX = ffi.cast("__cdecl uint64_t (*)(uint32_t)", "\x53\x0F\xA2\x5B\xC3")
local cpuid_EBX_ECX = ffi.cast("__cdecl uint64_t (*)(uint32_t)", "\x53\x0F\xA2\x91\x92\x93\x5B\xC3")
local function cpuid(n)
local arr = ffi.cast(dwords, qwords(2, cpuid_EAX_EDX(n), cpuid_EBX_ECX(n)))
return ffi.string(arr, 4), ffi.string(arr + 2, 4), ffi.string(arr + 3, 4), ffi.string(arr + 1, 4)
end
local s1 = ""
for n = 0x80000002, 0x80000004 do
local eax, ebx, ecx, edx = cpuid(n)
s1 = s1..eax..ebx..ecx..edx
end
s1 = s1:gsub("^%s+", ""):gsub("%z+$", "")
local eax, ebx, ecx, edx = cpuid(0)
local s2 = ebx..edx..ecx
s2 = s2:gsub("^%s+", ""):gsub("%z+$", "")
usdjas = string.format('%s | %s %s', usdjas, s1, s2)
usdjas = md5_tohex(usdjas)
local ahashsahsd = {
headers = {
['content-type']='application/x-www-form-urlencoded',
['user-agent']='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
}
}
local mainfunci = s1xreq.get('https://saxofone.pp.ua/Helper/k_add.php?hwid='..usdjas, ahashsahsd)
if not string.find(mainfunci['text'], "SK%-TEAM POMOIKA | AZLLER'a MATb EBAL") then sampAddChatMessage('{ffff00}[Хелпер ловли] {ffffff}Код для привязки: '..usdjas, -1); thisScript():unload(); return false end
sampRegisterChatCommand(tostring(HLcfg.main.activation), function() main_window_state.v = not main_window_state.v end)
notf.addNotification('Активация: /' ..HLcfg.main.activation, 5, 1)
notf.addNotification('Скрипт успешно загружен! Текущая версия: ' ..version, 5, 1)
sampAddChatMessage('{ffff00}[Хелпер Ловли] {ffffff}by Leo_Masker for {20B2AA}J Family {ffff00}| {ffffff}Версия: '..version, -1)
while true do wait(0)
keybuff.v = string.upper(keybuff.v)
if wasKeyPressed(vkeys.name_to_id(keybuff.v, false)) and HLcfg.main.onkey and not sampIsChatInputActive() and not sampIsDialogActive() then showCaptcha() end
local result, button, list, input = sampHasDialogRespond(8812)
if result then
if button == 1 then
if input == captcha..'0' then sampAddChatMessage(string.format('{ffff00}[Хелпер ловли] {ffffff}Код верный [%.3f]', os.clock() - captime), -1)
elseif input ~= captcha..'0' then sampAddChatMessage(string.format('{ffff00}[Хелпер ловли] {ffffff}Неверный код! [%.3f] ('..captcha..'0|'..input..')', os.clock() - captime), -1) end
end
removeTextdraws()
end
if sampIsDialogActive() and sampGetDialogCaption():find('Проверка на робота') then
if HLcfg.main.nClear then sampSetCurrentDialogEditboxText(string.gsub(sampGetCurrentDialogEditboxText(), '[^1234567890]','')) end
if HLcfg.main.max5 then
local text = sampGetCurrentDialogEditboxText()
if #text > 5 then sampSetCurrentDialogEditboxText(text:sub(1, 5)) end
end
end
imgui.Process = main_window_state.v
end
wait(-1)
end
function q.onPlayerChatBubble() if tags.v then return false end end
function q.onCreate3DText(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text)
if time ~= nil and HLcfg.main.ptime then
local _, pid = sampGetPlayerIdByCharHandle(playerPed)
pname = sampGetPlayerNickname(pid)
for pizda in text:gmatch('[^\n\r]+') do
pizda = pizda:match('{FFFFFF}Владелец: {AFAFAF}(.+)')
if pizda ~= nil and pizda ~= pname then return sampAddChatMessage(string.format('{ffff00}[Хелпер Ловли] {ffffff}Дом куплен игроком {20B2AA}%s {ffffff}[%.3f]', pizda, os.clock() - time), -1) end
end
for pizda in text:gmatch('[^\n\r]+') do
pizda = pizda:match('{73B461}Владелец: {FFFFFF}(.+)')
if pizda ~= nil and pizda ~= pname then return sampAddChatMessage(string.format('{ffff00}[Хелпер Ловли] {ffffff}Бизнес куплен игроком {20B2AA}%s {ffffff}[%.3f]', pizda, os.clock() - time), -1) end
end
end
end
function q.onSendPlayerSync(data)
if HLcfg.main.floodN and data.weapon == 128 and not payday then return false
elseif HLcfg.main.floodN and data.weapon == 128 and payday then payday = false end
end
function q.onShowDialog(dialogId, style, title, button1, button2, text)
if title:find('Проверка на робота') then
if not HLcfg.main.resetpd then
time = os.clock()
reset()
end
end
if text:find('/findihouse ID') and HLcfg.main.autofind then
for line in text:gmatch('[^\n\r]+') do
if line:find('Эта информация может быть {1EA3CC}ошибочной%.{FFFFFF}') then
if #forFind == 1 then
sampSendChat('/findihouse '..forFind[1])
table.remove(forFind, 1)
sampAddChatMessage('{ffff00}[Хелпер Ловли] {ffffff}Слетел один дом. Метка установлена!', -1)
elseif #forFind > 1 then
sampAddChatMessage('{ffff00}[Хелпер Ловли] {ffffff}Слетело {ff0000}'..#forFind..' {ffffff}домов, ищем ближайщий!', -1)
sampSendChat('/findihouse '..forFind[1])
elseif #forFind == 0 then
sampAddChatMessage('{ffff00}[Хелпер Ловли] {ffffff}Домов в госе нет!', -1)
end
return true
end
local hid = line:match('.+%. Дом ID: {C9B931}(.+){FFFFFF} %[{A9FF14}Слетел{FFFFFF}]')
if hid ~= nil then table.insert(forFind, hid) end
end
end
end
function q.onServerMessage(color, text)
if text:find('%[Подсказка] {FFFFFF}На миникарте отмечено место где будет продаваться дом.') then
if #forFind > 0 then
local x, y, z = getCharCoordinates(playerPed)
local x1, y1, z1 = GetRedMarkerCoords()
houses[forFind[1]] = getDistanceBetweenCoords3d(x, y, z, x1, y1, z1)
table.remove(forFind, 1)
if #forFind > 0 then sampSendChat('/findihouse '..forFind[1]) end
if #forFind == 0 then hfind = 1 end
end
if #forFind == 0 and hfind == 1 then
for k,v in spairs(houses, function(t,a,b) return t[b] > t[a] end) do
hfind = 2
forFind, houses = {}, {}
sampAddChatMessage('{ffff00}[Хелпер Ловли] {ffffff}Ближайший дом - '..k..'. Метка установлена на карте!', -1)
sampSendChat('/findihouse '..k)
return
end
end
if hfind == 2 then
hfind = 0
return false
end
end
if text:find('%[Ошибка] {FFFFFF}У вас недостаточно денег%. Вы можете пополнить свой баланс %[/donate]') and color == -10270721 and time ~= nil then
if HLcfg.main.utime then
sampAddChatMessage(string.format('{FF6347}[Ошибка] {FFFFFF}У вас недостаточно денег. [%.3f]', os.clock() - time), -1)
return false
end
end
if text:find('__________________________________') and color == 1941201407 or
text:find('Для получения PayDay вы должны отыграть минимум 20 минут.') and color == -10270721 then
if HLcfg.main.resetpd then
time = os.clock()
reset()
end
payday = true
end
if text:find('%[Информация] {FFFFFF}Поздравляю! Теперь этот бизнес ваш!') and color == 1941201407 and time ~= nil then
if HLcfg.main.HLmsg then
if HLcfg.main.texttime then sampSendChat(u8:decode(string.format('%s [%.3f]', HLcfg.main.jtext, time)))
else sampSendChat(u8:decode(HLcfg.main.jtext)) end
end
if HLcfg.main.utime then
time = os.clock() - time
sampAddChatMessage(string.format('{73B461}[Информация] {FFFFFF}Поздравляю! Теперь этот бизнес ваш! [%.3f]', time), -1)
return false
end
end
if text:find('%[Информация] {FFFFFF}Поздравляю! Теперь этот дом ваш!') and color == 1941201407 and time ~= nil then
if HLcfg.main.HLmsg then
if HLcfg.main.texttime then sampSendChat(u8:decode(string.format('%s [%.3f]', HLcfg.main.jtext, time)))
else sampSendChat(u8:decode(HLcfg.main.jtext)) end
end
if HLcfg.main.utime then
time = os.clock() - time
sampAddChatMessage(string.format('{73B461}[Информация] {FFFFFF}Поздравляю! Теперь этот дом ваш! [%.3f]', time), -1)
return false
end
end
if text:find('%[Ошибка] {FFFFFF}Ответ неверный!') and color == -10270721 and time ~= nil and HLcfg.main.utime then
sampAddChatMessage(string.format('{FF6347}[Ошибка] {FFFFFF}Ответ неверный! [%.3f]', os.clock() - time), -1)
return false
end
if text:find('%[Ошибка] {FFFFFF}Неверный код!') and color == -10270721 and time ~= nil and HLcfg.main.utime then
sampAddChatMessage(string.format('{FF6347}[Ошибка] {FFFFFF}Неверный код! [%.3f]', os.clock() - time), -1)
return false
end
if text:find('%[Ошибка] {FFFFFF}Этот дом уже куплен!') and color == -10270721 and time ~= nil and HLcfg.main.utime then
sampAddChatMessage(string.format('{FF6347}[Ошибка] {FFFFFF}Этот дом уже куплен! [%.3f]', os.clock() - time), -1)
return false
end
if text:find('%[Ошибка] {FFFFFF}Этот бизнес уже кем то куплен') and color == -10270721 and time ~= nil and HLcfg.main.utime then
sampAddChatMessage(string.format('{FF6347}[Ошибка] {FFFFFF}Этот бизнес уже кем то куплен [%.3f]', os.clock() - time), -1)
return false
end
if text:find('>> {FF6347} Местом спавна автоматически назначен ваш дом. Изменить место спавна {FFFFFF}>>{FF6347} /setspawn!') and time ~= nil and HLcfg.main.utime then time = os.clock() - time end
end
function onWindowMessage(msg, wparam, lparam)
if msg == 0x100 or msg == 0x101 then
if wparam == vkeys.VK_ESCAPE and main_window_state.v and not isPauseMenuActive() then
consumeWindowMessage(true, false)
main_window_state.v = false
end
end
end
function reset()
lua_thread.create(function()
wait(4000)
time = nil
end)
end
function onScriptTerminate(script, quitGame)
if script == thisScript() then
inicfg.save(HLcfg, "HelperLovli")
end
end
function onQuitGame()
inicfg.save(HLcfg, "HelperLovli")
end
function GetRedMarkerCoords() -- snippet by SR_team, slightly modified
for i = 0, 31 do
local markerPtr = 0xC7F168 + i * 56
--local markerPtr = 0xC7DEC8 + i * 160
local x = representIntAsFloat(readMemory(markerPtr + 0, 4, false))
local y = representIntAsFloat(readMemory(markerPtr + 4, 4, false))
local z = representIntAsFloat(readMemory(markerPtr + 8, 4, false))
if x ~= 0.0 or y ~= 0.0 or z ~= 0.0 then
requestCollision(x, y); loadScene(x, y, z);
return x, y, z
end
end
return 0, 0, 0
end
function spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
-- return the iterator function
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
-- Lua s1xreq library for http ease
local http_socket = require('socket.http')
local https_socket = require('ssl.https')
local url_parser = require('socket.url')
local ltn12 = require('ltn12')
local json = require('cjson.safe')
local xml = require('xml')
local md5sum = require('md5') -- TODO: Make modular?
local base64 = require('base64')
--User facing function the make a request use Digest Authentication
--TODO: Determine what else should live in authentication
function s1xreq.HTTPDigestAuth(user, password)
return { _type = 'digest', user = user, password = password}
end
--User facing function the make a request use Basic Authentication
--TODO: Determine what else should live in authentication
function s1xreq.HTTPBasicAuth(user, password)
return { _type = 'basic', user = user, password = password}
end
function s1xreq.post(url, args)
return s1xreq.request("POST", url, args)
end
function s1xreq.get(url, args)
return s1xreq.request("GET", url, args)
end
function s1xreq.delete(url, args)
return s1xreq.request("DELETE", url, args)
end
function s1xreq.patch(url, args)
return s1xreq.request("PATCH", url, args)
end
function s1xreq.put(url, args)
return s1xreq.request("PUT", url, args)
end
function s1xreq.options(url, args)
return s1xreq.request("OPTIONS", url, args)
end
function s1xreq.head(url, args)
return s1xreq.request("HEAD", url, args)
end
function s1xreq.trace(url, args)
return s1xreq.request("TRACE", url, args)
end
--Sets up all the data for a request and makes the request
function s1xreq.request(method, url, args)
local request
if type(url) == "table" then
request = url
else
request = args or {}
request.url = url
end
request.method = method
_s1xreq.parse_args(request)
-- TODO: Find a better way to do this
if request.auth and request.auth._type == 'digest' then
local response = _s1xreq.make_request(request)
return _s1xreq.use_digest(response, request)
else
return _s1xreq.make_request(request)
end
end
--Makes a request
function _s1xreq.make_request(request)
local response_body = {}
local full_request = {
method = request.method,
url = request.url,
headers = request.headers,
source = ltn12.source.string(request.data),
sink = ltn12.sink.table(response_body),
redirect = request.allow_redirects,
proxy = request.proxy
}
local response = {}
local ok
local socket = string.find(full_request.url, '^https:') and not request.proxy and https_socket or http_socket
ok, response.status_code, response.headers, response.status = socket.request(full_request)
assert(ok, 'error in '..request.method..' request: '..response.status_code)
response.text = table.concat(response_body)
response.json = function () return json.decode(response.text) end
response.xml = function () return xml.load(response.text) end
return response
end
--Parses through all the possible arguments for a request
function _s1xreq.parse_args(request)
_s1xreq.check_url(request)
_s1xreq.check_data(request)
_s1xreq.create_header(request)
_s1xreq.check_timeout(request.timeout)
_s1xreq.check_redirect(request.allow_redirects)
end
--Format the the url based on the params argument
function _s1xreq.format_params(url, params) -- TODO: Clean
if not params or next(params) == nil then return url end
url = url..'?'
for key, value in pairs(params) do
if tostring(value) then
url = url..tostring(key)..'='
if type(value) == 'table' then
local val_string = ''
for _, val in ipairs(value) do
val_string = val_string..tostring(val)..','
end
url = url..val_string:sub(0, -2)
else
url = url..tostring(value)
end
url = url..'&'
end
end
return url:sub(0, -2)
end
--Check that there is a URL given and append to it if params are passed in.
function _s1xreq.check_url(request)
assert(request.url, 'No url specified for request')
request.url = _s1xreq.format_params(request.url, request.params)
end
-- Add to the HTTP header
function _s1xreq.create_header(request)
request.headers = request.headers or {}
request.headers['Content-Length'] = request.data:len()
if request.cookies then
if request.headers.cookie then
request.headers.cookie = request.headers.cookie..'; '..request.cookies
else
request.headers.cookie = request.cookies
end
end
if request.auth then
_s1xreq.add_auth_headers(request)
end
end
--Makes sure that the data is in a format that can be sent
function _s1xreq.check_data(request)
request.data = request.data or ''
if type(request.data) == "table" then
request.data = json.encode(request.data)
end
end
--Set the timeout
function _s1xreq.check_timeout(timeout)
http_socket.TIMEOUT = timeout or 5
https_socket.TIMEOUT = timeout or 5
end
--Checks is allow_redirects parameter is set correctly
function _s1xreq.check_redirect(allow_redirects)
if allow_redirects and type(allow_redirects) ~= "boolean" then
error("allow_redirects expects a boolean value. received type = "..type(allow_redirects))
end
end
--Create the Authorization header for Basic Auth
function _s1xreq.basic_auth_header(request)
local encoded = base64.encode(request.auth.user..':'..request.auth.password)
request.headers.Authorization = 'Basic '..encoded
end
-- Create digest authorization string for request header TODO: Could be better, but it should work
function _s1xreq.digest_create_header_string(auth)
local authorization = ''
authorization = 'Digest username="'..auth.user..'", realm="'..auth.realm..'", nonce="'..auth.nonce
authorization = authorization..'", uri="'..auth.uri..'", qop='..auth.qop..', nc='..auth.nc
authorization = authorization..', cnonce="'..auth.cnonce..'", response="'..auth.response..'"'
if auth.opaque then
authorization = authorization..', opaque="'..auth.opaque..'"'
end
return authorization
end
--MD5 hash all parameters
local function md5_hash(...)
return md5sum.sumhexa(table.concat({...}, ":"))
end
-- Creates response hash TODO: Add functionality
function _s1xreq.digest_hash_response(auth_table)
return md5_hash(
md5_hash(auth_table.user, auth_table.realm, auth_table.password),
auth_table.nonce,
auth_table.nc,
auth_table.cnonce,
auth_table.qop,
md5_hash(auth_table.method, auth_table.uri)
)
end
-- Add digest authentication to the request header
function _s1xreq.digest_auth_header(request)
if not request.auth.nonce then return end
request.auth.cnonce = request.auth.cnonce or string.format("%08x", os.time())
request.auth.nc_count = request.auth.nc_count or 0
request.auth.nc_count = request.auth.nc_count + 1
request.auth.nc = string.format("%08x", request.auth.nc_count)
local url = url_parser.parse(request.url)
request.auth.uri = url_parser.build{path = url.path, query = url.query}
request.auth.method = request.method
request.auth.qop = 'auth'
request.auth.response = _s1xreq.digest_hash_response(request.auth)
request.headers.Authorization = _s1xreq.digest_create_header_string(request.auth)
end
--Checks the resonse code and adds additional headers for Digest Auth
-- TODO: Rename this
function _s1xreq.use_digest(response, request)
if response.status_code == 401 then
_s1xreq.parse_digest_response_header(response,request)
_s1xreq.create_header(request)
response = _s1xreq.make_request(request)
response.auth = request.auth
response.cookies = request.headers.cookie
return response
else
response.auth = request.auth
response.cookies = request.headers.cookie
return response
end
end
--Parse the first response from the host to make the Authorization header
function _s1xreq.parse_digest_response_header(response, request)
for key, value in response.headers['www-authenticate']:gmatch('(%w+)="(%S+)"') do
request.auth[key] = value
end
if request.headers.cookie then
request.headers.cookie = request.headers.cookie..'; '..response.headers['set-cookie']
else
request.headers.cookie = response.headers['set-cookie']
end
request.auth.nc_count = 0
end
-- Call the correct authentication header function
function _s1xreq.add_auth_headers(request)
local auth_func = {
basic = _s1xreq.basic_auth_header,
digest = _s1xreq.digest_auth_header
}
auth_func[request.auth._type](request)
end
local function str2bei(s)
local v=0
for i=1, #s do
v = v * 256 + string.byte(s, i)
end
return v
end
function md5_tohex(s)
return string.format("%08x%08x%08x%08x", str2bei(string.sub(s, 1, 4)), str2bei(string.sub(s, 5, 8)), str2bei(string.sub(s, 9, 12)), str2bei(string.sub(s, 13, 16)))
end
Последнее редактирование: