AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   dropped weapons (https://forums.alliedmods.net/showthread.php?t=257708)

woklex 02-06-2015 14:47

dropped weapons
 
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 02-10-2015 12:45

Re: dropped weapons
 
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?

woklex 02-10-2015 12:58

Re: dropped weapons
 
Now I wrote "head v4!", But it kills me ... Well, if I got into his head, should not write this, I'm dead.

KALASH NICOLE 08-21-2016 03:31

Re: dropped weapons
 
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 ?


All times are GMT -4. The time now is 16:23.

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