--[[ Project: SAMP-API.lua Developers: imring, LUCHARE, FYP Special thanks: SAMemory (https://www.blast.hk/threads/20472/) for implementing the basic functions. SAMP-API (https://github.com/BlastHackNet/SAMP-API) for the structures and addresses. ]] local sampapi = require 'sampapi' local shared = sampapi.shared local mt = require 'sampapi.metatype' local ffi = require 'ffi' shared.require 'CRect' shared.require 'v037r5.CFont' shared.ffi.cdef[[ typedef struct SCFonts SCFonts; #pragma pack(push, 1) struct SCFonts { SCFont* m_pFont; SCFont* m_pLittleFont; SCFont* m_pShadow; SCFont* m_pLittleShadow; SCFont* m_pLicensePlateFont; struct ID3DXSprite* m_pDefaultSprite; struct IDirect3DDevice9* m_pDevice; char* m_szTempBuffer; int m_nCharHeight; int m_nLittleCharHeight; }; #pragma pack(pop) ]] shared.validate_size('struct SCFonts', 0x28) local function RefFontRenderer() return ffi.cast('SCFonts**', sampapi.GetAddress(0x26EB9C))[0] end local CFonts_constructor = ffi.cast('void(__thiscall*)(SCFonts*, IDirect3DDevice9*)', 0x6BAF0) local CFonts_destructor = ffi.cast('void(__thiscall*)(SCFonts*)', 0x6B100) local function CFonts_new(...) local obj = ffi.gc(ffi.new('struct SCFonts[1]'), CFonts_destructor) CFonts_constructor(obj, ...) return obj end local SCFonts_mt = { OnLostDevice = ffi.cast('void(__thiscall*)(SCFonts*)', sampapi.GetAddress(0x70EA0)), OnResetDevice = ffi.cast('void(__thiscall*)(SCFonts*)', sampapi.GetAddress(0x6B1C0)), GetTextScreenSize = ffi.cast('void(__thiscall*)(SCFonts*, void*, const char*, int)', sampapi.GetAddress(0x6B200)), GetLittleTextScreenSize = ffi.cast('void(__thiscall*)(SCFonts*, void*, const char*, int)', sampapi.GetAddress(0x6B2B0)), DrawText = ffi.cast('void(__thiscall*)(SCFonts*, ID3DXSprite*, const char*, SCRect, D3DCOLOR, BOOL)', sampapi.GetAddress(0x6B360)), DrawLittleText = ffi.cast('void(__thiscall*)(SCFonts*, ID3DXSprite*, const char*, SCRect, int, D3DCOLOR, BOOL)', sampapi.GetAddress(0x6B4E0)), DrawLicensePlateText = ffi.cast('void(__thiscall*)(SCFonts*, const char*, SCRect, D3DCOLOR)', sampapi.GetAddress(0x6B650)), Reset = ffi.cast('void(__thiscall*)(SCFonts*)', sampapi.GetAddress(0x6B8E0)), } mt.set_handler('struct SCFonts', '__index', SCFonts_mt) return { RefFontRenderer = RefFontRenderer, new = CFonts_new, }