File size: 1,949 Bytes
d7c5875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--[[
    Project: SAMP-API.lua <https://github.com/imring/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.ffi.cdef[[
typedef struct SCObjectMaterialText SCObjectMaterialText;
#pragma pack(push, 1)
struct SCObjectMaterialText {
    struct IDirect3DDevice9* m_pDevice;
    struct ID3DXSprite* m_pSprite;
    struct ID3DXSprite* m_pSprite_0;
};
#pragma pack(pop)
]]

shared.validate_size('struct SCObjectMaterialText', 0xc)

local CObjectMaterialText_constructor = ffi.cast('void(__thiscall*)(SCObjectMaterialText*, IDirect3DDevice9*)', 0x70880)
local CObjectMaterialText_destructor = ffi.cast('void(__thiscall*)(SCObjectMaterialText*)', 0x708A0)
local function CObjectMaterialText_new(...)
    local obj = ffi.gc(ffi.new('struct SCObjectMaterialText[1]'), CObjectMaterialText_destructor)
    CObjectMaterialText_constructor(obj, ...)
    return obj
end

local SCObjectMaterialText_mt = {
    OnResetDevice = ffi.cast('void(__thiscall*)(SCObjectMaterialText*)', sampapi.GetAddress(0x70860)),
    OnLostDevice = ffi.cast('void(__thiscall*)(SCObjectMaterialText*)', sampapi.GetAddress(0x70830)),
    Create = ffi.cast('IDirect3DTexture9 * (__thiscall*)(SCObjectMaterialText*, const char*, const char*, char, int, int, D3DCOLOR, D3DCOLOR, bool, char)', sampapi.GetAddress(0x708B0)),
}
mt.set_handler('struct SCObjectMaterialText', '__index', SCObjectMaterialText_mt)

local function RefObjectMaterialTextManager() return ffi.cast('SCObjectMaterialText**', sampapi.GetAddress(0x26EBA4))[0] end

return {
    new = CObjectMaterialText_new,
    RefObjectMaterialTextManager = RefObjectMaterialTextManager,
}