警告
此回调是在SA-MP 0.3d中添加的,在早期版本中不起作用!描述
当玩家受到伤害时会调用此回调。姓名 | 描述 |
---|---|
playerid | 受到伤害的玩家的 ID。 |
issuerid | 造成伤害的玩家的 ID。如果是自己造成的,则为 INVALID_PLAYER_ID。 |
amount | 玩家受到的伤害量(生命值和护甲值之和)。 |
weaponid | 武器的 ID/损坏原因。 |
bodypart | 身体被击中的部位。 (注意:此参数是在 0.3z 中添加的。如果使用旧版本,请忽略它!) |
返回
1 - 回调不会在其他过滤器脚本中调用。 0 - 允许在其他过滤器脚本中调用此回调。 它总是在过滤器脚本中首先被调用,因此返回 1 会阻止其他过滤器脚本看到它。例子
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if (issuerid != INVALID_PLAYER_ID) // If not self-inflicted
{
new
infoString[128],
weaponName[24],
victimName[MAX_PLAYER_NAME],
attackerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, victimName, sizeof (victimName));
GetPlayerName(issuerid, attackerName, sizeof (attackerName));
GetWeaponName(weaponid, weaponName, sizeof (weaponName));
format(infoString, sizeof(infoString), "%s has made %.0f damage to %s, weapon: %s, bodypart: %d", attackerName, amount, victimName, weaponName, bodypart);
SendClientMessageToAll(-1, infoString);
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if (issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
{
// One shot to the head to kill with sniper rifle
SetPlayerHealth(playerid, 0.0);
}
return 1;
}