Detecting holding a weapon and using it at the same time
#1

Hey there,

I can detect if the player is holding a weapon but I can't detect if he is using it or not. I'm working on a damage system and I need to detect if the player shoots with the weapon he's holding because when the shooter gets closer to the target and tries to shoot him, he doesn't use the weapon and hits the target with hand and it still detects the weapon so it's an issue for my damage system.

EDIT: I tried to get the animation name the ped does whilst hitting with a gun, not shooting but it's not a different animation or I was not able to get the name of it.
Reply
#2

PHP код:
#include <a_samp>
#define HOLDING(%0) \
    
((newkeys & (%0)) == (%0))
    
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
GetPlayerWeapon(playerid) > && GetPlayerWeapon(playerid) < 40)
    {
        if(
PRESSED(KEY_FIRE) || HOLDING(KEY_FIRE))
        {
             
//player using weapon.
        
}
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by Whatname
Посмотреть сообщение
PHP код:
#include <a_samp>
#define HOLDING(%0) \
    
((newkeys & (%0)) == (%0))
    
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
GetPlayerWeapon(playerid) > && GetPlayerWeapon(playerid) < 40)
    {
        if(
PRESSED(KEY_FIRE) || HOLDING(KEY_FIRE))
        {
             
//player using weapon.
        
}
    }
    return 
1;

Well, I'm using OnPlayerGiveDamage public to get the damage value and such so how can I use it with these codes? Using a variable doesn't seem like a good way, it's probably not gonna work so fast if I'd do that.
Reply
#4

i thought you mean something else you can use this:

PHP код:

public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponidbodypart)
{
      if(
weaponid >= && weaponid <= 39)
      {
           
//code
      
}
      return 
1;

Reply
#5

Quote:
Originally Posted by Whatname
Посмотреть сообщение
i thought you mean something else you can use this:

PHP код:

public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponidbodypart)
{
      if(
weaponid >= && weaponid <= 39)
      {
           
//code
      
}
      return 
1;

I already use this but the problem is, player is holding a weapon in hand but he isn't shooting with it he is hitting with it.

So, when the player hits with a weapon it still does a custom damage, I want it to work just like normal hitting, using fist.
Reply
#6

you cant hit with weapon in samp
Reply
#7

Quote:
Originally Posted by Whatname
Посмотреть сообщение
you cant hit with weapon in samp
When you get close to your target and try to shoot them, it happens, whatever you call it.
Reply
#8

ohh yeah i forgot
Reply
#9

I still need help.
Reply
#10

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	if (! ((WEAPON_COLT45 <= weaponid <= WEAPON_SNIPER) || weaponid == WEAPON_MINIGUN))
		return 0;
    return 1;
}
Try this if does not work use weapon-config include you can set every weapon damage amount.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)