Binato/server/Packets/UserPresence.js

24 lines
604 B
JavaScript
Raw Permalink Normal View History

2020-08-27 13:09:35 +01:00
const osu = require("osu-packet"),
getUserById = require("../util/getUserById.js");
2020-08-27 13:09:35 +01:00
2021-01-26 12:26:46 +00:00
module.exports = function(currentUser, id = 0, sendImmidiate = true) {
const osuPacketWriter = new osu.Bancho.Writer;
2020-08-27 13:09:35 +01:00
const User = getUserById(id);
2020-08-27 13:09:35 +01:00
if (User == null) return;
2020-08-27 13:09:35 +01:00
osuPacketWriter.UserPresence({
userId: id,
username: User.username,
timezone: 0,
countryId: User.countryID,
permissions: 4,
longitude: User.location[1],
latitude: User.location[0],
rank: User.rank
});
2020-08-27 13:09:35 +01:00
if (sendImmidiate) currentUser.addActionToQueue(osuPacketWriter.toBuffer);
else return osuPacketWriter.toBuffer;
2020-08-27 13:09:35 +01:00
}