local ev = require 'lib.samp.events'
local inicfg = require 'inicfg'
local memory = require 'memory'
created = false
created2 = false
tag = '{73b461}[HP HUD] '
local cfg = inicfg.load({
main = {
active = true,
text = 3,
style = 1,
pos = 2
}
}, "HPHUD by Azimoff")
function getpos()
if cfg.main.pos == 1 then
return 548
end
if cfg.main.pos == 2 then
return 577
end
if cfg.main.pos == 3 then
return 606
end
end
function msg(param)
sampAddChatMessage(tag..""..param, -1)
end
function stringhp(param)
if cfg.main.style == 1 then
return '_'..param
end
if cfg.main.style == 0 then
return ''
end
end
function ev.onSendClickTextDraw(id)
if invopened and id == 65535 then
invopened = false
end
end
function onReceiveRpc(id, bs, priority, reliability)
if id == 83 then
print(raknetBitStreamReadBool(bs))
invopened = raknetBitStreamReadBool(bs)
end
end
function main()
while not isSampAvailable() do wait(100) end
msg("{ffffff}Загружен! {DC4747}/hphelp {ffffff}by Azimoff")
sampRegisterChatCommand("hphud", hphud)
sampRegisterChatCommand("hpstyle", hpstyle)
sampRegisterChatCommand("hppos", hppos)
sampRegisterChatCommand("hpt", hpt)
sampRegisterChatCommand("hphelp", hphelp)
while true do wait(0)
if sampIsLocalPlayerSpawned() and not created then
sampTextdrawCreate(500, "_", getpos(), 66.500)
created = true
end
if created and not sampTextdrawIsExists(500) then
created = false
end
if created2 and not sampTextdrawIsExists(501) then
created2 = false
end
if created then
if not created2 then
if getCharArmour(playerPed) >= 1 then
sampTextdrawCreate(501, "_", getpos(), 44.500)
created2 = true
end
end
sampTextdrawSetLetterSizeAndColor(500, 0.270, 0.900, 4294967295)
sampTextdrawSetPos(500, getpos(), 66.500)
sampTextdrawSetStyle(500, cfg.main.text)
sampTextdrawSetAlign(500, cfg.main.pos)
sampTextdrawSetOutlineColor(500, 1, 4278190080)
if cfg.main.active and not sampIsScoreboardOpen() and not invopened then
local hp = getCharHealth(playerPed)
sampTextdrawSetString(500, hp..""..stringhp('hp'))
else
sampTextdrawSetString(500, "_")
end
end
if created2 then
sampTextdrawSetLetterSizeAndColor(501, 0.270, 0.900, 4294967295)
sampTextdrawSetPos(501, getpos(), 44.500)
sampTextdrawSetStyle(501, cfg.main.text)
sampTextdrawSetAlign(501, cfg.main.pos)
sampTextdrawSetOutlineColor(501, 1, 4278190080)
if cfg.main.active and getCharArmour(playerPed) >= 1 and not sampIsScoreboardOpen() and not invopened then
local hp = getCharArmour(playerPed)
sampTextdrawSetString(501, hp..""..stringhp('ap'))
else
sampTextdrawSetString(501, "_")
end
end
end
end
function onScriptTerminate(script, quitGame)
if script == thisScript() then
if created then
sampTextdrawDelete(500)
end
if created2 then
sampTextdrawDelete(501)
end
inicfg.save(cfg, "HPHUD by Azimoff")
end
end
function hphelp()
sampShowDialog(5152,'{c2c2c2}[HP HUD] {DC4747}by azimoff',"{c2c2c2}Команды для управления {DC4747}HP HUD{c2c2c2}'ом:\n\n{DC4747}1. {73b461}/hphud {c2c2c2}- Включает и отключает HP HUD\n{DC4747}2. {73b461}/hpstyle {c2c2c2}- {ffffff}[0-3] {c2c2c2}- Изменяет стиль шрифта показателя\n{DC4747}3. {73b461}/hpt {c2c2c2}- Добавляет/Убирает буквы в показателе\n{DC4747}4. {73b461}/hppos {c2c2c2}- {ffffff}[1-3] {c2c2c2}- Изменяет позицию показателя\n{DC4747}5. {73b461}/hphelp {c2c2c2}- Вызов окна помощи", "Понятно", "", 0)
end
function hppos(param)
if tonumber(param) and tonumber(param) <= 3 and tonumber(param) >= 1 then
msg("{ffffff}Установлена позиция: {DC4747}"..param)
cfg.main.pos = tonumber(param)
else
msg("{ffffff}Используйте {DC4747}/hppos {ffffff}- [1 - 3]")
end
end
function hpt()
if cfg.main.style == 1 then
msg("{ffffff}Установлен стиль худа: {DC4747}0")
cfg.main.style = 0
else
msg("{ffffff}Установлен стиль худа: {DC4747}1")
cfg.main.style = 1
end
end
function hpstyle(param)
if tonumber(param) and tonumber(param) <= 3 and tonumber(param) >= 0 then
cfg.main.text = param
msg("{ffffff}Установлен шрифт: {DC4747}"..param)
cfg.main.text = param
else
msg("{ffffff}Используйте {DC4747}/hpstyle {ffffff}- [0, 1, 2, 3]")
end
end
function hphud()
cfg.main.active = not cfg.main.active
if cfg.main.active then
msg("{ffffff}Активирован!")
else
msg("{DC4747}Выключен")
end
end