File size: 1,449 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 SCNetStats SCNetStats;
#pragma pack(push, 1)
struct SCNetStats {
long unsigned int m_dwLastTotalBytesSent;
long unsigned int m_dwLastTotalBytesRecv;
long unsigned int m_dwLastUpdateTick;
long unsigned int m_dwBPSUpload;
long unsigned int m_dwBPSDownload;
struct IDirect3DDevice9* m_pDevice;
};
#pragma pack(pop)
]]
shared.validate_size('struct SCNetStats', 0x18)
local CNetStats_constructor = ffi.cast('void(__thiscall*)(SCNetStats*, IDirect3DDevice9*)', 0x5D220)
local function CNetStats_new(...)
local obj = ffi.new('struct SCNetStats[1]')
CNetStats_constructor(obj, ...)
return obj
end
local SCNetStats_mt = {
Draw = ffi.cast('void(__thiscall*)(SCNetStats*)', sampapi.GetAddress(0x5D250)),
}
mt.set_handler('struct SCNetStats', '__index', SCNetStats_mt)
local function RefNetStats() return ffi.cast('SCNetStats**', sampapi.GetAddress(0x21A0D0))[0] end
return {
new = CNetStats_new,
RefNetStats = RefNetStats,
} |