Add cs_get_weaponbox_item native (#548)
* Add cs_get_wpnbox_weapon native * Rename native + fix strcmp check
This commit is contained in:
		
				
					committed by
					
						 Vincent Herbet
						Vincent Herbet
					
				
			
			
				
	
			
			
			
						parent
						
							99ebd62653
						
					
				
				
					commit
					9a95fd9886
				
			| @@ -1998,6 +1998,34 @@ static cell AMX_NATIVE_CALL cs_get_user_weapon(AMX *amx, cell *params) | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // native cs_get_weaponbox_item(weaponboxIndex); | ||||||
|  | static cell AMX_NATIVE_CALL cs_get_weaponbox_item(AMX *amx, cell *params) | ||||||
|  | { | ||||||
|  | 	GET_OFFSET("CWeaponBox", m_rgpPlayerItems); | ||||||
|  |  | ||||||
|  | 	int weaponboxIndex = params[1]; | ||||||
|  | 	CHECK_NONPLAYER(weaponboxIndex); | ||||||
|  | 	edict_t *pWeaponBox = TypeConversion.id_to_edict(weaponboxIndex); | ||||||
|  |  | ||||||
|  | 	if (strcmp(STRING(pWeaponBox->v.classname), "weaponbox") != 0) | ||||||
|  | 	{ | ||||||
|  | 		MF_LogError(amx, AMX_ERR_NATIVE, "Not a weaponbox entity! (%d)", weaponboxIndex); | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	edict_t *pWeapon; | ||||||
|  | 	for (int i = 1; i < MAX_ITEM_TYPES; i++) | ||||||
|  | 	{ | ||||||
|  | 		pWeapon = TypeConversion.cbase_to_edict(get_pdata<void *>(pWeaponBox, m_rgpPlayerItems, i)); | ||||||
|  | 		if (!FNullEnt(pWeapon)) | ||||||
|  | 		{ | ||||||
|  | 			return TypeConversion.edict_to_id(pWeapon); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
| AMX_NATIVE_INFO CstrikeNatives[] = | AMX_NATIVE_INFO CstrikeNatives[] = | ||||||
| { | { | ||||||
| 	{"cs_set_user_money",			cs_set_user_money}, | 	{"cs_set_user_money",			cs_set_user_money}, | ||||||
| @@ -2070,5 +2098,6 @@ AMX_NATIVE_INFO CstrikeNatives[] = | |||||||
| 	{"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_entity",   cs_get_user_weapon_entity}, | ||||||
| 	{"cs_get_user_weapon",          cs_get_user_weapon}, | 	{"cs_get_user_weapon",          cs_get_user_weapon}, | ||||||
|  | 	{"cs_get_weaponbox_item",		cs_get_weaponbox_item}, | ||||||
| 	{nullptr,						nullptr} | 	{nullptr,						nullptr} | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -739,6 +739,17 @@ native cs_get_armoury_type(index, &count = 1); | |||||||
|  */ |  */ | ||||||
| native cs_set_armoury_type(index, type, count = -1); | native cs_set_armoury_type(index, type, count = -1); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Returns the weapon entity index that was packed into a weaponbox. | ||||||
|  |  * | ||||||
|  |  * @param weaponboxIndex  Weaponbox entity index | ||||||
|  |  * | ||||||
|  |  * @return                Weapon entity index on success or 0 if no weapon can be found | ||||||
|  |  * @error                 If a non-weaponbox entity is provided or the entity is invalid, an error will be | ||||||
|  |  *                        thrown. | ||||||
|  |  */ | ||||||
|  | native cs_get_weaponbox_item(weaponboxIndex); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Returns the map zones the client is inside of as a bitflag value. |  * Returns the map zones the client is inside of as a bitflag value. | ||||||
|  * |  * | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user