local ffi = require 'ffi'
ffi.cdef([[
struct stKillEntry
{
char szKiller[25];
char szVictim[25];
uint32_t clKillerColor; // D3DCOLOR
uint32_t clVictimColor; // D3DCOLOR
uint8_t byteType;
} __attribute__ ((packed));
struct stKillInfo
{
int iEnabled;
struct stKillEntry killEntry[5];
int iLongestNickLength;
int iOffsetX;
int iOffsetY;
void *pD3DFont; // ID3DXFont
void *pWeaponFont1; // ID3DXFont
void *pWeaponFont2; // ID3DXFont
void *pSprite;
void *pD3DDevice;
int iAuxFontInited;
void *pAuxFont1; // ID3DXFont
void *pAuxFont2; // ID3DXFont
} __attribute__ ((packed));
]])
ffi.cdef([[
typedef struct stRECT
{
int left, top, right, bottom;
} RECT;
typedef struct stID3DXFont
{
struct ID3DXFont_vtbl* vtbl;
} ID3DXFont;
struct ID3DXFont_vtbl
{
void* QueryInterface; // STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
void* AddRef; // STDMETHOD_(ULONG, AddRef)(THIS) PURE;
uint32_t (__stdcall * Release)(ID3DXFont* font); // STDMETHOD_(ULONG, Release)(THIS) PURE;
// ID3DXFont
void* GetDevice; // STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE;
void* GetDescA; // STDMETHOD(GetDescA)(THIS_ D3DXFONT_DESCA *pDesc) PURE;
void* GetDescW; // STDMETHOD(GetDescW)(THIS_ D3DXFONT_DESCW *pDesc) PURE;
void* GetTextMetricsA; // STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE;
void* GetTextMetricsW; // STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE;
void* GetDC; // STDMETHOD_(HDC, GetDC)(THIS) PURE;
void* GetGlyphData; // STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, LPDIRECT3DTEXTURE9 *ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE;
void* PreloadCharacters; // STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE;
void* PreloadGlyphs; // STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE;
void* PreloadTextA; // STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE;
void* PreloadTextW; // STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE;
int (__stdcall * DrawTextA)(ID3DXFont* font, void* pSprite, const char* pString, int Count, RECT* pRect, uint32_t Format, uint32_t Color); // STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
void* DrawTextW; // STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
void (__stdcall * OnLostDevice)(ID3DXFont* font); // STDMETHOD(OnLostDevice)(THIS) PURE;
void (__stdcall * OnResetDevice)(ID3DXFont* font); // STDMETHOD(OnResetDevice)(THIS) PURE;
};
uint32_t D3DXCreateFontA(void* pDevice, int Height, uint32_t Width, uint32_t Weight, uint32_t MipLevels, bool Italic, uint32_t CharSet, uint32_t OutputPrecision, uint32_t Quality, uint32_t PitchAndFamily, const char* pFaceName, ID3DXFont** ppFont);
]])
local ID = {
Background = -1,
Unarmed = 0,
Knuckles = 1,
Golf = 2,
Stick = 3,
Knife = 4,
Bat = 5,
Shovel = 6,
Cue = 7,
Katana = 8,
Chainsaw = 9,
Dildo1 = 10,
Dildo2 = 11,
Dildo3 = 12,
Dildo4 = 13,
Flowers = 14,
Cane = 15,
Grenade = 16,
Gas = 17,
Molotov = 18,
Pistol = 22,
Slicend = 23,
Eagle = 24,
Shotgun = 25,
Sawnoff = 26,
Combat = 27,
Uzi = 28,
Mp5 = 29,
Ak47 = 30,
M4 = 31,
Tec9 = 32,
Rifle = 33,
Sniper = 34,
RPG = 35,
Launcher = 36,
Flame = 37,
Minigun = 38,
Sachet = 39,
Detonator = 40,
Spray = 41,
Extinguisher = 42,
Goggles1 = 44,
Goggles2 = 45,
Parachute = 46,
}
--таблица кодов иконок
local RenderGun = {
[ID.Background] = 71,
[ID.Unarmed] = 37,
[ID.Knuckles] = 66,
[ID.Golf] = 62,
[ID.Stick] = 40,
[ID.Knife] = 67,
[ID.Bat] = 63,
[ID.Shovel] = 38,
[ID.Cue] = 34,
[ID.Katana] = 33,
[ID.Chainsaw] = 49,
[ID.Dildo1] = 69,
[ID.Dildo2] = 69,
[ID.Dildo3] = 69,
[ID.Dildo4] = 69,
[ID.Flowers] = 36,
[ID.Cane] = 35,
[ID.Grenade] = 64,
[ID.Gas] = 68,
[ID.Molotov] = 39,
[ID.Pistol] = 54,
[ID.Slicend] = 50,
[ID.Eagle] = 51,
[ID.Shotgun] = 61,
[ID.Sawnoff] = 48,
[ID.Combat] = 43,
[ID.Uzi] = 73,
[ID.Mp5] = 56,
[ID.Ak47] = 72,
[ID.M4] = 53,
[ID.Tec9] = 55,
[ID.Rifle] = 46,
[ID.Sniper] = 65,
[ID.RPG] = 52,
[ID.Launcher] = 41,
[ID.Flame] = 42,
[ID.Minigun] = 70,
[ID.Sachet] = 60,
[ID.Detonator] = 59,
[ID.Spray] = 47,
[ID.Extinguisher] = 44,
[ID.Goggles1] = 45,
[ID.Goggles2] = 45,
[ID.Parachute] = 58
}
function main()
while not isSampAvailable() do wait(0) end
if not isSampfuncsLoaded() and not isCleoLoaded() then return end
font_gtaweapon3, font_gtaweapon3_black = d3dxfont_create('gtaweapon3')
fonts_loaded = true
wait(-1)
end
function d3dxfont_draw(font, text, rect, color, format)
local prect = ffi.new('RECT[1]', {{rect[1], rect[2], rect[3], rect[4]}})
return font.vtbl.DrawTextA(font, nil, text, -1, prect, format, color)
end
function onD3DPresent()
if fonts_loaded and not sampIsScoreboardOpen() and not isPauseMenuActive() and ffi.cast("struct stKillInfo*", sampGetKillInfoPtr()).iEnabled == 1 and not isKeyDown(0x79) then
local sw, sh = getScreenResolution()
local posX, posY = 500, 500 -- X, Y
-- Фон
d3dxfont_draw(font_gtaweapon3_black, string.char(RenderGun[-1]), {posX, posY + 1, sw, sh}, 0xFF000000, 0x10)
--Иконка
local weaponId = 24 -- Дигл
d3dxfont_draw(font_gtaweapon3, string.char(RenderGun[weaponId]), {posX, posY, sw, sh}, 0xFFFFFFFF, 0x10)
end
end
function d3dxfont_create()
local d3ddev = ffi.cast("struct stKillInfo*", sampGetKillInfoPtr())
local tab = {
[1] = d3ddev.pWeaponFont2,
[2] = d3ddev.pWeaponFont2,
}
local pfont = ffi.new('ID3DXFont*[2]', tab)
return pfont[0], pfont[1]
end