public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(gPlayerClass[playerid] == Policeman) { if(issuerid != INVALID_PLAYER_ID && weaponid == 23) { ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); } } return 1; }
You likely want to check the gPlayerClass of the issuer, not the target. That also implies you want to move the INVALID_PLAYER_ID check in that condition too.
|
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(
issuerid != INVALID_PLAYER_ID &&
gPlayerClass[issuerid] == Policeman &&
weaponid == 23
)
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(gPlayerClass[killerid] == Policeman)
{
if(issuerid != INVALID_PLAYER_ID && weaponid == 23)
{
ClearAnimations(playerid);
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
}
}
return 1;
}
Return Values: 0 - Prevent the bullet from causing damage.
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == BULLET_HIT_TYPE_PLAYER)
{
if(gPlayerClass[playerid] == Policeman && weaponid == 23)
{
ApplyAnimation(hitid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
//Just to ensure it works, we'll send a message to the playerid:
SendClientMessage(playerid, -1, "You hit someone with your taser.");
return 0; // player wont take damage.
}
}
return 1;
}