Merge pull request #330 from WPMGPRoSToTeMa/csgetuserweapon
Add cs_get_user_weapon_entity() and cs_get_user_weapon() natives
This commit is contained in:
commit
fa7391e814
|
@ -1903,6 +1903,41 @@ static cell AMX_NATIVE_CALL cs_get_weapon_info(AMX* amx, cell* params)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// native cs_get_user_weapon_entity(playerIndex);
|
||||||
|
static cell AMX_NATIVE_CALL cs_get_user_weapon_entity(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
GET_OFFSET("CBasePlayer", m_pActiveItem);
|
||||||
|
|
||||||
|
int playerIndex = params[1];
|
||||||
|
|
||||||
|
CHECK_PLAYER(playerIndex);
|
||||||
|
edict_t *pPlayer = MF_GetPlayerEdict(playerIndex);
|
||||||
|
|
||||||
|
int weaponEntIndex = TypeConversion.cbase_to_id(get_pdata<void *>(pPlayer, m_pActiveItem));
|
||||||
|
|
||||||
|
return (weaponEntIndex != -1) ? weaponEntIndex : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// native cs_get_user_weapon(playerIndex);
|
||||||
|
static cell AMX_NATIVE_CALL cs_get_user_weapon(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
GET_OFFSET("CBasePlayer", m_pActiveItem);
|
||||||
|
GET_OFFSET("CBasePlayerItem", m_iId);
|
||||||
|
|
||||||
|
int playerIndex = params[1];
|
||||||
|
|
||||||
|
CHECK_PLAYER(playerIndex);
|
||||||
|
edict_t *pPlayer = MF_GetPlayerEdict(playerIndex);
|
||||||
|
|
||||||
|
edict_t *pWeapon = TypeConversion.cbase_to_edict(get_pdata<void *>(pPlayer, m_pActiveItem));
|
||||||
|
|
||||||
|
if (!FNullEnt(pWeapon))
|
||||||
|
{
|
||||||
|
return get_pdata<int>(pWeapon, m_iId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO CstrikeNatives[] =
|
AMX_NATIVE_INFO CstrikeNatives[] =
|
||||||
{
|
{
|
||||||
|
@ -1972,5 +2007,7 @@ AMX_NATIVE_INFO CstrikeNatives[] =
|
||||||
{"cs_get_item_id", cs_get_item_id},
|
{"cs_get_item_id", cs_get_item_id},
|
||||||
{"cs_get_translated_item_alias",cs_get_translated_item_alias},
|
{"cs_get_translated_item_alias",cs_get_translated_item_alias},
|
||||||
{"cs_get_weapon_info", cs_get_weapon_info},
|
{"cs_get_weapon_info", cs_get_weapon_info},
|
||||||
|
{"cs_get_user_weapon_entity", cs_get_user_weapon_entity},
|
||||||
|
{"cs_get_user_weapon", cs_get_user_weapon},
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1085,6 +1085,32 @@ native bool:cs_get_translated_item_alias(const alias[], itemname[], maxlength);
|
||||||
*/
|
*/
|
||||||
native any:cs_get_weapon_info(weapon_id, CsWeaponInfo:type);
|
native any:cs_get_weapon_info(weapon_id, CsWeaponInfo:type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns active weapon entity.
|
||||||
|
*
|
||||||
|
* @param playerIndex Player index
|
||||||
|
*
|
||||||
|
* @return Weapon entity index on success or 0 if there is no active weapon
|
||||||
|
* @error If the client index is not within the range of 1 to
|
||||||
|
* maxClients, or the client is not connected, an error will be
|
||||||
|
* thrown.
|
||||||
|
*/
|
||||||
|
native cs_get_user_weapon_entity(playerIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns weapon index of the active weapon.
|
||||||
|
*
|
||||||
|
* @note More reliable than get_user_weapon.
|
||||||
|
*
|
||||||
|
* @param playerIndex Player index
|
||||||
|
*
|
||||||
|
* @return Weapon index on success or 0 if there is no active weapon
|
||||||
|
* @error If the client index is not within the range of 1 to
|
||||||
|
* maxClients, or the client is not connected, an error will be
|
||||||
|
* thrown.
|
||||||
|
*/
|
||||||
|
native cs_get_user_weapon(playerIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a weapon class id associated with a weapon id.
|
* Returns a weapon class id associated with a weapon id.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user