local ffi = require('ffi')
ffi.cdef([[
struct std_string {
union {
char buf[16];
char* ptr;
};
unsigned size;
unsigned capacity;
};
struct stCommandInfo {
struct std_string name;
int type;
void* owner;
};
struct std_vector_stCommandInfo{
struct stCommandInfo* first;
struct stCommandInfo* last;
struct stCommandInfo* end;
};
]])
function get_string(from_string)
if from_string.size <= 0x0F then
return ffi.string(from_string.buf);
else
return ffi.string(from_string.ptr);
end
end
local SF_getChatCommands = getModuleProcAddress('SAMPFUNCS.asi', '?getChatCommands@SAMPFUNCS@@QAE?AV?$vector@UstCommandInfo@@V?$allocator@UstCommandInfo@@@std@@@std@@XZ')
local getChatCommands = ffi.cast('struct std_vector_stCommandInfo(__thiscall*)()', SF_getChatCommands)
local commands = getChatCommands()
do
local it = commands.first
while it ~= commands.last do
print(get_string(it[0].name))
it = it + 1
end
end