Fixed master address, admin cheats (money, needs, goto/bring), docs page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -221,6 +221,66 @@ namespace MSCO
|
||||
return list;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Cheats (Admin-Menü)
|
||||
|
||||
/// <summary>Cheats nur im Spiel und nur für Server-Admins bzw. den P2P-Host.</summary>
|
||||
public bool CanCheat { get { return session != null && MenuHelper.InGame && (dedicated ? isAdmin : session.IsHost); } }
|
||||
|
||||
public void CheatMoney(float amount)
|
||||
{
|
||||
if (!CanCheat) return;
|
||||
overlays.Log(Cheats.AddMoney(amount));
|
||||
AnnounceCheat("gave themselves " + amount.ToString("0") + " MK");
|
||||
}
|
||||
|
||||
public void CheatNeeds()
|
||||
{
|
||||
if (!CanCheat) return;
|
||||
overlays.Log(Cheats.FillNeeds());
|
||||
AnnounceCheat("refilled their needs");
|
||||
}
|
||||
|
||||
/// <summary>Zu einem Mitspieler teleportieren.</summary>
|
||||
public void GotoPlayer(int playerId)
|
||||
{
|
||||
PlayerInfo p;
|
||||
if (!CanCheat || !players.TryGetValue(playerId, out p) || p.Avatar == null) { overlays.Log("Player position unknown"); return; }
|
||||
passenger.Exit(localPlayer, playerCamera);
|
||||
PlayerState s = p.Avatar.LastState;
|
||||
Vector3 side = Quaternion.Euler(0f, s.RotationY, 0f) * Vector3.right;
|
||||
if (Cheats.Teleport(localPlayer, s.Position + side * TeleportSideOffset)) overlays.Log("Teleported to " + p.Name);
|
||||
}
|
||||
|
||||
/// <summary>Mitspieler zu sich holen (Server prüft, ob man Admin ist).</summary>
|
||||
public void BringPlayer(int playerId)
|
||||
{
|
||||
if (!CanCheat || localPlayer == null || playerId == localId) return;
|
||||
Vector3 pos = localPlayer.position + localPlayer.forward * TeleportSideOffset;
|
||||
if (dedicated)
|
||||
{
|
||||
session.SendTo(NetSession.HostId, MsgType.AdminAction, NetSession.Build(w =>
|
||||
{
|
||||
w.Write((byte)3);
|
||||
w.Write(playerId);
|
||||
w.Write("");
|
||||
w.Write(pos.x); w.Write(pos.y); w.Write(pos.z);
|
||||
}));
|
||||
}
|
||||
else if (players.ContainsKey(playerId))
|
||||
{
|
||||
session.SendTo(playerId, MsgType.Teleport, NetSession.Build(w => { w.Write(pos.x); w.Write(pos.y); w.Write(pos.z); }));
|
||||
overlays.Log("Brought " + players[playerId].Name + " to you");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Cheats für alle sichtbar im Chat melden.</summary>
|
||||
void AnnounceCheat(string what)
|
||||
{
|
||||
string text = OwnName() + " " + what + " (admin)";
|
||||
overlays.AddChat("", text, true);
|
||||
SendGame(MsgType.Chat, NetSession.Build(w => w.Write("* " + text)));
|
||||
}
|
||||
|
||||
public void AdminAction(bool ban, int playerId, string reason)
|
||||
{
|
||||
if (session == null) return;
|
||||
@@ -835,6 +895,17 @@ namespace MSCO
|
||||
SaveSync.WriteFile(file, data);
|
||||
break;
|
||||
|
||||
case MsgType.Teleport:
|
||||
{
|
||||
// Ein Admin holt uns zu sich
|
||||
var pos = new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||
if (!MenuHelper.InGame || localPlayer == null) break;
|
||||
passenger.Exit(localPlayer, playerCamera);
|
||||
Cheats.Teleport(localPlayer, pos);
|
||||
overlays.AddChat("", "An admin teleported you", true);
|
||||
break;
|
||||
}
|
||||
|
||||
case MsgType.AdminStatus:
|
||||
isAdmin = r.ReadBoolean();
|
||||
if (isAdmin) overlays.Log("You are an admin on this server - type /admin in chat or 'admin' here.");
|
||||
|
||||
Reference in New Issue
Block a user