ZItemKnockback: new plugin WIP
This commit is contained in:
		
							parent
							
								
									2aae907554
								
							
						
					
					
						commit
						57fb499cd7
					
				
							
								
								
									
										85
									
								
								ZItemKnockback/scripting/ZItemKnockback.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								ZItemKnockback/scripting/ZItemKnockback.sp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,85 @@ | ||||
| #pragma semicolon 1 | ||||
| #pragma newdecls required | ||||
| 
 | ||||
| #include <basic> | ||||
| #include <sourcemod> | ||||
| #include <sdkhooks> | ||||
| #include <sdktools> | ||||
| 
 | ||||
| 
 | ||||
| public Plugin myinfo = | ||||
| { | ||||
| 	name 			= "ZItemKnockback", | ||||
| 	author 			= "BotoX", | ||||
| 	description 	= "", | ||||
| 	version 		= "0.0", | ||||
| 	url 			= "" | ||||
| }; | ||||
| 
 | ||||
| public void OnPluginStart() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| public void OnClientPutInServer(int client) | ||||
| { | ||||
| 	SDKHook(client, SDKHook_WeaponEquipPost, OnWeaponEquip); | ||||
| } | ||||
| 
 | ||||
| public Action OnWeaponEquip(int client, int entity) | ||||
| { | ||||
| 	if(!IsValidEntity(entity)) | ||||
| 		return; | ||||
| 
 | ||||
| 	char sClassname[64]; | ||||
| 	GetEntityClassname(entity, sClassname, sizeof(sClassname)); | ||||
| 	if(strcmp(sClassname, "weapon_knife", false) != 0) | ||||
| 		return; | ||||
| 
 | ||||
| 	int HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID"); | ||||
| 	if(!HammerID) | ||||
| 		return; | ||||
| 
 | ||||
| 	char sTargetname[64]; | ||||
| 	GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname)); | ||||
| 
 | ||||
| 	CheckWeaponChildren(client, entity); | ||||
| } | ||||
| 
 | ||||
| void CheckWeaponChildren(int client, int parent) | ||||
| { | ||||
| 	int entity = INVALID_ENT_REFERENCE; | ||||
| 	while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE) | ||||
| 	{ | ||||
| 		if(GetEntPropEnt(entity, Prop_Data, "m_pParent") != parent) | ||||
| 			continue; | ||||
| 
 | ||||
| 		char sClassname[64]; | ||||
| 		GetEntityClassname(entity, sClassname, sizeof(sClassname)); | ||||
| 
 | ||||
| 		if(!strncmp(sClassname, "func_physbox", 12, false) || !strcmp(sClassname, "func_breakable", false)) | ||||
| 		{ | ||||
| 			SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePost); | ||||
| 		} | ||||
| 
 | ||||
| 		else if(!strcmp(sClassname, "trigger_push", false)) | ||||
| 		{ | ||||
| 			AcceptEntityInput(entity, "Kill"); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| public void OnTakeDamagePost(int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, const float damageForce[3], const float damagePosition[3]) | ||||
| { | ||||
| 	if(attacker <= 0 || attacker > MAXPLAYERS) | ||||
| 		return; | ||||
| 
 | ||||
| 	int iKnife = GetEntPropEnt(victim, Prop_Data, "m_pParent"); | ||||
| 	if(iKnife <= 0) | ||||
| 		return; | ||||
| 
 | ||||
| 	int client = GetEntPropEnt(iKnife, Prop_Data, "m_hOwnerEntity"); | ||||
| 	if(client <= 0 || client > MAXPLAYERS) | ||||
| 		return; | ||||
| 
 | ||||
| 	SDKHooks_TakeDamage(client, inflictor, attacker, damage, damagetype, weapon, damageForce, damagePosition); | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user