/**
* Player info page — single player detail with quirk fixes.
*/
function PlayerInfoPage(params, container) {
var userid = params[2]; // SteamID from URL
var html =
'
' +
'
' +
'
' +
'
' +
'Player: ' + userid + ' ' +
' ' +
' ' +
'
' +
'
' +
'
' +
'
This Player is currently not connected to this server!
' +
'
' +
'
' +
'
' +
'
';
container.innerHTML = html;
function refresh() {
Rcon.getPlayers(function (players) {
var info = null;
for (var i = 0; i < players.length; i++) {
if (String(players[i].SteamID) === userid) { info = players[i]; break; }
}
if (!info) {
document.getElementById('pi-notfound').style.display = 'block';
document.getElementById('pi-fields').innerHTML = '';
return;
}
document.getElementById('pi-notfound').style.display = 'none';
// Fix known Rust RCON quirk: VoiationLevel → ViolationLevel
if (info.VoiationLevel !== undefined) {
info.ViolationLevel = info.VoiationLevel;
delete info.VoiationLevel;
}
// Remove XP remnants
delete info.CurrentLevel;
delete info.UnspentXp;
document.getElementById('pi-username').textContent = info.DisplayName || userid;
var fieldsHtml = '';
for (var key in info) {
if (info.hasOwnProperty(key)) {
var value = info[key];
if (key === 'Address') {
value = maskIp(value);
}
fieldsHtml += '' + key + ': ' + value + '
';
}
}
document.getElementById('pi-fields').innerHTML = fieldsHtml;
});
}
document.getElementById('pi-refresh').addEventListener('click', refresh);
document.getElementById('pi-kick').addEventListener('click', function () {
if (confirm('Kick player ' + (document.getElementById('pi-username').textContent) + '?')) {
Rcon.command('kick ' + userid);
}
});
document.getElementById('pi-ban').addEventListener('click', function () {
var reason = prompt('Ban reason:', '');
if (reason !== null) {
Rcon.command('ban ' + userid + ' ' + (reason || 'No reason'));
}
});
if (Rcon.isConnected()) refresh();
else { var _c = function () { refresh(); Rcon.off('connected', _c); }; Rcon.on('connected', _c); }
}