-- Rodina RP STAMINA HUD
local wm = require 'lib.windows.message'
local inicfg = require 'inicfg'
local memory = require 'memory'
local directIni = 'rodina_stamina.ini'
local ini = inicfg.load({
main = {
x = 35,
y = 420,
}
}, directIni)
inicfg.save(ini, directIni)
local changePos = false
local sX, sY = getScreenResolution()
local font_size = sY / 128
local font = renderCreateFont('Tahoma', font_size, 5)
addEventHandler("onWindowMessage", function(msg, wp, lp)
if changePos then
if msg == wm.WM_LBUTTONDOWN then
consumeWindowMessage(true, false)
end
if msg == wm.WM_LBUTTONUP then
changePos = false
showCursor(false)
inicfg.save(ini, directIni)
end
end
end)
function main()
while not isSampAvailable() do
wait(0)
end
sampAddChatMessage("{00CC66}[STAMINA]{FFFFFF} Загружен. /staminapos", -1)
sampRegisterChatCommand('staminapos', function()
changePos = true
showCursor(true)
sampAddChatMessage("{00CC66}[STAMINA]{FFFFFF} Перетащи HUD мышкой.", -1)
end)
while true do
wait(0)
if not isCharOnFoot(PLAYER_PED) then
goto continue
end
renderStamina()
::continue::
end
end
function renderStamina()
if changePos then
local posX, posY = getCursorPos()
ini.main.x = posX
ini.main.y = posY
end
local stamina = getPlayerStamina()
local text = string.format("Стамина: %d%%", stamina)
local height = renderGetFontDrawHeight(font)
local width = renderGetFontDrawTextLength(font, text) + 16
-- фон
renderDrawBox(
ini.main.x,
ini.main.y,
width,
height + 6,
0x70000000
)
renderDrawBox(
ini.main.x - 3,
ini.main.y,
3,
height + 6,
0xFF00AA55
)
renderFontDrawText(
font,
text,
ini.main.x + 8 + 1,
ini.main.y + 3 + 1,
0xAA000000
)
renderFontDrawText(
font,
text,
ini.main.x + 8,
ini.main.y + 3,
0xFF00CC66
)
end
function getPlayerStamina()
-- Rodina/CRMP address
local value = memory.getfloat(0xBAA410, 1)
local stamina = math.floor(value / 31.47000244)
if stamina < 0 then stamina = 0 end
if stamina > 100 then stamina = 100 end
return stamina
end