2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Add native GetGrenadeType

This commit is contained in:
s1lent 2017-06-13 19:10:04 +07:00
parent 3788581874
commit e1eac93aab
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
5 changed files with 60 additions and 2 deletions

View File

@ -152,6 +152,15 @@ native SetHookChainArg(number, AType:type, any:...);
*/
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.
*

View File

@ -19,6 +19,8 @@ enum client_auth_type
CA_TYPE_SSE3,
};
#define is_user_steam(%0) (REU_GetAuthtype(%0) == CA_TYPE_STEAM)
/*
* Checks whether the player is talking at the moment.
*

View File

@ -25,9 +25,47 @@ cell AMX_NATIVE_CALL amx_FClassnameIs(AMX *amx, cell *params)
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[] =
{
{ "FClassnameIs", amx_FClassnameIs },
{ "GetGrenadeType", amx_GetGrenadeType },
{ nullptr, nullptr }
};

View File

@ -49,6 +49,15 @@ inline T* getPrivate(int index)
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)
{
entvars_t* pvars = nullptr;