script_version('1.0')
script_name('Daniels Helper')
require 'lib.moonloader'
local imgui = require 'imgui'
local key = require 'vkeys'
local inicfg = require 'inicfg'
local lib = require 'lib.samp.events'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local mainIni = inicfg.load({
config =
{
famsms = " "
}
}, 'Daniels Helper')
local playerTargeting = -1
local gettheme = 1
local toggle = false
local ImBool1 = imgui.ImBool(false)
local ImBool2 = imgui.ImBool(false)
local ImBool3 = imgui.ImBool(false)
local wind = imgui.ImBool(false)
local settings_window = imgui.ImBool(false)
local famsms = imgui.ImBuffer(''..mainIni.config.famsms, 500)
local status = inicfg.load(mainIni, 'Daniels Helper.ini')
if not doesFileExist('moonloader/config/Daniels Helper.ini') then inicfg.save(mainIni, 'Daniels Helper.ini') end
function imgui.OnDrawFrame()
imgui.ShowCursor = wind.v
local sw, sh = getScreenResolution()
if wind.v then
imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) --положение основного окна
imgui.SetNextWindowSize(imgui.ImVec2(600, 500), imgui.Cond.FirstUseEver)--размер основного окна
imgui.Begin('DanielsHelper', wind)
imgui.PushItemWidth(150)
imgui.SetCursorPos(imgui.ImVec2(435, 25))
end imgui.PopItemWidth()
imgui.SetCursorPos(imgui.ImVec2(7, 50))
imgui.BeginChild('##id', imgui.ImVec2(580, 30), true)
if (playerTargeting >= 0) then
local name = sampGetPlayerNickname(tostring(playerTargeting))
imgui.Text(u8' Цель: '..name..'('..tostring(playerTargeting)..')')
end
if (playerTargeting < 0) then
imgui.Text(u8' Цель: Not Found')
end
imgui.EndChild()
imgui.SetCursorPos (imgui.ImVec2(7, 85))
imgui.BeginChild('##1', imgui.ImVec2(190, 180), true)
local btn_size = imgui.ImVec2(-0.1, 0)
imgui.Text(u8'Общение')
imgui.Separator()
if imgui.Button(u8'Приветствие в чате семьи', btn_size) then
sampSendChat("/fam "..mainIni.config.famsms)
end
imgui.InputText('', famsms)
imgui.SameLine()
imgui.TextQuestion(u8'Вводить без /fam')
if imgui.Button(u8'Приветствие нового члена!', btn_size) then
sampSendChat('/fam Добро пожаловать в гей клуб!')
end
if imgui.Button(u8'Поздравить с ДР', btn_size) then
sampSendChat('/fam Поздравляю с ДР! Счастья, здоровья!')
end
imgui.EndChild()
imgui.BeginChild('##2', imgui.ImVec2(190, 180), true)
imgui.Text(u8'Перс')
imgui.Separator()
if imgui.Button(u8'Броня', btn_size) then
sampSendChat("/armour")
end
if imgui.Button(u8'Маска', btn_size) then
sampSendChat('/mask')
end
if imgui.Button(u8'Телефон', btn_size) then
sampSendChat('/phone')
end
if imgui.Button(u8'Статистика', btn_size) then
sampSendChat('/stats')
end
if imgui.Button(u8'Выход из игры', btn_size) then
sampProcessChatInput ("/q")
end
imgui.EndChild()
------------------------------
imgui.SameLine()
--2 блок
------------------------------
imgui.SetCursorPos(imgui.ImVec2(204, 85))
imgui.BeginChild('##3', imgui.ImVec2(190, 180), true)
imgui.Text(u8'Здоровье')
imgui.Separator()
if imgui.Button(u8'Покушать за 300$', btn_size) then
sampSendClickTextdraw(645)
end
if imgui.Button(u8'Нарко 3г', btn_size) then
sampSendChat('/usedrugs 3')
end
if imgui.Button(u8'Попить водяры за 500$', btn_size) then
sampSendClickTextdraw(644)
end
imgui.EndChild()
imgui.SetCursorPos(imgui.ImVec2(204, 269))
imgui.BeginChild('##4', imgui.ImVec2(190, 180), true)
imgui.Text('Cars')
imgui.Separator()
if imgui.Button(u8'Заправить', btn_size) then
sampSendChat("/fillcar")
end
if imgui.Button(u8'Починка', btn_size) then
sampSendChat('/repcar')
end
if imgui.Button(u8'Закрыть кар', btn_size) then
sampSendChat('/lock')
end
if imgui.Button(u8'Вставить/вытащить ключи', btn_size) then
sampSendChat('/key')
end
imgui.EndChild()
------------------------------------
imgui.SameLine()
--3 блок
------------------------------------
imgui.SetCursorPos(imgui.ImVec2(401, 85))
imgui.BeginChild('##5', imgui.ImVec2(190, 180), true)
imgui.Text(u8'Взаимодействие с игроками')
imgui.Separator()
if imgui.Button(u8'Трейд', btn_size) then
sampSendChat('/trade '..tostring(playerTargeting))
end
if imgui.Button(u8'Паспорт', btn_size) then
sampSendChat('/showpass '..tostring(playerTargeting))
end
if imgui.Button(u8'Мед. карта', btn_size) then
sampSendChat('/showmc '..tostring(playerTargeting))
end
if imgui.Button(u8'Лицензии', btn_size) then
sampSendChat('/showlic '..tostring(playerTargeting))
end
if imgui.Button(u8'Передать 10к', btn_size) then
sampSendChat('/pay '..tostring(playerTargeting)..' 10000')
end
imgui.EndChild()
imgui.SetCursorPos(imgui.ImVec2(401, 269))
imgui.BeginChild('##6', imgui.ImVec2(190, 180), true)
imgui.Text(u8'В разработке')
imgui.Separator()
imgui.EndChild()
imgui.SetCursorPos(imgui.ImVec2(8, 453))
imgui.BeginChild('##2wind', imgui.ImVec2(583, 30), true)
imgui.EndChild()
imgui
imgui.End()
end
function main()
autoupdate("https://api.jsonbin.io/b/5dcedf7dee15a6060aa203f4", '['..string.upper(thisScript().name)..']: ', "https://www.dropbox.com/s/44qjpq610vhnxs6/Daniels%20Helper.lua?dl=0")
if not isSampfuncsLoaded() or not isSampLoaded() then
return
end
while not isSampAvailable() do
wait(0)
end
sampRegisterChatCommand('danh', function() wind.v = not wind.v end)
sampAddChatMessage('{FF0000}[Daniels Helper]: {FFFFFF}Успешно загружен', -1)
sampAddChatMessage('{FF0000}[Daniels Helper]: {FFFFFF}Активация - Q+E или /danh', -1)
while true do
wait(0)
if wasKeyPressed(key.VK_E) and wasKeyPressed(key.VK_Q) then -- активация
wind.v = not wind.v
end
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
if valid and doesCharExist(ped) then
local result, id = sampGetPlayerIdByCharHandle(ped)
if result then
playerTargeting = id
end
end
imgui.Process = wind.v
end
end
function apply_custom_style()
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
apply_custom_style()
function blueTheme()
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
blueTheme()
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 GetTheme()
if gettheme == 1 then apply_custom_style()
elseif gettheme == 2 then blueTheme() end
end
GetTheme()
function autoupdate(json_url, prefix, url)
local dlstatus = require('moonloader').download_status
local json = getWorkingDirectory() .. '\\'..thisScript().name..'-version.json'
if doesFileExist(json) then os.remove(json) end
downloadUrlToFile(json_url, json,
function(id, status, p1, p2)
if status == dlstatus.STATUSEX_ENDDOWNLOAD then
if doesFileExist(json) then
local f = io.open(json, 'r')
if f then
local info = decodeJson(f:read('*a'))
updatelink = info.updateurl
updateversion = info.latest
f:close()
os.remove(json)
if updateversion ~= thisScript().version then
lua_thread.create(function(prefix)
local dlstatus = require('moonloader').download_status
local color = -1
sampAddChatMessage((prefix..'Обнаружено обновление. Пытаюсь обновиться c '..thisScript().version..' на '..updateversion), color)
wait(250)
downloadUrlToFile(updatelink, thisScript().path,
function(id3, status1, p13, p23)
if status1 == dlstatus.STATUS_DOWNLOADINGDATA then
print(string.format('Загружено %d из %d.', p13, p23))
elseif status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
print('Загрузка обновления завершена.')
sampAddChatMessage((prefix..'Обновление завершено!'), color)
goupdatestatus = true
lua_thread.create(function() wait(500) thisScript():reload() end)
end
if status1 == dlstatus.STATUSEX_ENDDOWNLOAD then
if goupdatestatus == nil then
sampAddChatMessage((prefix..'Обновление прошло неудачно. Запускаю устаревшую версию..'), color)
update = false
end
end
end
)
end, prefix
)
else
update = false
print('v'..thisScript().version..': Обновление не требуется.')
end
end
else
print('v'..thisScript().version..': Не могу проверить обновление. Смиритесь или проверьте самостоятельно на '..url)
update = false
end
end
end
)
while update ~= false do wait(100) end
end