diff --git a/reapi/src/dllapi.cpp b/reapi/src/dllapi.cpp index fed0410..dc3d58c 100644 --- a/reapi/src/dllapi.cpp +++ b/reapi/src/dllapi.cpp @@ -9,7 +9,7 @@ DLL_FUNCTIONS gFunctionTable = NULL, // pfnUse NULL, // pfnTouch NULL, // pfnBlocked - NULL, // pfnKeyValue + &KeyValue, // pfnKeyValue NULL, // pfnSave NULL, // pfnRestore NULL, // pfnSetAbsBox diff --git a/reapi/src/main.cpp b/reapi/src/main.cpp index 4bedd99..53402cc 100644 --- a/reapi/src/main.cpp +++ b/reapi/src/main.cpp @@ -59,10 +59,20 @@ void ServerDeactivate_Post() api_cfg.ServerDeactivate(); g_hookManager.clearHandlers(); g_pFunctionTable->pfnSpawn = DispatchSpawn; + g_pFunctionTable->pfnKeyValue = KeyValue; SET_META_RESULT(MRES_IGNORED); } +void KeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) +{ + // get the first edict worldspawn + if (FClassnameIs(pentKeyvalue, "worldspawn")) { + g_pEdicts = pentKeyvalue; + g_pFunctionTable->pfnKeyValue = nullptr; + } +} + CGameRules *InstallGameRules(IReGameHook_InstallGameRules *chain) { return g_pGameRules = chain->callNext(); diff --git a/reapi/src/main.h b/reapi/src/main.h index 7ad07ec..6914e64 100644 --- a/reapi/src/main.h +++ b/reapi/src/main.h @@ -17,5 +17,6 @@ void ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax); void ServerDeactivate_Post(); int DispatchSpawn(edict_t* pEntity); void ResetGlobalState(); +void KeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd); CGameRules *InstallGameRules(IReGameHook_InstallGameRules *chain);