script_name('shelper2.0')
script_author('ne4estno')
script_version(1.0)
require 'lib.moonloader'
require "moonloader"
local keys = require 'vkeys'
local imgui = require 'imgui'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
local samp = require 'lib.samp.events'
local mem = require('memory')
encoding.default = 'CP1251'
u8 = encoding.UTF8
if not doesFileExist('moonloader\\config\\shelper2.0.ini') then
if not doesDirectoryExist('moonloader\\config') then
createDirectory('moonloader\\config')
end
ini = {
settings = {
secs = 0,
mins = 0,
hours = 0,
counter = 0,
nameknpk1_1 = ""
}
}
inicfg.save(ini, 'shelper2.0')
end
id = 0
qcounter = 0
disable_cursor_gui = imgui.ImBool(false)
show_main_timer = imgui.ImBool(false)
show_main_window = imgui.ImBool(false)
redact = imgui.ImBool(false)
entervk = imgui.ImBool(false)
ALTX = imgui.ImBool(false)
my_color = 0xFF5511
resX, resY = getScreenResolution()
sduty = false
t = {}
c1 = 0
c2 = 0
t[c1] = 'Нет вопроса.'
test_text_buffer = imgui.ImBuffer(256)
knpk1 = imgui.ImBuffer(256) nameknpk1 = imgui.ImBuffer(256)
knpk2 = imgui.ImBuffer(256) nameknpk2 = imgui.ImBuffer(256)
knpk3 = imgui.ImBuffer(256) nameknpk3 = imgui.ImBuffer(256)
knpk4 = imgui.ImBuffer(256) nameknpk4 = imgui.ImBuffer(256)
knpk5 = imgui.ImBuffer(256) nameknpk5 = imgui.ImBuffer(256)
knpk6 = imgui.ImBuffer(256) nameknpk6 = imgui.ImBuffer(256)
knpk7 = imgui.ImBuffer(256) nameknpk7 = imgui.ImBuffer(256)
knpk8 = imgui.ImBuffer(256) nameknpk8 = imgui.ImBuffer(256)
show_main_knpk1 = imgui.ImBool(false)
show_main_knpk2 = imgui.ImBool(false)
show_main_knpk3 = imgui.ImBool(false)
show_main_knpk4 = imgui.ImBool(false)
show_main_knpk5 = imgui.ImBool(false)
show_main_knpk6 = imgui.ImBool(false)
show_main_knpk7 = imgui.ImBool(false)
show_main_knpk8 = imgui.ImBool(false)
tempsecs = 0
tempmins = 0
temphours = 0
cfg = inicfg.load(nil, 'shelper2.0')
lua_thread.create(function()
while true do
wait(1000)
if sduty == true then
cfg.settings.secs = cfg.settings.secs + 1
if cfg.settings.secs > 59 then
cfg.settings.secs = 0
cfg.settings.mins = cfg.settings.mins + 1
end
if cfg.settings.mins > 59 then
cfg.settings.mins = 0
cfg.settings.hours = cfg.settings.hours + 1
end
tempsecs = tempsecs + 1
if tempsecs > 59 then
tempsecs = 0
tempmins = tempmins + 1
end
if tempmins > 59 then
tempmins = 0
temphours = temphours + 1
end
end
end
end)
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
supportname = sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
sampRegisterChatCommand('shelper1', shelper_cmd)
sampAddChatMessage('{FFFFFF}Скрипт {FF5511}shelper2.0 {FFFFFF}успешно запущен. {FF5511}/shelper', my_color)
sampAddChatMessage('{FFFFFF}Автор {FF5511}ne4estno. {FFFFFF}Переписанный скрипт {FF5511}Nishikinov-а{FFFFFF}.', my_color)
--БЕСКОНЕЧНЫЙ БЛОК--------------------------------
while true do
wait(0)
if isKeyJustPressed(164) and isKeyJustPressed(88) and ALTX.v then
windowm2()
end
if isKeyJustPressed(13) and entervk.v then
if show_main_window.v and test_text_buffer.v ~= nil and id ~= nil then
var1 = (u8:decode('/ans '..id.." "..test_text_buffer.v))
test_text_buffer.v = " "
c2 = c2 + 1
sampSendChat(var1)
elseif show_main_window.v and test_text_buffer.v ~= nil and id == nil then
sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color)
end
end
end
--КОНЕЦ БЕСКОНЕЧНОГО БЛОКА------------------------
end
function samp.onServerMessage(color, text)
if text:find(supportname) and text:find("вышел на дежурство") then
sduty = true
print('Успешно вышли на дежурство.')
elseif text:find(supportname) and text:find("покинул дежурство") then
sduty = false
print('Успешно покинули дежурство.')
show_main_window.v = false
elseif text:find(supportname) and text:find("Оператор") and text:find("ответил") then
qcounter = qcounter + 1
cfg.settings.counter = cfg.settings.counter + 1
end
if text:find("Вопрос от") then
strk = text:match("Вопрос от (.*)")
c1 = c1 + 1
t[c1] = strk
end
end
function shelper_cmd()
if sduty then
show_main_window.v = not show_main_window.v
imgui.Process = true
else
sampAddChatMessage('Вы не раб (саппорт) или не на sduty.', my_color)
end
end
function windowm2()
show_main_window.v = not show_main_window.v
end
function imgui.OnDrawFrame()
if show_main_window.v then
imgui.ShowCursor = true
else
imgui.ShowCursor = false
imgui.SetMouseCursor(imgui.MouseCursor.None)
end
if show_main_window.v then
imgui.SetNextWindowSize(imgui.ImVec2(740, 300), imgui.Cond.FirstUseEver)
imgui.Begin(u8'shelper - главное окно.',windowm2,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
if t[c2] == nil then imguitext = "Нет вопроса." else imguitext = t[c2] end
imgui.BeginChild("change", imgui.ImVec2(700, 45), true)
imgui.Text(u8(imguitext)) id = imguitext:match("%[(%d+)%]")
imgui.EndChild()
imgui.InputText(u8'Текущий вопрос.', test_text_buffer) imgui.SameLine() if imgui.Button(u8("Ответить.")) then if id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else var1 = (u8:decode('/ans '..id.." "..test_text_buffer.v)) test_text_buffer.v = " " c2 = c2 + 1 sampSendChat(var1) end end
imgui.Separator()
if imgui.Button(u8("Предыдущий вопрос.")) then c2 = c2 - 1 end imgui.SameLine()
if imgui.Button(u8("Следующий вопрос.")) then c2 = c2 + 1 end
peredal = 'Передал ваш вопрос администрации.'
imgui.SameLine() if imgui.Button(u8("Передать администрации.")) and id ~= nil then sampSendChat('/h [SCRIPT] Администрация, '..imguitext) var2 = ('/ans ' ..id.." "..peredal) sampSendChat(var2) end
imgui.BeginChild("change1", imgui.ImVec2(700, 85), true)
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk1.v))) then if redact.v then show_main_knpk1.v = not show_main_knpk1.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk1.v)) end end
imgui.SameLine()
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk2.v))) then if redact.v then show_main_knpk2.v = not show_main_knpk2.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk2.v)) end end imgui.SameLine()
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk3.v))) then if redact.v then show_main_knpk3.v = not show_main_knpk3.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk3.v)) end end imgui.SameLine()
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk4.v))) then if redact.v then show_main_knpk4.v = not show_main_knpk4.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk4.v)) end end
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk5.v))) then if redact.v then show_main_knpk5.v = not show_main_knpk5.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk5.v)) end end imgui.SameLine()
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk6.v))) then if redact.v then show_main_knpk6.v = not show_main_knpk6.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk1.v)) end end imgui.SameLine()
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk7.v))) then if redact.v then show_main_knpk7.v = not show_main_knpk7.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk7.v)) end end imgui.SameLine()
if imgui.Button(u8("Кнопка - " ..u8:decode(nameknpk8.v))) then if redact.v then show_main_knpk8.v = not show_main_knpk8.v elseif id == nil then sampAddChatMessage('В строке нет вопроса, нажмите "следующий", если не помогло - ждите.', my_color) else sampSendChat('/ans ' ..id.." "..u8:decode(knpk8.v)) end end imgui.EndChild()
imgui.Checkbox(u8"Редактировать кнопки.", redact) imgui.SameLine() imgui.Checkbox(u8"Выводить таймер.", show_main_timer) imgui.SameLine() imgui.Checkbox(u8"Ответ при двойном нажатии на Enter.", entervk)
imgui.Checkbox(u8"Скрывать/открывать окно ALT + X", ALTX)
imgui.End()
end
if show_main_timer.v and sduty then
imgui.SetNextWindowPos(imgui.ImVec2(resX-170, resY-125))
imgui.SetNextWindowSize(imgui.ImVec2(155, 100), imgui.Cond.FirstUseEver)
imgui.Begin(u8'таймер',show_main_timer,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.Text(u8'Сессия: '..temphours..':' ..tempmins..':'..tempsecs)
imgui.Text(u8'Общий: '..cfg.settings.hours..':'..cfg.settings.mins..':'..cfg.settings.secs)
imgui.Text(u8'Ответов за сессию: '..qcounter)
imgui.Text(u8'Ответов всего: '..cfg.settings.counter)
imgui.End()
end
if show_main_knpk1.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 1.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk1)
imgui.InputText(u8'Ответ.', knpk1)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk1.v = not show_main_knpk1.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk2.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 2.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk2)
imgui.InputText(u8'Ответ.', knpk2)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk2.v = not show_main_knpk2.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk3.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 3.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk3)
imgui.InputText(u8'Ответ.', knpk3)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk3.v = not show_main_knpk3.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk4.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 4.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk4)
imgui.InputText(u8'Ответ.', knpk4)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk4.v = not show_main_knpk4.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk5.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 5.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk5)
imgui.InputText(u8'Ответ.', knpk5)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk5.v = not show_main_knpk5.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk6.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 6.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk6)
imgui.InputText(u8'Ответ.', knpk6)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk6.v = not show_main_knpk6.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk7.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 7.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk7)
imgui.InputText(u8'Ответ.', knpk7)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk7.v = not show_main_knpk7.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
if show_main_knpk8.v then
imgui.SetNextWindowSize(imgui.ImVec2(600, 125), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Переназначение клавиши 8.', nil ,imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar)
imgui.InputText(u8'Добавить в название.', nameknpk8)
imgui.InputText(u8'Ответ.', knpk8)
if imgui.Button(u8("Сохранить.")) then
show_main_knpk8.v = not show_main_knpk8.v
redact.v = false
inicfg.save(cfg, 'shelper2.0')
end
imgui.End()
end
end
lua_thread.create(function ()
while true do
wait(1000)
cfg.settings.secs = cfg.settings.secs
cfg.settings.mins = cfg.settings.mins
cfg.settings.hours = cfg.settings.hours
cfg.settings.counter = cfg.settings.counter
inicfg.save(cfg, 'shelper2.0')
end
end)
function changeNum(newSize)
cfg.settings = newSize
inicfg.save(cfg, 'shelper2.0')
end
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(15, 15)
style.WindowRounding = 6.0
style.FramePadding = ImVec2(5, 5)
style.FrameRounding = 4.0
style.ItemSpacing = ImVec2(12, 8)
style.ItemInnerSpacing = ImVec2(8, 6)
style.IndentSpacing = 25.0
style.ScrollbarSize = 15.0
style.ScrollbarRounding = 9.0
style.GrabMinSize = 5.0
style.GrabRounding = 3.0
colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
colors[clr.TitleBg] = ImVec4(0.76, 0.31, 0.00, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
colors[clr.TitleBgActive] = ImVec4(0.10, 0.09, 0.12, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
colors[clr.CheckMark] = ImVec4(1.00, 0.42, 0.00, 0.53)
colors[clr.SliderGrab] = ImVec4(1.00, 0.42, 0.00, 0.53)
colors[clr.SliderGrabActive] = ImVec4(1.00, 0.42, 0.00, 1.00)
colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
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.40, 0.39, 0.38, 0.63)
colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)