local ffi = require("ffi")
ffi.cdef[[
typedef struct{
void* handle;
char name[260];
int load_flags;
int server_count;
int type;
int flags;
float mins[3];
float maxs[3];
float radius;
char pad[0x1C];
} model_t;
typedef struct {void** this;}aclass;
typedef void*(__thiscall* get_client_entity_t)(void*, int);
typedef void(__thiscall* find_or_load_model_fn_t)(void*, const char*);
typedef const int(__thiscall* get_model_index_fn_t)(void*, const char*);
typedef const int(__thiscall* add_string_fn_t)(void*, bool, const char*, int, const void*);
typedef void*(__thiscall* find_table_t)(void*, const char*);
typedef void(__thiscall* full_update_t)();
typedef int(__thiscall* get_player_idx_t)();
typedef void*(__thiscall* get_client_networkable_t)(void*, int);
typedef void(__thiscall* pre_data_update_t)(void*, int);
typedef int(__thiscall* get_model_index_t)(void*, const char*);
typedef const model_t(__thiscall* find_or_load_model_t)(void*, const char*);
typedef int(__thiscall* add_string_t)(void*, bool, const char*, int, const void*);
typedef void(__thiscall* set_model_index_t)(void*, int);
typedef int(__thiscall* precache_model_t)(void*, const char*, bool);
]]
local a = ffi.cast(ffi.typeof("void***"), utils.create_interface("client.dll", "VClientEntityList003")) or error("rawientitylist is nil", 2)
local b = ffi.cast("get_client_entity_t", a[0][3]) or error("get_client_entity is nil", 2)
local c = ffi.cast(ffi.typeof("void***"), utils.create_interface("engine.dll", "VModelInfoClient004")) or error("model info is nil", 2)
local d = ffi.cast("get_model_index_fn_t", c[0][2]) or error("Getmodelindex is nil", 2)
local e = ffi.cast("find_or_load_model_fn_t", c[0][43]) or error("findmodel is nil", 2)
local f = ffi.cast(ffi.typeof("void***"), utils.create_interface("engine.dll","VEngineClientStringTable001")) or error("clientstring is nil", 2)
local g = ffi.cast("find_table_t", f[0][3]) or error("find table is nil", 2)
function p(pa)
local a_p = ffi.cast(ffi.typeof("void***"), g(f, "modelprecache"))
if a_p~= nil then
e(c, pa)
local ac = ffi.cast("add_string_fn_t", a_p[0][8]) or error("ac nil", 2)
local acs = ac(a_p, false, pa, -1, nil)
if acs == -1 then print("failed")
return false
end
end
return true
end
function smi(en, i)
local rw = b(a, en)
if rw then
local gc = ffi.cast(ffi.typeof("void***"), rw)
local se = ffi.cast("set_model_index_t", gc[0][75])
if se == nil then
error("smi is nil")
end
se(gc, i)
end
end
function cm(ent, md)
if md:len() > 5 then
if p(md) == false then
error("invalid model", 2)
end
local i = d(c, md)
if i == -1 then
return
end
smi(ent, i)
end
end
ui.create(" ")
local main=ui.create("Model Changer")
local en=main:switch("Enabled", false)
local custom= main:input("Custom", "")
events.net_update_end:set(function()
local lp = entity.get_local_player()
if lp==nil then return end
if globals.is_in_game and lp:is_alive() then
if en:get() then
cm(lp:get_index(), custom:get())
end
end
end)