I think
Add basic ReHLDS and ReGameDLL support #417 broke cs_set_user_model's update_index.
Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
public plugin_precache()
{
precache_model("models/player/vip/vip.mdl");
}
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "OnSpawnPost", .Post = true);
}
public OnSpawnPost(id)
{
if(is_user_alive(id))
{
cs_set_user_model(id, "vip", true);
}
}
Is that the correct usage? It prints:
Code:
[CSTRIKE] Model must be precached using cs_set_user_model with update_index parameter set
CstrikeNatives.cpp
Code:
if (*params / sizeof(cell) >= 3 && params[3] != 0)
{
if (!Server)
{
MF_Log("cs_set_user_model is disabled with update_index parameter set");
return 0;
}
GET_OFFSET("CBasePlayer", m_modelIndexPlayer);
char modelpath[260];
ke::SafeSprintf(modelpath, sizeof(modelpath), "models/player/%s/%s.mdl", newModel, newModel);
auto modelIndex = 0;
if (ModelsList.retrieve(modelpath, &modelIndex))
{
if (pPlayer->v.modelindex != modelIndex)
{
SET_MODEL(pPlayer, STRING(ALLOC_STRING(modelpath)));
}
set_pdata<int>(pPlayer, m_modelIndexPlayer, modelIndex);
return 1;
}
MF_Log("Model must be precached using cs_set_user_model with update_index parameter set");
return 0;
}
CstrikeMain.cpp
Code:
void SV_ActivateServer_RH(IRehldsHook_SV_ActivateServer *chain, int runPhysics)
{
chain->callNext(runPhysics);
auto numResources = RehldsData->GetResourcesNum();
if (!numResources)
{
return;
}
ModelsList.clear();
for (auto i = 0; i < numResources; ++i) // Saves all the precached models into a list.
{
auto resource = RehldsData->GetResource(i);
if (resource->type == t_model)
{
ModelsList.insert(resource->szFileName, i);
}
}
}
SV_ActivateServer_RH is only called on ReHLDS:
Code:
void OnAmxxAttach()
{
.
.
.
.
if (HasReHlds)
{
RehldsHookchains->SV_ActivateServer()->registerHook(SV_ActivateServer_RH);
}
}