OnProjectileHitZone
A player’s arrow, bolt or ball reached a target zone.
Called for every zone marked with SetZoneHittable that the shot’s flight entered before it stopped - at the ground, at a
wall (when the server has the collision export) or in a body it struck - at the moment the arrow got there, a quarter of a
second later still. A shot flies on through a zone, so one arrow can reach several. A zone the shooter stands in does not
count for the shot leaving it.
Syntax
Section titled “Syntax”function OnProjectileHitZone(pid, zone, weapon, ammo, x, y, z) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the shooter |
zone |
number | the zone reached |
weapon |
string | the bow, crossbow or gun by its table name |
ammo |
string | the arrow, bolt or ball by its table name |
x |
number | where the shot entered the zone, metres |
y |
number | metres |
z |
number | metres |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”-- an archery range: a ball over the bullseye, a ring around itlocal bull = CreateSphereZone(1290, 1100, 27.5, 0.15)local ring = CreateSphereZone(1290, 1100, 27.5, 0.6)SetZoneHittable(bull, true)SetZoneHittable(ring, true)local score = {}
function OnProjectileHitZone(pid, zone, weapon, ammo, x, y, z) local points = zone == bull and 10 or 3 -- an arrow through the bull passes the ring too: both count score[pid] = (score[pid] or 0) + points GameText(pid, "+" .. points .. " (" .. score[pid] .. ")", 1500, GAMETEXT_LOWER)endSee also
Section titled “See also”SetZoneHittable · OnMeleeHitZone · CreateSphereZone · the Zones group of the index
