local ffi = require 'ffi'
local font = renderCreateFont('arial', 12, 5)
function main()
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand('tt', function() bool = not bool sampAddChatMessage(bool and 'Active' or 'Deactive', -1) end)
while true do wait(0)
if bool then
local time = localTime()
renderFontDrawText(font, time.wHour .. ':'.. time.wMinute .. ':' .. time.wSecond .. ':' .. time.wMilliseconds, 10,500, -1)
end
end
end
function localTime()
local time = ffi.new("SYSTEMTIME")
ffi.C.GetLocalTime(time)
return time
end
ffi.cdef[[
typedef unsigned short WORD;
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;
void GetSystemTime(
PSYSTEMTIME lpSystemTime
);
void GetLocalTime(
PSYSTEMTIME lpSystemTime
);
]]