Raised This Month: $ Target: $400
 0% 

dropped weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
woklex
Member
Join Date: Sep 2012
Old 02-06-2015 , 14:47   dropped weapons
Reply With Quote #1

Hello!


I want to write a plugin that when getting into the hands of dropped weapons. Here is the code:

Code:
public PlayerHurtEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
	if (GetConVarInt(g_Cvar_Enable))
	{
		new client     = GetClientOfUserId(GetEventInt(event, "userid"))
		new attacker   = GetClientOfUserId(GetEventInt(event, "attacker"))
		
		if (client > 0)
		{
			if (attacker > 0)
			{
				new String:weapon[64]  
				GetEventString(event, "weapon", weapon, 64)
				
				new hitgroup = GetEventInt(event, "hitgroup")
				new damage   = GetEventInt(event, "damage")
				
				new String:attacker_name[64]
				GetClientName(attacker, attacker_name, 64)
				// Hitgroups
				// 1 = Head
				// 2 = Upper Chest
				// 3 = Lower Chest
				// 4 = Left arm
				// 5 = Right arm
				// 6 = Left leg
				// 7 = Right Leg 
					if ((hitgroup == 4) || (hitgroup == 5))
					{
						PrintToChatAll("hand")
						ForceWeaponDrop(attacker)
					}
					if (hitgroup == 1)
					{
					    PrintToChatAll("hand")
					}
			}
		}
	}
}
Runs only if you kill a man in the arm...How to make it to run when hit in the arm?
woklex is offline
woklex
Member
Join Date: Sep 2012
Old 02-10-2015 , 12:45   Re: dropped weapons
Reply With Quote #2

Ok. It's work:

Code:
public OnPluginStart()
{
	HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post)
}

public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
		new client     = GetClientOfUserId(GetEventInt(event, "userid"))
		new attacker   = GetClientOfUserId(GetEventInt(event, "attacker"))
		new String:weapon[64]  
		GetEventString(event, "weapon", weapon, 64)
		
		new hitgroup = GetEventInt(event, "hitgroup")
		new damage   = GetEventInt(event, "dmg_health")
		new String:attacker_name[64]
				GetClientName(attacker, attacker_name, 64)
				// Hitgroups
				// 1 = Head
				// 2 = Upper Chest
				// 3 = Lower Chest
				// 4 = Left arm
				// 5 = Right arm
				// 6 = Left leg
				// 7 = Right Leg 
				if ((hitgroup == 0) && (damage > 70) && (IsPlayerAlive(client)))
				{
				PrintToChatAll("damage v4 %d to %N", damage, client)
				ForceWeaponDrop(client )
				}
					if ((hitgroup == 4) || (hitgroup == 5) && (IsPlayerAlive(client)))
					{
						PrintHintText(client, "arm v4!")
						ForceWeaponDrop(client )
					}
					if ((hitgroup == 1) && (IsPlayerAlive(client)))
					{
					    PrintHintText(client, "head v4!")
					}
}
I wanted to write a message to players only live what I am doing wrong?

Last edited by woklex; 02-10-2015 at 12:46.
woklex is offline
woklex
Member
Join Date: Sep 2012
Old 02-10-2015 , 12:58   Re: dropped weapons
Reply With Quote #3

Now I wrote "head v4!", But it kills me ... Well, if I got into his head, should not write this, I'm dead.
woklex is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 08-21-2016 , 03:31   Re: dropped weapons
Reply With Quote #4

Hello I need a plugin for Insurgency, could you adapt this plugin to create another one able to force the player to stay in prone position (instead of dropping weapon) when one of the leg has less than 25% health ?

Last edited by KALASH NICOLE; 08-21-2016 at 03:48.
KALASH NICOLE is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode