let hitList = []
const DEAD_MSG = "DEAD"
const Z_OFFSET = 1.5
mp.events.add("SRV::CL::DrawHitMarker", (targetId, damage, bone, flag) => {
let player = mp.players.atRemoteId(targetId);
if (player === undefined || player === null) return;
let color = [];
switch (flag) {
// обычный хит
case 0:
color = [255,255,255]
break
// голова
case 1:
color = [0,255,0]
break
case 2:
// умер
color = [255,0,0]
break
default:
color = [255,255,255]
break
}
hitList.push({
text: flag === 2 ? DEAD_MSG : damage,
position: new mp.Vector3(player.position.x,player.position.y,player.position.z + Z_OFFSET),
color: color,
opacityCorrosion: 0
})
})
const FONT = 2
const SCALE = 0.4
const OPACITY_PER_FRAME = 2
const Z_OFFSET_PER_FRAME = 0.02
mp.events.add('render', () => {
hitList.forEach((hit) => {
mp.game.graphics.drawText(hit.text, [hit.position.x,hit.position.y,hit.position.z], {
font: FONT,
color: [hit.color[0], hit.color[1],hit.color[2], 155 - hit.opacityCorrosion],
scale: [SCALE, SCALE],
outline: true,
})
hit.opacityCorrosion = hit.opacityCorrosion + OPACITY_PER_FRAME
hit.position.z = hit.position.z + Z_OFFSET_PER_FRAME
if (hit.opacityCorrosion > 155) hitList.pop();
})
})