File size: 2,223 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--[[
    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.require 'CRect'

shared.ffi.cdef[[
typedef struct SCScoreboard SCScoreboard;
#pragma pack(push, 1)
struct SCScoreboard {
    BOOL m_bIsEnabled;
    int m_nPlayerCount;
    float m_position[2];
    float m_fScalar;
    float m_size[2];
    float pad[5];
    struct IDirect3DDevice9* m_pDevice;
    struct CDXUTDialog* m_pDialog;
    struct CDXUTListBox* m_pListBox;
    int m_nCurrentOffset;
    BOOL m_bIsSorted;
};
#pragma pack(pop)
]]

shared.validate_size('struct SCScoreboard', 0x44)

local CScoreboard_constructor = ffi.cast('void(__thiscall*)(SCScoreboard*, IDirect3DDevice9*)', 0x6A370)
local function CScoreboard_new(...)
    local obj = ffi.new('struct SCScoreboard[1]')
    CScoreboard_constructor(obj, ...)
    return obj
end

local SCScoreboard_mt = {
    Recalc = ffi.cast('void(__thiscall*)(SCScoreboard*)', sampapi.GetAddress(0x6A270)),
    GetRect = ffi.cast('void(__thiscall*)(SCScoreboard*, SCRect*)', sampapi.GetAddress(0x6A2D0)),
    Close = ffi.cast('void(__thiscall*)(SCScoreboard*, bool)', sampapi.GetAddress(0x6A320)),
    ResetDialogControls = ffi.cast('void(__thiscall*)(SCScoreboard*, CDXUTDialog*)', sampapi.GetAddress(0x6A3F0)),
    SendNotification = ffi.cast('void(__thiscall*)(SCScoreboard*)', sampapi.GetAddress(0x6A550)),
    UpdateList = ffi.cast('void(__thiscall*)(SCScoreboard*)', sampapi.GetAddress(0x6A680)),
    Draw = ffi.cast('void(__thiscall*)(SCScoreboard*)', sampapi.GetAddress(0x6AA10)),
    Enable = ffi.cast('void(__thiscall*)(SCScoreboard*)', sampapi.GetAddress(0x6AD30)),
}
mt.set_handler('struct SCScoreboard', '__index', SCScoreboard_mt)

local function RefScoreboard() return ffi.cast('SCScoreboard**', sampapi.GetAddress(0x21A0B4))[0] end

return {
    new = CScoreboard_new,
    RefScoreboard = RefScoreboard,
}