Files
2026-08-24 22:20:36 +02:00

40 lines
1.0 KiB
JavaScript

/*
@Packet name -
@Packet identifier 61
@Description
@Data pId
@Structure -
*/
module.exports = {
init: startPosition => {
const packetLength = (10 * 16 + 10 * 4) + 3 + 1;
const buffer = new ArrayBuffer(packetLength);
const view = new DataView(buffer);
view.setUint8(0, 61);
view.setUint8(1, packetLength);
view.setUint16(2, startPosition);
let i = 0;
return {
update: d => {
const startIndex = i * (16 + 4);
const nameBuffer = Buffer.from(d.username);
for (const pair of nameBuffer.entries()) {
const index = pair[0];
view.setUint8(4 + startIndex + index, pair[1]);
};
view.setUint32(4 + startIndex + 16, d.amount);
i++;
},
get: () => {
return buffer;
}
};
}
};