OnPlayerWeaponShot
#1

Hello ,

I have a problem with OnPlayerWeaponShot.
I am trying to detect when someone has shot a player while q or e pressed in a vehicle.
Also i am trying to detect if someone on a bike shot someone.
But i dont know how i can detect that.
Can someone help me with that?

Admigo
Reply
#2

Drive-by doesn't work with OnPlayerWeaponShot.

You'll have to use key detection (KEY_LOOK_LEFT/KEY_LOOK_RIGHT + KEY_FIRE ?).

You could use GetPlayerKeys under OnPlayerTakeDamage.

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(GetPlayerState(issuerid) == 2)
    {
        new keys, updown, leftright;
        GetPlayerKeys(issuerid, keys, updown, leftright);
        if((keys & KEY_LOOK_LEFT || keys & KEY_LOOK_RIGHT) && (keys & KEY_FIRE))
        {
            // Driver drive-by
        }
    }
    return 1;
}
NOTE: Players can drive-by FORWARDS (not holding KEY_LOOK_LEFT/RIGHT) while on a motorbike. You could check for that.

EDIT: Actually, thinking about it, you only really need to check if they are a driver, as obviously if they dealt damage from inside a vehicle, it's got to be a weapon. Although the exception is if they drive in to someone, for which the reason would be 'collision'.
Reply
#3

Quote:
Originally Posted by MP2
View Post
Drive-by doesn't work with OnPlayerWeaponShot.

You'll have to use key detection (KEY_LOOK_LEFT/KEY_LOOK_RIGHT + KEY_FIRE ?).

You could use GetPlayerKeys under OnPlayerTakeDamage.

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(GetPlayerState(issuerid) == 2)
    {
        new keys, updown, leftright;
        GetPlayerKeys(issuerid, keys, updown, leftright);
        if((keys & KEY_LOOK_LEFT || keys & KEY_LOOK_RIGHT) && (keys & KEY_FIRE))
        {
            // Driver drive-by
        }
    }
    return 1;
}
NOTE: Players can drive-by FORWARDS (not holding KEY_LOOK_LEFT/RIGHT) while on a motorbike. You could check for that.

EDIT: Actually, thinking about it, you only really need to check if they are a driver, as obviously if they dealt damage from inside a vehicle, it's got to be a weapon. Although the exception is if they drive in to someone, for which the reason would be 'collision'.
Thanks MP2. Rep+.
I need this for detecting if Cops hitting innocent players.
Reply
#4

In which case just use OnPlayerTakeDamage and don't check anything. You don't need to check if they're doing a drive-by.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)