feat: add fun/admin actions to player info page
Added button group below stats: Kill, Heal, Moderator, Owner. - Kill/Heal are plugin-dependent (kill/heal commands) - Moderator/Owner are standard Rust RCON (moderatorid/ownerid) - Buttons hidden until player is confirmed online - Confirm dialogs on all destructive actions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,14 @@ function PlayerInfoPage(params, container) {
|
||||
'<div class="col-lg-12">' +
|
||||
'<div id="pi-fields" class="row"><span class="text-white-50">Loading…</span></div>' +
|
||||
'</div>' +
|
||||
'<div id="pi-actions" class="col-lg-12 mt-3" style="display:none">' +
|
||||
'<div class="btn-group d-flex">' +
|
||||
'<button id="pi-kill" class="btn btn-outline-danger"><i class="bi bi-skull"></i> Kill</button>' +
|
||||
'<button id="pi-heal" class="btn btn-outline-success"><i class="bi bi-heart-fill"></i> Heal</button>' +
|
||||
'<button id="pi-mod" class="btn btn-outline-info"><i class="bi bi-shield-check"></i> Moderator</button>' +
|
||||
'<button id="pi-owner" class="btn btn-outline-warning"><i class="bi bi-star-fill"></i> Owner</button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
container.innerHTML = html;
|
||||
@@ -40,9 +48,11 @@ function PlayerInfoPage(params, container) {
|
||||
if (!info) {
|
||||
document.getElementById('pi-notfound').style.display = 'block';
|
||||
document.getElementById('pi-fields').innerHTML = '';
|
||||
document.getElementById('pi-actions').style.display = 'none';
|
||||
return;
|
||||
}
|
||||
document.getElementById('pi-notfound').style.display = 'none';
|
||||
document.getElementById('pi-actions').style.display = 'block';
|
||||
|
||||
// Fix known Rust RCON quirk: VoiationLevel → ViolationLevel
|
||||
if (info.VoiationLevel !== undefined) {
|
||||
@@ -88,6 +98,32 @@ function PlayerInfoPage(params, container) {
|
||||
}
|
||||
});
|
||||
|
||||
var pname = document.getElementById('pi-username');
|
||||
|
||||
document.getElementById('pi-kill').addEventListener('click', function () {
|
||||
if (confirm('Kill ' + pname.textContent + '? (plugin required)')) {
|
||||
Rcon.command('kill ' + userid);
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('pi-heal').addEventListener('click', function () {
|
||||
if (confirm('Heal ' + pname.textContent + '? (plugin required)')) {
|
||||
Rcon.command('heal ' + userid);
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('pi-mod').addEventListener('click', function () {
|
||||
if (confirm('Promote ' + pname.textContent + ' to Moderator?')) {
|
||||
Rcon.command('moderatorid ' + userid + ' ' + pname.textContent);
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('pi-owner').addEventListener('click', function () {
|
||||
if (confirm('Promote ' + pname.textContent + ' to Owner?')) {
|
||||
Rcon.command('ownerid ' + userid + ' ' + pname.textContent);
|
||||
}
|
||||
});
|
||||
|
||||
if (Rcon.isConnected()) refresh();
|
||||
else { var _c = function () { refresh(); Rcon.off('connected', _c); }; Rcon.on('connected', _c); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user