@@ -286,6 +286,17 @@ void Utils::SetOrigin(CBaseEntity* entity, const Vector& vecOrigin, const bool f
286286 setOrigin (entity, vecOrigin, fireTriggers);
287287}
288288
289+ /* *
290+ * @brief CBaseEntity to entity index.
291+ * @param pEntity Pointer to entity.
292+ * @return Entity index of entity.
293+ */
294+ int Utils::EntityIndex (CBaseEntity* pEntity)
295+ {
296+ static auto entIndex = reinterpret_cast <int (__cdecl*)(CBaseEntity*)>(Memory::Scan<void *>(MODULE_SERVER, " 55 8B EC 8B 45 ? 85 C0 74 ? 8B 40 ? 85 C0 74 ? 8B 0D" ));
297+ return entIndex (pEntity);
298+ }
299+
289300/* *
290301 * @brief Entity edict to entity index.
291302 * @param pEdict Pointer to edict.
@@ -318,6 +329,16 @@ edict_t* Utils::IndexToEdict(const int entityIndex)
318329 return nullptr ;
319330}
320331
332+ /* *
333+ * @brief Convert CBaseEntity to entity edict.
334+ * @param pEntity Pointer to entity.
335+ * @return Edict of CBaseEntity.
336+ */
337+ edict_t * Utils::EntityToEdict (CBaseEntity* pEntity)
338+ {
339+ return IndexToEdict (EntityIndex (pEntity));
340+ }
341+
321342/* *
322343 * @brief Returns the current game directory. Ex. "portal2"
323344 * @return The current game directory.
@@ -365,13 +386,3 @@ bool Utils::IsGameShutdown()
365386 return bIsGameShuttingDown;
366387}
367388
368- /* *
369- * @brief CBaseEntity to entity index.
370- * @param pEntity Pointer to entity.
371- * @return Entity index of entity.
372- */
373- int Utils::EntityIndex (CBaseEntity* pEntity)
374- {
375- static auto entIndex = reinterpret_cast <int (__cdecl*)(CBaseEntity*)>(Memory::Scan<void *>(MODULE_SERVER, " 55 8B EC 8B 45 ? 85 C0 74 ? 8B 40 ? 85 C0 74 ? 8B 0D" ));
376- return entIndex (pEntity);
377- }
0 commit comments