Эксперт
- Статус
- Оффлайн
- Регистрация
- 1 Июл 2017
- Сообщения
- 1,744
- Реакции
- 1,503
Код:
ffi.cdef[[
typedef int( __thiscall* get_ent_by_idx_t )( void*, int );
typedef void( __thiscall* set_model_index_t )( void*, int );
typedef const int( __thiscall* get_model_index_t )( void*, const char* );
]]
local g_entity_list = ffi.cast("void*", client.CreateInterface("client_panorama.dll", "VClientEntityList003"))
local g_model_info = ffi.cast("void*", client.CreateInterface("engine.dll", "VModelInfoClient004"))
local FRAME_NET_UPDATE_POSTDATAUPDATE_START = 2
local MODEL_PATH = "models/player/custom_player/legacy/ctm_fbi_variantb.mdl"
local function get_local_player_addr()
local vtable = ffi.cast("int*", g_entity_list)[0]
local addr = ffi.cast("int*", vtable + 12)[0] -- 3
local fn = ffi.cast("get_ent_by_idx_t", addr)
local lp_index = engine.GetLocalPlayer()
return fn(g_entity_list, lp_index)
end
local function set_model_index(entity, model_index)
local vtable = ffi.cast("int*", entity)[0]
local addr = ffi.cast("int*", vtable + 300)[0] -- 75
local fn = ffi.cast("set_model_index_t", addr)
fn(ffi.cast("void*", entity), model_index)
end
local function get_model_index(model_name)
local vtable = ffi.cast("int*", g_model_info)[0]
local addr = ffi.cast("int*", vtable + 8)[0] -- 2
local fn = ffi.cast("get_model_index_t", addr)
return fn(g_model_info, model_name)
end
local function on_frame_stage(stage)
if stage ~= FRAME_NET_UPDATE_POSTDATAUPDATE_START then return end
local p_local = get_local_player_addr()
if p_local == 0 then return end
local model_idx = get_model_index(MODEL_PATH)
set_model_index(p_local, model_idx)
end
client.RegisterCallback("FrameStageNotify", on_frame_stage)