Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
@Packet name Economy
|
||||
@Packet identifier 158
|
||||
@Description Sends economy data
|
||||
@Data pId,
|
||||
@Structure -
|
||||
*/
|
||||
|
||||
module.exports = function (data) {
|
||||
const packetLength = 1 + 1 + data.length * 5;
|
||||
const buffer = new ArrayBuffer(packetLength);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
for (let i = 0, length = data.length; i < length; i++) {
|
||||
const economy = data[i];
|
||||
view.setUint8(2 + i * 5, economy.id);
|
||||
view.setUint32(2 + i * 5 + 1, economy.amount);
|
||||
};
|
||||
|
||||
view.setUint8(0, 158);
|
||||
view.setUint8(1, packetLength);
|
||||
|
||||
return buffer;
|
||||
};
|
||||
Reference in New Issue
Block a user