require 'lib.moonloader'
require 'lib.sampfuncs'
local sampev = require 'lib.samp.events'
local memory = require 'memory'
local textdraw_id = 605
local vremya = 0
local colorPhase = 0 -- для анимации
-- Позиция для текста
local textPosX = 547.0
local textPosY = 24.0
function main()
repeat wait(100) until isSampAvailable()
lua_thread.create(updateStats)
while true do
animateColor()
wait(0)
end
end
function animateColor()
-- Меняем фазу цвета для анимации
colorPhase = (colorPhase + 0.02) % (2 * math.pi)
end
function getAnimatedColor()
-- Переливание между красным и зелёным
local r = math.floor(127 + 127 * math.sin(colorPhase))
local g = math.floor(127 + 127 * math.sin(colorPhase + 2))
local b = math.floor(127 + 127 * math.sin(colorPhase + 4))
return bit.bor(0xFF000000, bit.lshift(r, 16) + bit.lshift(g, 8) + b)
end
function applyStyle(id)
local animatedColor = getAnimatedColor()
sampTextdrawSetLetterSizeAndColor(id, 0.20, 0.70, animatedColor) -- применяем цвет
sampTextdrawSetStyle(id, 1)
sampTextdrawSetShadow(id, 2)
sampTextdrawSetOutlineColor(id, 1, 0x80000000)
end
function updateStats()
while true do
wait(200) -- обновляем чаще для анимации
-- Удаляем старые
for i = textdraw_id, textdraw_id + 10 do
if sampTextdrawIsExists(i) then
sampTextdrawDelete(i)
end
end
local timer = os.time() + vremya
local fps = getCurrentFPS()
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local ping = sampGetPlayerPing(myId)
-- Верхний блок
sampTextdrawCreate(textdraw_id + 0, "~w~ARIZONA", textPosX, textPosY)
applyStyle(textdraw_id + 0)
sampTextdrawCreate(textdraw_id + 1, "~w~DEATHMATCH", textPosX + 36, textPosY)
applyStyle(textdraw_id + 1)
sampTextdrawCreate(textdraw_id + 2, "~w~" .. os.date("%Y-%m-%d", timer), textPosX, textPosY + 6)
applyStyle(textdraw_id + 2)
sampTextdrawCreate(textdraw_id + 3, "~w~" .. os.date("%H:%M", timer), textPosX + 41, textPosY + 6)
applyStyle(textdraw_id + 3)
end
end
function getCurrentFPS()
return math.ceil(memory.getfloat(0xB7CB50, true))
end
function sampev.onShowTextDraw(id, data)
-- Отключаем дефолтные надписи
if data.position.x == 550 and data.position.y == 1 then return false end
if data.position.x == 565 and data.position.y == 6 then return false end
if data.position.x == 563 and data.position.y == 14 then return false end
end