Skip to content

playerHitEntity

Tells your gamemode that a player hit something another player’s game runs: that player, their car, or an NPC.

Renamed in 0.28 from hit; see renamed names.

server.on("playerHitEntity", ({ attacker, victim, attackerNetworkId, victimNetworkId, targetSeat, weapon, impactIntensity, hitKind, provenance }) => void)
Name Type Description
attacker PlayerSnapshot or null The player who hit, when the hitting entity is that player’s ped or the car they drive; otherwise null.
victim PlayerSnapshot or null The player who was hit, the same way; null for an NPC or an empty car.
attackerNetworkId number The hitting entity’s network ID.
victimNetworkId number The network ID of what was hit; a vehicle’s ID for the NPCs in it.
targetSeat number | null null for the entity itself; for an NPC in a vehicle, its seat: 0 the driver, 1-3 a passenger. Always null for a player.
weapon number The weapon type.
impactIntensity number How hard the hit was: for damage the game’s damage before armour (at most 1100), for runOver how hard the car struck (at most 1000). Not the health lost; see playerHealthOrArmourDecreased.
hitKind "damage" | "runOver" A hit, or being run over.
provenance "client-report" The hitter’s game says so; the server doesn’t prove it.

Count hits between players.

gamemodes/deathmatch.ts
import { server } from "nativemp";
const hits = new Map<number, number>();
server.on("playerHitEntity", ({ attacker, victim }) => {
if (attacker && victim) hits.set(attacker.id, (hits.get(attacker.id) ?? 0) + 1);
});