script_name('ScareHelper')
script_author('Bredd Lane')
require 'lib.moonloader'
local imgui = require 'imgui'
local sampev = require "samp.events"
local vkeys = require 'vkeys'
local imadd = require 'imgui_addons'
local rkeys = require 'rkeys'
if not doesDirectoryExist('moonloader/config') then
createDirectory('moonloader\\config')
end
local inicfg = require 'inicfg'
local file = 'ScareHelper.ini'
local mainIni = inicfg.load({
main = {
scareKey = encodeJson({VK_R}),
checkscare = false,
checkblock = false,
}
},file)
if not doesFileExist('moonloader/config/'..file) then
inicfg.save(mainIni,file)
end
local scareKey = {
v = decodeJson(mainIni.main.scareKey)
}
local checkscare = imgui.ImBool(mainIni.main.checkscare)
local checkblock = imgui.ImBool(mainIni.main.checkblock)
local main_window_state = imgui.ImBool(false)
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8
function onWindowMessage(msg, wparam, lparam)
if msg == 0x100 or msg == 0x101 then
if (wparam == 0x1B and main_window_state.v) and not isPauseMenuActive() and not sampIsChatInputActive() and not isSampfuncsConsoleActive() and not sampIsDialogActive() then
consumeWindowMessage(true, false)
if msg == 0x101 then
main_window_state.v = false
end
end
end
end
function isKeysDown(keylist)
local tKeys = keylist
local bool = false
local isDownIndex = 0
local key = #tKeys < 2 and tonumber(tKeys[1]) or tonumber(tKeys[#tKeys])
if #tKeys < 2 then
if not isKeyDown(VK_RMENU) and not isKeyDown(VK_LMENU) and not isKeyDown(VK_LSHIFT) and not isKeyDown(VK_RSHIFT) and not isKeyDown(VK_LCONTROL) and not isKeyDown(VK_RCONTROL) then
if wasKeyPressed(key) then
bool = true
end
end
else
if isKeyDown(tKeys[1]) then
if isKeyDown(tKeys[2]) then
if tKeys[3] ~= nil then
if isKeyDown(tKeys[3]) then
if tKeys[4] ~= nil then
if isKeyDown(tKeys[4]) then
if tKeys[5] ~= nil then
if isKeyDown(tKeys[5]) then
if wasKeyPressed(key) then
bool = true
end
end
else
if wasKeyPressed(key) then
bool = true
end
end
end
else
if wasKeyPressed(key) then
bool = true
end
end
end
else
if wasKeyPressed(key) then
bool = true
end
end
end
end
end
if nextLockKey == keylist then
bool = false
nextLockKey = ""
end
return bool
end
function imgui.TextQuestion(text)
imgui.TextDisabled('?')
if imgui.IsItemHovered() then
imgui.BeginTooltip()
imgui.PushTextWrapPos(450)
imgui.TextUnformatted(text)
imgui.PopTextWrapPos()
imgui.EndTooltip()
end
end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage('{3660E9}[ScareHelper]{FFFFFF} Загружен! Команда - /scareh. Автор - Bredd Lane',-1)
sampRegisterChatCommand('scareh', ScareHelper)
while true do
wait(0)
theme()
imgui.Process = main_window_state.v
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
local result, id = sampGetPlayerIdByCharHandle(ped)
if result then
if checkscare.v and doesCharExist(ped) and isKeysDown(scareKey.v) and not isPauseMenuActive() and not sampIsChatInputActive() and not isSampfuncsConsoleActive() and not sampIsDialogActive() then
sampSendChat('/scare '..id)
end
end
mainIni.main.scareKey = encodeJson(scareKey.v)
mainIni.main.checkblock = checkblock.v
mainIni.main.checkscare = checkscare.v
inicfg.save(mainIni,file)
end
end
function ScareHelper()
main_window_state.v = not main_window_state.v
end
function imgui.OnDrawFrame()
imgui.ShowCursor = main_window_state.v
if main_window_state.v then
local sw, sh = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(200, 80), imgui.Cond.FirstUseEver)
imgui.Begin('ScareHelper', main_window_state, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
imgui.Checkbox('FastScare', checkscare)
imgui.SameLine()
imgui.TextQuestion(u8'При прицеливании на игрока и нажатии на "'..table.concat(rkeys.getKeysName(scareKey.v), " + ")..u8'" прописывается /scare и ID игрока, на которого вы прицелились.')
if checkscare.v then
imgui.SameLine()
imadd.HotKey('##scarekey', scareKey, {}, 100)
end
imgui.Checkbox('BlockScare', checkblock)
imgui.SameLine()
imgui.TextQuestion(u8'Если вас напугают, то дьявол не высветится на весь ваш экран.')
imgui.End()
end
end
function sampev.onShowTextDraw(id, data)
if checkblock.v and (id == 507 or id == 508) then
return false
end
end
function theme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowPadding = imgui.ImVec2(4, 4)
style.WindowRounding = 10
style.ChildWindowRounding = 5
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 13.0
style.ScrollbarRounding = 10
style.GrabMinSize = 8
style.GrabRounding = 1
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00)
colors[clr.TextDisabled] = ImVec4(0.36, 0.42, 0.47, 1.00)
colors[clr.WindowBg] = ImVec4(0.11, 0.15, 0.17, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
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.FrameBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.12, 0.20, 0.28, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00)
colors[clr.TitleBg] = ImVec4(0.09, 0.12, 0.14, 0.65)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.TitleBgActive] = ImVec4(0.08, 0.10, 0.12, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39)
colors[clr.ScrollbarGrab] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.09, 0.21, 0.31, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.CheckMark] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.37, 0.61, 1.00, 1.00)
colors[clr.Button] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.ButtonActive] = ImVec4(0.06, 0.53, 0.98, 1.00)
colors[clr.Header] = ImVec4(0.20, 0.25, 0.29, 0.55)
colors[clr.HeaderHovered] = ImVec4(0.26, 0.59, 0.98, 0.80)
colors[clr.HeaderActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.26, 0.59, 0.98, 0.25)
colors[clr.ResizeGripHovered] = ImVec4(0.26, 0.59, 0.98, 0.67)
colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 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.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
colors[clr.ModalWindowDarkening] = ImVec4(0.20, 0.20, 0.20, 0.35);
end