Initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
@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;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user