File size: 2,250 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 63 64 65 66 67 68 69 70 71 72 73 | --[[
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 'v037r5.CEntity'
shared.require 'v037r5.CActor'
shared.require 'CMatrix'
shared.require 'CVector'
shared.ffi.cdef[[
typedef struct SActorInfo SActorInfo;
#pragma pack(push, 1)
struct SActorInfo {
ID m_nId;
int m_nModel;
SCVector m_position;
float m_fRotation;
float m_fHealth;
bool m_bInvulnerable;
};
#pragma pack(pop)
enum {
MAX_ACTORS = 1000,
};
typedef struct SCActorPool SCActorPool;
#pragma pack(push, 1)
struct SCActorPool {
int m_nLargestId;
SCActor* m_pObject[1000];
BOOL m_bNotEmpty[1000];
struct CPed* m_pGameObject[1000];
int pad_2ee4[1000];
int pad_3e84[1000];
};
#pragma pack(pop)
]]
shared.validate_size('struct SActorInfo', 0x1b)
shared.validate_size('struct SCActorPool', 0x4e24)
local CActorPool_constructor = ffi.cast('void(__thiscall*)(SCActorPool*)', 0x16C0)
local CActorPool_destructor = ffi.cast('void(__thiscall*)(SCActorPool*)', 0x18E0)
local function CActorPool_new(...)
local obj = ffi.gc(ffi.new('struct SCActorPool[1]'), CActorPool_destructor)
CActorPool_constructor(obj, ...)
return obj
end
local SCActorPool_mt = {
Get = ffi.cast('SCActor * (__thiscall*)(SCActorPool*, ID)', sampapi.GetAddress(0x1610)),
DoesExist = ffi.cast('BOOL(__thiscall*)(SCActorPool*, ID)', sampapi.GetAddress(0x1640)),
UpdateLargestId = ffi.cast('void(__thiscall*)(SCActorPool*)', sampapi.GetAddress(0x1660)),
Delete = ffi.cast('BOOL(__thiscall*)(SCActorPool*, ID)', sampapi.GetAddress(0x16F0)),
Find = ffi.cast('ID(__thiscall*)(SCActorPool*, struct CPed*)', sampapi.GetAddress(0x18B0)),
Create = ffi.cast('BOOL(__thiscall*)(SCActorPool*, SActorInfo*)', sampapi.GetAddress(0x1900)),
}
mt.set_handler('struct SCActorPool', '__index', SCActorPool_mt)
return {
new = CActorPool_new,
} |