diff --git a/modules/cstrike/cstrike/CstrikeMain.cpp b/modules/cstrike/cstrike/CstrikeMain.cpp index be63441a..e6d28218 100644 --- a/modules/cstrike/cstrike/CstrikeMain.cpp +++ b/modules/cstrike/cstrike/CstrikeMain.cpp @@ -37,30 +37,6 @@ int AmxxCheckGame(const char *game) return AMXX_GAME_BAD; } -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); - } - } -} - void OnAmxxAttach() { MF_AddNatives(CstrikeNatives); @@ -85,11 +61,6 @@ void OnAmxxAttach() } InitializeHacks(); - - if (HasReHlds) - { - RehldsHookchains->SV_ActivateServer()->registerHook(SV_ActivateServer_RH); - } } void OnPluginsLoaded() @@ -131,6 +102,8 @@ void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax) ToggleHook_BuyCommands(HasOnBuyForward); ToggleHook_GiveDefaultItems(false); + ModelsList.clear(); + RETURN_META(MRES_IGNORED); } diff --git a/modules/cstrike/cstrike/CstrikeNatives.cpp b/modules/cstrike/cstrike/CstrikeNatives.cpp index 004b0c5a..50108790 100644 --- a/modules/cstrike/cstrike/CstrikeNatives.cpp +++ b/modules/cstrike/cstrike/CstrikeNatives.cpp @@ -856,12 +856,30 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params) if (*params / sizeof(cell) >= 3 && params[3] != 0) { - if (!Server) + if (!HasReHlds && !Server) { MF_Log("cs_set_user_model is disabled with update_index parameter set"); return 0; } + if (!ModelsList.elements()) + { + auto numResources = HasReHlds ? RehldsData->GetResourcesNum() : Server->num_resources; + + if (numResources) + { + for (auto i = 0; i < numResources; ++i) // Saves all the precached models into a list. + { + auto resource = HasReHlds ? RehldsData->GetResource(i) : &Server->resourcelist[i]; + + if (resource->type == t_model) + { + ModelsList.insert(resource->szFileName, resource->nIndex); + } + } + } + } + GET_OFFSET("CBasePlayer", m_modelIndexPlayer); char modelpath[260];