mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-01 01:25:47 +03:00
Add native GetGrenadeType
This commit is contained in:
parent
3788581874
commit
e1eac93aab
@ -152,6 +152,15 @@ native SetHookChainArg(number, AType:type, any:...);
|
|||||||
*/
|
*/
|
||||||
native bool:FClassnameIs(const entityIndex, const className[]);
|
native bool:FClassnameIs(const entityIndex, const className[]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To get WeaponIdType from grenade entity
|
||||||
|
*
|
||||||
|
* @param entity Grenade entity
|
||||||
|
*
|
||||||
|
* @return return enum's of WeaponIdType
|
||||||
|
*/
|
||||||
|
native WeaponIdType:GetGrenadeType(const entityIndex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the entity is valid.
|
* Check if the entity is valid.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,8 @@ enum client_auth_type
|
|||||||
CA_TYPE_SSE3,
|
CA_TYPE_SSE3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define is_user_steam(%0) (REU_GetAuthtype(%0) == CA_TYPE_STEAM)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks whether the player is talking at the moment.
|
* Checks whether the player is talking at the moment.
|
||||||
*
|
*
|
||||||
|
@ -25,9 +25,47 @@ cell AMX_NATIVE_CALL amx_FClassnameIs(AMX *amx, cell *params)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To get WeaponIdType from grenade entity
|
||||||
|
*
|
||||||
|
* @param entity Grenade entity
|
||||||
|
*
|
||||||
|
* @return return enum's of WeaponIdType
|
||||||
|
*
|
||||||
|
* native WeaponIdType:GetGrenadeType(const entityIndex);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL amx_GetGrenadeType(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_index };
|
||||||
|
|
||||||
|
CHECK_ISENTITY(arg_index);
|
||||||
|
|
||||||
|
edict_t *pEdict = edictByIndex(params[arg_index]);
|
||||||
|
if (!pEdict || !FClassnameIs(pEdict, "grenade")) {
|
||||||
|
return WEAPON_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGrenade *pGrenade = getPrivate<CGrenade>(pEdict);
|
||||||
|
if (!pGrenade) {
|
||||||
|
return WEAPON_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pGrenade->m_bIsC4) {
|
||||||
|
return WEAPON_C4;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned short usCreateExplosion = 0;
|
||||||
|
if (!usCreateExplosion) {
|
||||||
|
usCreateExplosion = PRECACHE_EVENT(1, "events/createexplo.sc");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (pGrenade->m_usEvent == usCreateExplosion) ? WEAPON_HEGRENADE : WEAPON_SMOKEGRENADE;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO Natives_Common[] =
|
AMX_NATIVE_INFO Natives_Common[] =
|
||||||
{
|
{
|
||||||
{ "FClassnameIs", amx_FClassnameIs },
|
{ "FClassnameIs", amx_FClassnameIs },
|
||||||
|
{ "GetGrenadeType", amx_GetGrenadeType },
|
||||||
|
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
@ -49,6 +49,15 @@ inline T* getPrivate(int index)
|
|||||||
return pdata;
|
return pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T* getPrivate(edict_t *pEdict)
|
||||||
|
{
|
||||||
|
T* pdata = nullptr;
|
||||||
|
if (likely(pEdict != nullptr))
|
||||||
|
pdata = (T *)pEdict->pvPrivateData;
|
||||||
|
return pdata;
|
||||||
|
}
|
||||||
|
|
||||||
inline entvars_t* PEV(int index)
|
inline entvars_t* PEV(int index)
|
||||||
{
|
{
|
||||||
entvars_t* pvars = nullptr;
|
entvars_t* pvars = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user