Functions of receiving private data for Вы должны зарегистрироваться, чтобы видеть ссылки.:
- Код: Выделить всё
const int XO_CBASEPLAYERWEAPON = 4;
const int XO_CBASEPLAYER = 5;
template <typename t>
inline t UTIL_GetPData(edict_t *pthis, int offset, int extraoffset = XO_CBASEPLAYER) {
#ifdef _WIN32
return *((t *)pthis->pvPrivateData + offset);
#else
return *((t *)pthis->pvPrivateData + offset + extraoffset);
#endif
}
inline edict_t *UTIL_GetPCBase(edict_t *pthis, int offset, int extraoffset = XO_CBASEPLAYER) {
#ifdef _WIN32
void *pvPrivateData = *((void **)(uint32_t *)pthis->pvPrivateData + offset);
#else
void *pvPrivateData = *((void **)(uint32_t *)pthis->pvPrivateData + offset + extraoffset);
#endif
if (pvPrivateData != NULL) {
char *pvData = (char *)pvPrivateData + getVirtualOffset(pev);
if (pvData != NULL) {
entvars_t *pEnt = *(entvars_t **)pvData;
return pEnt == NULL ? NULL : pEnt->pContainingEntity;
}
}
return NULL;
}
For example, get the player index in the event primary or secondary attack:
- Код: Выделить всё
const int m_pPlayer = 41;
VIRTUAL_CALLBACK(void) SecondaryAttack_Handler(void *pEnt VIRTUAL_ARG) {
VIRTUAL_CALL<void>(g_vhSecondaryAttack.getAddress(), pEnt);
edict_t *pWeap = UTIL_PrivateToEdict(pEnt);
edict_t *pPlayer = UTIL_GetPCBase(pWeap, m_pPlayer, XO_CBASEPLAYERWEAPON);
}