Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Вопрос [NL] Почему не работает моделчейнджер?

Privatny p100 DT Airlag Break LC Teleport Exploit
Участник
Участник
Статус
Оффлайн
Регистрация
27 Янв 2021
Сообщения
1,242
Реакции
219
Вот код


code_language.lua:
Expand Collapse Copy
ffi.cdef [[

typedef struct {
  float x;
  float y;
  float z;
}vec3_t;

typedef struct
{
  void*   fnHandle;               //0x0000
  char    szName[260];            //0x0004
  int     nLoadFlags;             //0x0108
  int     nServerCount;           //0x010C
  int     type;                   //0x0110
  int     flags;                  //0x0114
  vec3_t  vecMins;                //0x0118
  vec3_t  vecMaxs;                //0x0124
  float   radius;                 //0x0130
  char    pad[0x1C];              //0x0134
}model_t;//Size=0x0150

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* find_table_t)(void*, const char*);
typedef void(__thiscall* set_model_index_t)(void*, int);
typedef int(__thiscall* precache_model_t)(void*, const char*, bool);
]]

local class_ptr = ffi.typeof("void***")
local rawivmodelinfo = utils.create_interface("engine.dll", "VModelInfoClient004") or error("VModelInfoClient004 wasnt found", 2)
local ivmodelinfo = ffi.cast(class_ptr, rawivmodelinfo) or error("rawivmodelinfo is nil", 2)
local get_model_index = ffi.cast("get_model_index_t", ivmodelinfo[0][2]) or error("get_model_info is nil", 2)

events.net_update_end:set(function()
    local local_player = entity.get_local_player()
    if local_player == nil then return end
 
    local model_idx = get_model_index(ivmodelinfo, "models/player/custom_player/toppiofficial/genshin/rework/hutao.mdl")
    if model_idx ~= -1 then
        local_player["m_nModelIndex"] = model_idx
    end
end)
 
Вот код


code_language.lua:
Expand Collapse Copy
ffi.cdef [[

typedef struct {
  float x;
  float y;
  float z;
}vec3_t;

typedef struct
{
  void*   fnHandle;               //0x0000
  char    szName[260];            //0x0004
  int     nLoadFlags;             //0x0108
  int     nServerCount;           //0x010C
  int     type;                   //0x0110
  int     flags;                  //0x0114
  vec3_t  vecMins;                //0x0118
  vec3_t  vecMaxs;                //0x0124
  float   radius;                 //0x0130
  char    pad[0x1C];              //0x0134
}model_t;//Size=0x0150

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* find_table_t)(void*, const char*);
typedef void(__thiscall* set_model_index_t)(void*, int);
typedef int(__thiscall* precache_model_t)(void*, const char*, bool);
]]

local class_ptr = ffi.typeof("void***")
local rawivmodelinfo = utils.create_interface("engine.dll", "VModelInfoClient004") or error("VModelInfoClient004 wasnt found", 2)
local ivmodelinfo = ffi.cast(class_ptr, rawivmodelinfo) or error("rawivmodelinfo is nil", 2)
local get_model_index = ffi.cast("get_model_index_t", ivmodelinfo[0][2]) or error("get_model_info is nil", 2)

events.net_update_end:set(function()
    local local_player = entity.get_local_player()
    if local_player == nil then return end

    local model_idx = get_model_index(ivmodelinfo, "models/player/custom_player/toppiofficial/genshin/rework/hutao.mdl")
    if model_idx ~= -1 then
        local_player["m_nModelIndex"] = model_idx
    end
end)
потому что индек модели -1, т.е. она не прекешнута
 
А как их прекешать?
Расскажи пожалуйста, желательно с приложенным кодом
code_language.lua:
Expand Collapse Copy
ffi.cdef [[

    typedef struct {
      float x;
      float y;
      float z;
    }vec3_t;

    typedef struct
    {
      void*   fnHandle;               //0x0000
      char    szName[260];            //0x0004
      int     nLoadFlags;             //0x0108
      int     nServerCount;           //0x010C
      int     type;                   //0x0110
      int     flags;                  //0x0114
      vec3_t  vecMins;                //0x0118
      vec3_t  vecMaxs;                //0x0124
      float   radius;                 //0x0130
      char    pad[0x1C];              //0x0134
    }model_t;//Size=0x0150

    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* find_table_t)(void*, const char*);
    typedef void(__thiscall* set_model_index_t)(void*, int);
    typedef int(__thiscall* precache_model_t)(void*, const char*, bool);
]]

local class_ptr = ffi.typeof("void***")
local rawivmodelinfo = utils.create_interface("engine.dll", "VModelInfoClient004") or error("VModelInfoClient004 wasnt found", 2)
local ivmodelinfo = ffi.cast(class_ptr, rawivmodelinfo) or error("rawivmodelinfo is nil", 2)
local get_model_index = ffi.cast("get_model_index_t", ivmodelinfo[0][2]) or error("get_model_info is nil", 2)

local find_or_load_model = ffi.cast("find_or_load_model_t", ivmodelinfo[0][39])
local rawnetworkstringtablecontainer = utils.create_interface("engine.dll", "VEngineClientStringTable001")
local networkstringtablecontainer = ffi.cast(class_ptr, rawnetworkstringtablecontainer)
local find_table = ffi.cast("find_table_t", networkstringtablecontainer[0][3])

local function precache_model(modelname)
    local rawprecache_table = find_table(networkstringtablecontainer, "modelprecache") or error("couldnt find modelprecache", 2)
    if rawprecache_table then
        local precache_table = ffi.cast(class_ptr, rawprecache_table) or error("couldnt cast precache_table", 2)
        if precache_table then
            local add_string = ffi.cast("add_string_t", precache_table[0][8]) or error("add_string is nil", 2)

            find_or_load_model(ivmodelinfo, modelname)
            local idx = add_string(precache_table, false, modelname, -1, nil)
            if idx == -1 then
                return false
            end
        end
    end
    return true
end

local model = "models/player/custom_player/toppiofficial/genshin/rework/hutao.mdl"

events.net_update_end:set(function()
    local local_player = entity.get_local_player()
    if local_player == nil then return end

    local model_idx = get_model_index(ivmodelinfo, model)

    if model_idx == -1 then
        precache_model(model)
    end

    if model_idx ~= -1 then
        local_player["m_nModelIndex"] = model_idx
    end
end)
 
Вот код


code_language.lua:
Expand Collapse Copy
ffi.cdef [[

typedef struct {
  float x;
  float y;
  float z;
}vec3_t;

typedef struct
{
  void*   fnHandle;               //0x0000
  char    szName[260];            //0x0004
  int     nLoadFlags;             //0x0108
  int     nServerCount;           //0x010C
  int     type;                   //0x0110
  int     flags;                  //0x0114
  vec3_t  vecMins;                //0x0118
  vec3_t  vecMaxs;                //0x0124
  float   radius;                 //0x0130
  char    pad[0x1C];              //0x0134
}model_t;//Size=0x0150

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* find_table_t)(void*, const char*);
typedef void(__thiscall* set_model_index_t)(void*, int);
typedef int(__thiscall* precache_model_t)(void*, const char*, bool);
]]

local class_ptr = ffi.typeof("void***")
local rawivmodelinfo = utils.create_interface("engine.dll", "VModelInfoClient004") or error("VModelInfoClient004 wasnt found", 2)
local ivmodelinfo = ffi.cast(class_ptr, rawivmodelinfo) or error("rawivmodelinfo is nil", 2)
local get_model_index = ffi.cast("get_model_index_t", ivmodelinfo[0][2]) or error("get_model_info is nil", 2)

events.net_update_end:set(function()
    local local_player = entity.get_local_player()
    if local_player == nil then return end

    local model_idx = get_model_index(ivmodelinfo, "models/player/custom_player/toppiofficial/genshin/rework/hutao.mdl")
    if model_idx ~= -1 then
        local_player["m_nModelIndex"] = model_idx
    end
end)
В нле есть callback draw_model
 
code_language.lua:
Expand Collapse Copy
ffi.cdef [[

    typedef struct {
      float x;
      float y;
      float z;
    }vec3_t;

    typedef struct
    {
      void*   fnHandle;               //0x0000
      char    szName[260];            //0x0004
      int     nLoadFlags;             //0x0108
      int     nServerCount;           //0x010C
      int     type;                   //0x0110
      int     flags;                  //0x0114
      vec3_t  vecMins;                //0x0118
      vec3_t  vecMaxs;                //0x0124
      float   radius;                 //0x0130
      char    pad[0x1C];              //0x0134
    }model_t;//Size=0x0150

    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* find_table_t)(void*, const char*);
    typedef void(__thiscall* set_model_index_t)(void*, int);
    typedef int(__thiscall* precache_model_t)(void*, const char*, bool);
]]

local class_ptr = ffi.typeof("void***")
local rawivmodelinfo = utils.create_interface("engine.dll", "VModelInfoClient004") or error("VModelInfoClient004 wasnt found", 2)
local ivmodelinfo = ffi.cast(class_ptr, rawivmodelinfo) or error("rawivmodelinfo is nil", 2)
local get_model_index = ffi.cast("get_model_index_t", ivmodelinfo[0][2]) or error("get_model_info is nil", 2)

local find_or_load_model = ffi.cast("find_or_load_model_t", ivmodelinfo[0][39])
local rawnetworkstringtablecontainer = utils.create_interface("engine.dll", "VEngineClientStringTable001")
local networkstringtablecontainer = ffi.cast(class_ptr, rawnetworkstringtablecontainer)
local find_table = ffi.cast("find_table_t", networkstringtablecontainer[0][3])

local function precache_model(modelname)
    local rawprecache_table = find_table(networkstringtablecontainer, "modelprecache") or error("couldnt find modelprecache", 2)
    if rawprecache_table then
        local precache_table = ffi.cast(class_ptr, rawprecache_table) or error("couldnt cast precache_table", 2)
        if precache_table then
            local add_string = ffi.cast("add_string_t", precache_table[0][8]) or error("add_string is nil", 2)

            find_or_load_model(ivmodelinfo, modelname)
            local idx = add_string(precache_table, false, modelname, -1, nil)
            if idx == -1 then
                return false
            end
        end
    end
    return true
end

local model = "models/player/custom_player/toppiofficial/genshin/rework/hutao.mdl"

events.net_update_end:set(function()
    local local_player = entity.get_local_player()
    if local_player == nil then return end

    local model_idx = get_model_index(ivmodelinfo, model)

    if model_idx == -1 then
        precache_model(model)
    end

    if model_idx ~= -1 then
        local_player["m_nModelIndex"] = model_idx
    end
end)
Спасибо, я конечно сам успел разобраться, но всё равно спасибо
 
Назад
Сверху Снизу