Merge pull request #114 from VoiDeD/tf2-removewearable
Implement TF2_RemoveWearable native (r=psychonic).
This commit is contained in:
		
						commit
						8d5fe316e0
					
				| @ -599,6 +599,55 @@ cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params) | ||||
| 	return (retValue) ? 1 : 0; | ||||
| } | ||||
| 
 | ||||
| cell_t TF2_RemoveWearable(IPluginContext *pContext, const cell_t *params) | ||||
| { | ||||
| 	static ICallWrapper *pWrapper = NULL; | ||||
| 
 | ||||
| 	//CBasePlayer::RemoveWearable(CEconWearable *)
 | ||||
| 
 | ||||
| 	if (!pWrapper) | ||||
| 	{ | ||||
| 		int offset; | ||||
| 
 | ||||
| 		if (!g_pGameConf->GetOffset("RemoveWearable", &offset)) | ||||
| 		{ | ||||
| 			return pContext->ThrowNativeError("Failed to locate function"); | ||||
| 		} | ||||
| 
 | ||||
| 		PassInfo pass[1]; | ||||
| 		pass[0].flags = PASSFLAG_BYVAL; | ||||
| 		pass[0].size = sizeof(CBaseEntity *); | ||||
| 		pass[0].type = PassType_Basic; | ||||
| 
 | ||||
| 		pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, NULL, pass, 1); | ||||
| 
 | ||||
| 		g_RegNatives.Register(pWrapper); | ||||
| 	} | ||||
| 
 | ||||
| 	CBaseEntity *pEntity; | ||||
| 	if (!(pEntity = UTIL_GetCBaseEntity(params[1], true))) | ||||
| 	{ | ||||
| 		return pContext->ThrowNativeError("Client index %d is not valid", params[1]); | ||||
| 	} | ||||
| 
 | ||||
| 	CBaseEntity *pWearable; | ||||
| 	if (!(pWearable = UTIL_GetCBaseEntity(params[2], false))) | ||||
| 	{ | ||||
| 		return pContext->ThrowNativeError("Wearable index %d is not valid", params[2]); | ||||
| 	} | ||||
| 
 | ||||
| 	unsigned char vstk[sizeof(void *) + sizeof(CBaseEntity *)]; | ||||
| 	unsigned char *vptr = vstk; | ||||
| 
 | ||||
| 	*(void **)vptr = (void *)pEntity; | ||||
| 	vptr += sizeof(void *); | ||||
| 	*(CBaseEntity **)vptr = pWearable; | ||||
| 
 | ||||
| 	pWrapper->Execute(vstk, NULL); | ||||
| 
 | ||||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| sp_nativeinfo_t g_TFNatives[] =  | ||||
| { | ||||
| 	{"TF2_IgnitePlayer",			TF2_Burn}, | ||||
| @ -616,5 +665,6 @@ sp_nativeinfo_t g_TFNatives[] = | ||||
| 	{"TF2_MakeBleed",				TF2_MakeBleed}, | ||||
| 	{"TF2_IsPlayerInDuel",				TF2_IsPlayerInDuel}, | ||||
| 	{"TF2_IsHolidayActive",				TF2_IsHolidayActive}, | ||||
| 	{"TF2_RemoveWearable",			TF2_RemoveWearable}, | ||||
| 	{NULL,							NULL} | ||||
| }; | ||||
|  | ||||
| @ -137,6 +137,13 @@ | ||||
| 				"linux"		"139" | ||||
| 				"mac"		"139" | ||||
| 			} | ||||
| 
 | ||||
| 			"RemoveWearable" | ||||
| 			{ | ||||
| 				"windows"	"426" | ||||
| 				"linux"		"427" | ||||
| 				"mac"		"427" | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -359,6 +359,17 @@ native bool:TF2_IsHolidayActive(TFHoliday:holiday); | ||||
|  */ | ||||
| native bool:TF2_IsPlayerInDuel(client); | ||||
| 
 | ||||
| /** | ||||
|  * Removes an econ wearable (hat, misc, etc) from a player. | ||||
|  * This also deletes the wearable entity. | ||||
|  * | ||||
|  * @param client	Client index. | ||||
|  * @param wearable	Index of the wearable entity. | ||||
|  * @noreturn | ||||
|  * @error			Invalid client index, client not in game, invalid wearable entity, or no mod support. | ||||
| */ | ||||
| native TF2_RemoveWearable(client, wearable); | ||||
| 
 | ||||
| /** | ||||
|  * Called after a condition is added to a player | ||||
|  * | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user